Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it a pretty way for exit_boot_services()? #914

Closed
julic20s opened this issue Aug 10, 2023 · 2 comments
Closed

Is it a pretty way for exit_boot_services()? #914

julic20s opened this issue Aug 10, 2023 · 2 comments

Comments

@julic20s
Copy link
Contributor

julic20s commented Aug 10, 2023

The current solution is very convenient, but I think some improvements could be added:

  1. 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.
  2. 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.

It's a related issue: #523

@julic20s
Copy link
Contributor Author

julic20s commented Aug 10, 2023

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.

@julic20s
Copy link
Contributor Author

I will take a pull request.

@julic20s julic20s mentioned this issue Aug 10, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant