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

uefi: add BootPolicy type #1326

Merged
merged 6 commits into from
Aug 14, 2024
Merged

Conversation

phip1611
Copy link
Contributor

This was decoupled from #1297 for better review-ability.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

This type is used in three functions of the UEFI spec. Having an enum instead of a
boolean simplifies the interface as the variants can be properly documented.
- public modules
- private modules
- public uses
- private uses

This is consistent with other parts of the code.
This adds the new `BootPolicy` type into `LoadImageSource`.
The existing code duplication is just temporary until the old API
is deleted. Nevertheless, it is nicer to have this conversion close
to the actual type.
/// various UEFI functions that load files (typically UEFI images).
///
/// This type is not ABI compatible. On the ABI level, this is an UEFI
/// boolean.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it could be made compatible: add repr(u8) and BootSelection = 1, ExactMatch = 0.

(As long as this type is only passed into UEFI APIs, and not read from them; in that case newtype_enum might be better.)

Copy link
Contributor Author

@phip1611 phip1611 Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to postpone that decision/discussion to #1307?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the type is only being passed into the API, UB shouldn't be a concern -- we'll always initialize BootPolicy correctly.

Copy link
Contributor Author

@phip1611 phip1611 Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you just adding thoughts to the discussion or do you want this doccomment to be removed before we merge it? That's not clear to me right now :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we should make changes before merging, but actually since there is no declared repr right now, it wouldn't be a breaking change to add repr(u8) in the future I think. So let's go ahead and merge.

@nicholasbishop nicholasbishop added this pull request to the merge queue Aug 14, 2024
Merged via the queue into rust-osdev:main with commit 59790f8 Aug 14, 2024
13 checks passed
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

Successfully merging this pull request may close these issues.

2 participants