-
-
Notifications
You must be signed in to change notification settings - Fork 177
uefi: Make BootServices
a wrapper around uefi_raw::table::boot::BootServices
#863
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
uefi: Make BootServices
a wrapper around uefi_raw::table::boot::BootServices
#863
Conversation
uefi/src/table/boot.rs
Outdated
@@ -94,7 +94,7 @@ struct BootServicesInternal { | |||
|
|||
// Protocol handlers | |||
install_protocol_interface: unsafe extern "efiapi" fn( | |||
handle: &mut Option<Handle>, | |||
handle: *mut uefi_raw::Handle, |
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.
Why can't we use Option<&mut uefi_raw::Handle>
here and in similar places? It has the same memory layout as a raw pointer, but we do have more guarantees in higher-level Rust APIs.
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.
We could, but I'm wary of using any references at all in the uefi-raw interface. Broadly, my thinking is that we want uefi-raw to be as close to the C interface as possible, and in particular placing no restrictions on the API that wouldn't also be present for a C user. My understanding is that a Rust reference, even if it's never dereferenced, must always be valid (aligned, non-dangling), and obey the (currently unfinished) aliasing rules.
This is a transitional type working towards replacing `BootServices` with a transparent wrapper around the `uefi_raw` `BootServices` type. It makes future diffs smaller by taking care of the mechanical change of adding all the `.0` accessors up front.
These are simple cases that just need an `as_ptr()` call to make the types line up.
e073a4c
to
59da9b3
Compare
The overall diff here is fairly large, somewhat unavoidable since there are so many functions in BootServices. I've broken it down into smaller commits that should make it clearer how the transformations were done, and also easier to bisect if any bugs are found later.
Checklist