Skip to content

Conversation

@phip1611
Copy link
Member

@phip1611 phip1611 commented Jan 1, 2026

This ultimately adds and tests boot::install_multiple_protocol_interface() and boot::uninstall_multiple_protocol_interface() (see #302). Further, it streamlines multiple things and adds pre-requisites:

  • We were inconsistent in our API: sometimes we consume <P: ProtocolPointer + ?Sized> and sometimes proto: &Guid
    • Inconsistency is always bad
    • The generic-based approach is not usable if the GUID is only available at runtime
  • Therefore, I refactored multiple functions to use the generic-based API for consistency and added _by_guid counterparts
  • These ultimatively also enabled me to implement install_multiple_protocol_interface()

Checklist

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

The majority of our protocol-related public functions use a generic
approach with `<P: ProtocolPointer + ?Sized>`. Unfortunately:

- we are inconsistent with that
- this hinders some use-cases where the GUID is only known at
  runtime

Therefore, this is the first commit of a series of commits that
improves the situation by providing base functions that use the
generic-based API and `by_guid` counterparts for more runtime-
flexibility.
Having these functions is very helpful if one installs multiple protocol
interfaces in a driver at once. The caveat is unfortunately that Rust
handling of varargs isn't very convenient. I also didn't come up with
a working + nice way using normal macros to workaround.

Instead, I looked into the implementation in edk2 [0]. The logic is
fairly simple and can be emulated on a higher-level by us.

[0] https://github.com/tianocore/edk2/blob/66346d5edeac2a00d3cf2f2f3b5f66d423c07b3e/MdeModulePkg/Core/Dxe/Hand/Handle.c#L630
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