You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current solution is very convenient, but I think some improvements could be added:
The memory type of allocation for memory map in exit_boot_services() shouldn't be fixed at MemoryType::LOADER_DATA. Sometime I want to place it into a memory region which has a custom MemoryType.
Return (.., MemoryMap<'static>) by value can not keep the lifetime in 'static. For example:
let(_, memory_map) = system_table.exit_boot_services();let iter:MemoryMapIter<'static> = memory_map.entries();// error, the lifetime was changed.
Because the type of memory_map will be MemoryMap<'_> but not MemoryMap<'static>. This causes the lifetime of the buffer to shrink. In fact, the lifetime of memory map buffer != the lifetime of MemoryMap. MemoryMap::entries() returns a iterator with wrong lifetime.
Currently I have to use a static mutable variable to save the memory map returned by exit_boot_services() to keep the lifetime.
Change exit_boot_services() into exit_boot_services(memory_type: MemoryType) to help user to change the memory type of memory map. But I'm not sure how to fix the second problem. Remove the lifetime of MemoryMap may not a good way.
Use buffer pointer instead of its reference in MemoryMapIter will solve the second problem.
The current solution is very convenient, but I think some improvements could be added:
(.., MemoryMap<'static>)
by value can not keep the lifetime in'static
. For example:Because the type of memory_map will be MemoryMap<'_> but not MemoryMap<'static>. This causes the lifetime of the buffer to shrink. In fact, the lifetime of memory map buffer != the lifetime of MemoryMap.MemoryMap::entries() returns a iterator with wrong lifetime.
Currently I have to use a static mutable variable to save the memory map returned by exit_boot_services() to keep the lifetime.
It's a related issue: #523
The text was updated successfully, but these errors were encountered: