-
-
Notifications
You must be signed in to change notification settings - Fork 170
Type-safety cleanup and safe exit from boot services #65
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Document parameter names of various UEFI methods - Avoid using usize as a pointer type, prefer c_void pointer if we have to - Use *mut u8 for pool allocation since this is what Rust's allocator API uses - Use u64 for page allocations since that is needed for PAE-like configurations - Tie protocols to the lifetime of the BootServices
- Minimize usage of fake 'static lifetimes - Prefer explicit lifetimes, or that fails raw pointers - Clarify the safety problems of global services - Provide a way to prepare exit from boot services
HadrienG2
commented
Oct 21, 2018
Do you have any other feedback before this is merged? |
HadrienG2
commented
Oct 22, 2018
GabrielMajeri
approved these changes
Oct 23, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the mentioned changes, LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR gives uefi-rs a solid type-safety cleanup (e.g. no more "usize" as a substitute for pointers, and using 'static when that's a lie is avoided). Most importantly, however, it also fixes #3 by providing a safe method to exit UEFI boot services, ensuring that the borrow checker will warn you if you try to use boot services after the fact.
Achieving this result required a significant redesign of how protocols work. Previously, protocols were assumed to live forever, whereas now they are treated as a reference to UEFI boot services. Some lifetime inconvenience results, and impl Trait may not be used quite as frequently as before, but overall the patch remains remarkably simple considering what it does.
The type-safety cleanup fixes #23 .