Skip to content

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
merged 25 commits into from
Oct 23, 2018

Conversation

HadrienG2
Copy link
Contributor

@HadrienG2 HadrienG2 commented Oct 21, 2018

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 .

- 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
Copy link
Contributor Author

Do you have any other feedback before this is merged?

Copy link
Collaborator

@GabrielMajeri GabrielMajeri left a 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

@HadrienG2 HadrienG2 merged commit efacc77 into master Oct 23, 2018
@HadrienG2 HadrienG2 deleted the exit-boot-services branch October 23, 2018 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify lifetime of the pointers returned by the API exit_boot_services should consume the host BootServices
2 participants