Skip to content

Commit 44107eb

Browse files
committed
uefi: protocols: cleanup register_protocol_notify[_by_guid]()
1 parent 688b26a commit 44107eb

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

uefi-test-runner/src/boot/misc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,11 @@ fn test_register_protocol_notify() {
145145
info!("in callback for test_register_protocol_notify")
146146
}
147147

148-
let protocol = &TestProtocol::GUID;
149148
let event = unsafe {
150149
boot::create_event(EventType::NOTIFY_SIGNAL, Tpl::NOTIFY, Some(callback), None).unwrap()
151150
};
152151

153-
boot::register_protocol_notify(protocol, &event)
152+
boot::register_protocol_notify::<TestProtocol>(&event)
154153
.expect("Failed to register protocol notify fn");
155154
}
156155

uefi/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Added `proto::nvme::pass_thru::NvmePassThru::broadcast()`.
99
- Added `proto::media::block::BlockIO2`.
1010
- Added `boot::test_protocol_by_guid()`
11+
- Added `boot::register_protocol_notify_by_guid()`
1112

1213
## Changed
1314
- Changed ordering of `proto::pci::PciIoAddress` to (bus -> dev -> fun -> reg -> ext_reg).
@@ -16,6 +17,8 @@
1617
returns `Option<Event>` instead of `&Event`.
1718
- `Http::get_mode_data` doesn't consume a parameter anymore and instead return
1819
an owned value of type `HttpConfigData`
20+
- **Breaking**: `boot::register_protocol_notify()` now follows our generic-based
21+
API and now longer consumes a `&Guid` parameter.
1922

2023
# uefi - v0.36.1 (2025-11-05)
2124

uefi/src/boot.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,15 @@ pub unsafe fn uninstall_protocol_interface(
819819
/// # Errors
820820
///
821821
/// * [`Status::OUT_OF_RESOURCES`]: the event could not be allocated.
822-
pub fn register_protocol_notify(
822+
pub fn register_protocol_notify<P: ProtocolPointer + ?Sized>(
823+
event: &Event,
824+
) -> Result<SearchType<'static>> {
825+
register_protocol_notify_by_guid(&P::GUID, event)
826+
}
827+
828+
/// Variant of [`register_protocol_notify`] that consumes the [`Guid`] as
829+
/// parameter.
830+
pub fn register_protocol_notify_by_guid(
823831
protocol: &'static Guid,
824832
event: &Event,
825833
) -> Result<SearchType<'static>> {

0 commit comments

Comments
 (0)