From 1855be5a93091981d03f302178bea4cebd0715a6 Mon Sep 17 00:00:00 2001 From: Timothy Roberts <39689890+timrobertsdev@users.noreply.github.com> Date: Sun, 6 Nov 2022 14:36:52 -0500 Subject: [PATCH 1/4] Implement additional `BootServices` functions - Implement `BootServices::install_protocol_interface` - Implement `BootServices::uninstall_protocol_interface` - Implement `BootServices::reinstall_protocol_interface` - Implement `BootServices::register_protocol_notify` - Add `SearchType::ByRegisterNotify` variant. - Add `SearchType::from_search_key` - Add `SearchKey` type that abstracts over an opaque pointer given by `BootServices::register_protocol_notify`. --- CHANGELOG.md | 5 ++ src/data_types/mod.rs | 6 ++ src/table/boot.rs | 150 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 147 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26f06d452..2f1c97788 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ - Added structs to represent each type of device path node. All node types specified in the UEFI 2.10 Specification are now supported. - Added `DevicePathBuilder` for building new device paths. +- Added `BootServices::install_protocol_interface`, + `BootServices::uninstall_protocol_interface`, and + `BootServices::reinstall_protocol_interface`. +- Added `BootServices::register_protocol_notify`. +- Added `SearchType::ByRegisterNotify` and `SearchKey` type. ### Changed diff --git a/src/data_types/mod.rs b/src/data_types/mod.rs index 622a40304..937988c4f 100644 --- a/src/data_types/mod.rs +++ b/src/data_types/mod.rs @@ -117,6 +117,12 @@ pub type PhysicalAddress = u64; /// of target platform. pub type VirtualAddress = u64; +/// Opaque pointer returned by `BootServices::register_protocol_notify() to be used +/// with `BootServices::locate_handle` as the `key` parameter. +#[derive(Debug, Clone, Copy)] +#[repr(transparent)] +pub struct SearchKey(NonNull); + mod guid; pub use self::guid::Guid; pub use self::guid::{unsafe_guid, Identify}; diff --git a/src/table/boot.rs b/src/table/boot.rs index ab69ed0a1..3990a7bc2 100644 --- a/src/table/boot.rs +++ b/src/table/boot.rs @@ -1,7 +1,7 @@ //! UEFI services available during boot. use super::{Header, Revision}; -use crate::data_types::{Align, PhysicalAddress, VirtualAddress}; +use crate::data_types::{Align, PhysicalAddress, SearchKey, VirtualAddress}; use crate::proto::device_path::{DevicePath, FfiDevicePath}; #[cfg(feature = "exts")] use crate::proto::{loaded_image::LoadedImage, media::fs::SimpleFileSystem}; @@ -128,17 +128,32 @@ pub struct BootServices { check_event: unsafe extern "efiapi" fn(event: Event) -> Status, // Protocol handlers - install_protocol_interface: usize, - reinstall_protocol_interface: usize, - uninstall_protocol_interface: usize, + install_protocol_interface: unsafe extern "efiapi" fn( + handle: Option<&Handle>, + guid: &Guid, + interface_type: InterfaceType, + interface: Option>, + ) -> Status, + reinstall_protocol_interface: unsafe extern "efiapi" fn( + handle: Handle, + protocol: &Guid, + old_interface: Option>, + new_interface: Option>, + ) -> Status, + uninstall_protocol_interface: unsafe extern "efiapi" fn( + handle: Handle, + protocol: &Guid, + interface: Option>, + ) -> Status, handle_protocol: extern "efiapi" fn(handle: Handle, proto: &Guid, out_proto: &mut *mut c_void) -> Status, _reserved: usize, - register_protocol_notify: usize, + register_protocol_notify: + extern "efiapi" fn(protocol: &Guid, event: Event, registration: *mut SearchKey) -> Status, locate_handle: unsafe extern "efiapi" fn( search_ty: i32, - proto: *const Guid, - key: *mut c_void, + proto: Option<&Guid>, + key: Option, buf_sz: &mut usize, buf: *mut MaybeUninit, ) -> Status, @@ -221,8 +236,8 @@ pub struct BootServices { ) -> Status, locate_handle_buffer: unsafe extern "efiapi" fn( search_ty: i32, - proto: *const Guid, - key: *const c_void, + proto: Option<&Guid>, + key: Option, no_handles: &mut usize, buf: &mut *mut Handle, ) -> Status, @@ -618,6 +633,72 @@ impl BootServices { } } + /// Installs a protocol interface on a device handle. If `handle` is `None`, one will be + /// created and added to the list of handles in the system and then returned. + /// + /// When a protocol interface is installed, firmware will call all functions that have registered + /// to wait for that interface to be installed. + /// + /// # Safety + /// + /// The caller is responsible for ensuring that they pass a valid `Guid` for `protocol`. + pub unsafe fn install_protocol_interface( + &self, + handle: Option<&Handle>, + protocol: &Guid, + interface: Option>, + ) -> Result { + ((self.install_protocol_interface)( + handle, + protocol, + InterfaceType::NATIVE_INTERFACE, + interface, + )) + // this `unwrapped_unchecked` is safe, `handle` is guaranteed to be Some() if this call is + // successful + .into_with_val(|| *handle.unwrap_unchecked()) + } + + /// Reinstalls a protocol interface on a device handle. `old_interface` is replaced with `new_interface`. + /// These interfaces may be the same, in which case the registered protocol notifies occur for the handle + /// without replacing the interface. + /// + /// As with `install_protocol_interface`, any process that has registered to wait for the installation of + /// the interface is notified. + /// + /// # Safety + /// + /// The caller is responsible for ensuring that there are no references to the `old_interface` that is being + /// removed. + pub unsafe fn reinstall_protocol_interface( + &self, + handle: Handle, + protocol: &Guid, + old_interface: Option>, + new_interface: Option>, + ) -> Result<()> { + (self.reinstall_protocol_interface)(handle, protocol, old_interface, new_interface).into() + } + + /// Removes a protocol interface from a device handle. + /// + /// # Safety + /// + /// The caller is responsible for ensuring that there are no references to a protocol interface + /// that has been removed. Some protocols may not be able to be removed as there is no information + /// available regarding the references. This includes Console I/O, Block I/O, Disk I/o, and handles + /// to device protocols. + /// + /// The caller is responsible for ensuring that they pass a valid `Guid` for `protocol`. + pub unsafe fn uninstall_protocol_interface( + &self, + handle: Handle, + protocol: &Guid, + interface: Option>, + ) -> Result<()> { + (self.uninstall_protocol_interface)(handle, protocol, interface).into() + } + /// Query a handle for a certain protocol. /// /// This function attempts to get the protocol implementation of a handle, @@ -655,6 +736,26 @@ impl BootServices { }) } + /// Registers `event` to be signalled whenever a protocol interface is registered for + /// `protocol` by `install_protocol_interface()` or `reinstall_protocol_interface()`. + /// + /// Once `event` has been signalled, `BootServices::locate_handle()` can be used to identify + /// the newly (re)installed handles that support `protocol`. The returned `SearchKey` on success + /// corresponds to the `search_key` parameter in `locate_handle()`. + /// + /// Events can be unregistered from protocol interface notification by calling `close_event()`. + pub fn register_protocol_notify( + &self, + protocol: &Guid, + event: Event, + ) -> Result<(Event, SearchKey)> { + let mut key: MaybeUninit = MaybeUninit::uninit(); + // Safety: we clone `event` a couple times, but there will be only one left once we return. + unsafe { (self.register_protocol_notify)(protocol, event.unsafe_clone(), key.as_mut_ptr()) } + // Safety: as long as this call is successful, `key` will be valid. + .into_with_val(|| unsafe { (event.unsafe_clone(), key.assume_init()) }) + } + /// Enumerates all handles installed on the system which match a certain query. /// /// You should first call this function with `None` for the output buffer, @@ -677,8 +778,9 @@ impl BootServices { // Obtain the needed data from the parameters. let (ty, guid, key) = match search_ty { - SearchType::AllHandles => (0, ptr::null(), ptr::null_mut()), - SearchType::ByProtocol(guid) => (2, guid as *const _, ptr::null_mut()), + SearchType::AllHandles => (0, None, None), + SearchType::ByRegisterNotify(registration) => (1, None, Some(registration)), + SearchType::ByProtocol(guid) => (2, Some(guid), None), }; let status = unsafe { (self.locate_handle)(ty, guid, key, &mut buffer_size, buffer) }; @@ -1095,8 +1197,9 @@ impl BootServices { // Obtain the needed data from the parameters. let (ty, guid, key) = match search_ty { - SearchType::AllHandles => (0, ptr::null(), ptr::null_mut()), - SearchType::ByProtocol(guid) => (2, guid as *const _, ptr::null_mut()), + SearchType::AllHandles => (0, None, None), + SearchType::ByRegisterNotify(registration) => (1, None, Some(registration)), + SearchType::ByProtocol(guid) => (2, Some(guid), None), }; unsafe { (self.locate_handle_buffer)(ty, guid, key, &mut num_handles, &mut buffer) } @@ -1731,7 +1834,9 @@ pub enum SearchType<'guid> { /// If the protocol implements the `Protocol` interface, /// you can use the `from_proto` function to construct a new `SearchType`. ByProtocol(&'guid Guid), - // TODO: add ByRegisterNotify once the corresponding function is implemented. + /// Return all handles that implement a protocol when an interface for that protocol + /// is (re)installed. + ByRegisterNotify(SearchKey), } impl<'guid> SearchType<'guid> { @@ -1741,6 +1846,13 @@ impl<'guid> SearchType<'guid> { } } +impl SearchType<'_> { + /// Constructs a new search type from a SearchKey. + pub fn from_search_key(key: SearchKey) -> Self { + SearchType::ByRegisterNotify(key) + } +} + bitflags! { /// Flags describing the type of an UEFI event and its attributes. pub struct EventType: u32 { @@ -1844,3 +1956,13 @@ impl<'a> HandleBuffer<'a> { unsafe { slice::from_raw_parts(self.buffer, self.count) } } } + +newtype_enum! { +/// Interface type of a protocol interface +/// +/// Only has one variant when this was written (v2.10 of the UEFI spec) +pub enum InterfaceType: i32 => { + /// Native interface + NATIVE_INTERFACE = 0, +} +} From 89688e612cd1333136d0f71a35893bf09dc2c459 Mon Sep 17 00:00:00 2001 From: Timothy Roberts <39689890+timrobertsdev@users.noreply.github.com> Date: Mon, 7 Nov 2022 11:31:07 -0500 Subject: [PATCH 2/4] Correct implementation of `install_protocol_interface` --- src/table/boot.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/table/boot.rs b/src/table/boot.rs index 3990a7bc2..960e53548 100644 --- a/src/table/boot.rs +++ b/src/table/boot.rs @@ -129,7 +129,7 @@ pub struct BootServices { // Protocol handlers install_protocol_interface: unsafe extern "efiapi" fn( - handle: Option<&Handle>, + handle: NonNull>, guid: &Guid, interface_type: InterfaceType, interface: Option>, @@ -633,8 +633,8 @@ impl BootServices { } } - /// Installs a protocol interface on a device handle. If `handle` is `None`, one will be - /// created and added to the list of handles in the system and then returned. + /// Installs a protocol interface on a device handle. If the inner `Option` in `handle` is `None`, + /// one will be created and added to the list of handles in the system and then returned." /// /// When a protocol interface is installed, firmware will call all functions that have registered /// to wait for that interface to be installed. @@ -644,19 +644,23 @@ impl BootServices { /// The caller is responsible for ensuring that they pass a valid `Guid` for `protocol`. pub unsafe fn install_protocol_interface( &self, - handle: Option<&Handle>, + mut handle: Option, protocol: &Guid, interface: Option>, ) -> Result { + // Safety: The given pointer is guaranteed to be non-null, even though what it's indirectly pointing to + // may be null, thus this is safe + let handle_ptr = NonNull::new(&mut handle as *mut _).unwrap_unchecked(); + ((self.install_protocol_interface)( - handle, + handle_ptr, protocol, InterfaceType::NATIVE_INTERFACE, interface, )) // this `unwrapped_unchecked` is safe, `handle` is guaranteed to be Some() if this call is // successful - .into_with_val(|| *handle.unwrap_unchecked()) + .into_with_val(|| handle.unwrap_unchecked()) } /// Reinstalls a protocol interface on a device handle. `old_interface` is replaced with `new_interface`. From 94b5ee1b3706937fba9e7cd2a6e1bc17973d8327 Mon Sep 17 00:00:00 2001 From: Timothy Roberts <39689890+timrobertsdev@users.noreply.github.com> Date: Mon, 7 Nov 2022 11:31:21 -0500 Subject: [PATCH 3/4] Add tests for the protocol handler services. --- uefi-test-runner/src/boot/misc.rs | 73 ++++++++++++++++++++++++++++++- uefi-test-runner/src/main.rs | 1 + 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/uefi-test-runner/src/boot/misc.rs b/uefi-test-runner/src/boot/misc.rs index 8e7fd5f5b..e9f4cfc66 100644 --- a/uefi-test-runner/src/boot/misc.rs +++ b/uefi-test-runner/src/boot/misc.rs @@ -1,8 +1,9 @@ use core::ffi::c_void; use core::ptr::NonNull; -use uefi::table::boot::{BootServices, EventType, TimerTrigger, Tpl}; -use uefi::Event; +use uefi::proto::Protocol; +use uefi::table::boot::{BootServices, EventType, SearchType, TimerTrigger, Tpl}; +use uefi::{unsafe_guid, Event, Identify}; pub fn test(bt: &BootServices) { info!("Testing timer..."); @@ -12,6 +13,11 @@ pub fn test(bt: &BootServices) { test_callback_with_ctx(bt); info!("Testing watchdog..."); test_watchdog(bt); + info!("Testing protocol handler services..."); + test_register_protocol_notify(bt); + test_install_protocol_interface(bt); + test_reinstall_protocol_interface(bt); + test_uninstall_protocol_interface(bt); } fn test_timer(bt: &BootServices) { @@ -72,3 +78,66 @@ fn test_watchdog(bt: &BootServices) { bt.set_watchdog_timer(0, 0x10000, None) .expect("Could not set watchdog timer"); } + +/// Dummy protocol for tests +#[unsafe_guid("1a972918-3f69-4b5d-8cb4-cece2309c7f5")] +#[derive(Protocol)] +struct TestProtocol {} + +unsafe extern "efiapi" fn _test_notify(_event: Event, _context: Option>) { + info!("Protocol was (re)installed and this function notified.") +} + +fn test_register_protocol_notify(bt: &BootServices) { + let protocol = &TestProtocol::GUID; + let event = unsafe { + bt.create_event( + EventType::NOTIFY_SIGNAL, + Tpl::NOTIFY, + Some(_test_notify), + None, + ) + .expect("Failed to create an event") + }; + + bt.register_protocol_notify(protocol, event) + .expect("Failed to register protocol notify fn"); +} + +fn test_install_protocol_interface(bt: &BootServices) { + info!("Installing TestProtocol"); + + let _ = unsafe { + bt.install_protocol_interface(None, &TestProtocol::GUID, None) + .expect("Failed to install protocol interface") + }; + + let _ = bt + .locate_handle_buffer(SearchType::from_proto::()) + .expect("Failed to find protocol after it was installed"); +} + +fn test_reinstall_protocol_interface(bt: &BootServices) { + info!("Reinstalling TestProtocol"); + let handle = bt + .locate_handle_buffer(SearchType::from_proto::()) + .expect("Failed to find protocol to uninstall") + .handles()[0]; + + unsafe { + let _ = bt.reinstall_protocol_interface(handle, &TestProtocol::GUID, None, None); + } +} + +fn test_uninstall_protocol_interface(bt: &BootServices) { + info!("Uninstalling TestProtocol"); + let handle = bt + .locate_handle_buffer(SearchType::from_proto::()) + .expect("Failed to find protocol to uninstall") + .handles()[0]; + + unsafe { + bt.uninstall_protocol_interface(handle, &TestProtocol::GUID, None) + .expect("Failed to uninstall protocol interface"); + } +} diff --git a/uefi-test-runner/src/main.rs b/uefi-test-runner/src/main.rs index cb807dbd2..a6dd6c69a 100644 --- a/uefi-test-runner/src/main.rs +++ b/uefi-test-runner/src/main.rs @@ -1,6 +1,7 @@ #![no_std] #![no_main] #![feature(abi_efiapi)] +#![feature(negative_impls)] #[macro_use] extern crate log; From 4d6aabeebe169e307e22e6ade8f94e12584ee624 Mon Sep 17 00:00:00 2001 From: Timothy Roberts <39689890+timrobertsdev@users.noreply.github.com> Date: Thu, 10 Nov 2022 16:56:52 -0500 Subject: [PATCH 4/4] Apply suggestions from @nicholasbishop Adjust changelog Rename `SearchKey` to `ProtocolSearchKey` and move to `boot.rs`. Fixup doclinks. Adjust signatures of the `[re/un]install_protocol_interface` functions --- CHANGELOG.md | 2 +- src/data_types/mod.rs | 6 --- src/table/boot.rs | 65 ++++++++++++++++--------------- uefi-test-runner/src/boot/misc.rs | 13 +++++-- 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1c97788..5bacc4cdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ `BootServices::uninstall_protocol_interface`, and `BootServices::reinstall_protocol_interface`. - Added `BootServices::register_protocol_notify`. -- Added `SearchType::ByRegisterNotify` and `SearchKey` type. +- Added `SearchType::ByRegisterNotify`and `ProtocolSearchKey`. ### Changed diff --git a/src/data_types/mod.rs b/src/data_types/mod.rs index 937988c4f..622a40304 100644 --- a/src/data_types/mod.rs +++ b/src/data_types/mod.rs @@ -117,12 +117,6 @@ pub type PhysicalAddress = u64; /// of target platform. pub type VirtualAddress = u64; -/// Opaque pointer returned by `BootServices::register_protocol_notify() to be used -/// with `BootServices::locate_handle` as the `key` parameter. -#[derive(Debug, Clone, Copy)] -#[repr(transparent)] -pub struct SearchKey(NonNull); - mod guid; pub use self::guid::Guid; pub use self::guid::{unsafe_guid, Identify}; diff --git a/src/table/boot.rs b/src/table/boot.rs index 960e53548..8c0230247 100644 --- a/src/table/boot.rs +++ b/src/table/boot.rs @@ -1,7 +1,7 @@ //! UEFI services available during boot. use super::{Header, Revision}; -use crate::data_types::{Align, PhysicalAddress, SearchKey, VirtualAddress}; +use crate::data_types::{Align, PhysicalAddress, VirtualAddress}; use crate::proto::device_path::{DevicePath, FfiDevicePath}; #[cfg(feature = "exts")] use crate::proto::{loaded_image::LoadedImage, media::fs::SimpleFileSystem}; @@ -129,31 +129,34 @@ pub struct BootServices { // Protocol handlers install_protocol_interface: unsafe extern "efiapi" fn( - handle: NonNull>, + handle: &mut Option, guid: &Guid, interface_type: InterfaceType, - interface: Option>, + interface: *mut c_void, ) -> Status, reinstall_protocol_interface: unsafe extern "efiapi" fn( handle: Handle, protocol: &Guid, - old_interface: Option>, - new_interface: Option>, + old_interface: *mut c_void, + new_interface: *mut c_void, ) -> Status, uninstall_protocol_interface: unsafe extern "efiapi" fn( handle: Handle, protocol: &Guid, - interface: Option>, + interface: *mut c_void, ) -> Status, handle_protocol: extern "efiapi" fn(handle: Handle, proto: &Guid, out_proto: &mut *mut c_void) -> Status, _reserved: usize, - register_protocol_notify: - extern "efiapi" fn(protocol: &Guid, event: Event, registration: *mut SearchKey) -> Status, + register_protocol_notify: extern "efiapi" fn( + protocol: &Guid, + event: Event, + registration: *mut ProtocolSearchKey, + ) -> Status, locate_handle: unsafe extern "efiapi" fn( search_ty: i32, proto: Option<&Guid>, - key: Option, + key: Option, buf_sz: &mut usize, buf: *mut MaybeUninit, ) -> Status, @@ -237,7 +240,7 @@ pub struct BootServices { locate_handle_buffer: unsafe extern "efiapi" fn( search_ty: i32, proto: Option<&Guid>, - key: Option, + key: Option, no_handles: &mut usize, buf: &mut *mut Handle, ) -> Status, @@ -634,7 +637,7 @@ impl BootServices { } /// Installs a protocol interface on a device handle. If the inner `Option` in `handle` is `None`, - /// one will be created and added to the list of handles in the system and then returned." + /// one will be created and added to the list of handles in the system and then returned. /// /// When a protocol interface is installed, firmware will call all functions that have registered /// to wait for that interface to be installed. @@ -646,14 +649,10 @@ impl BootServices { &self, mut handle: Option, protocol: &Guid, - interface: Option>, + interface: *mut c_void, ) -> Result { - // Safety: The given pointer is guaranteed to be non-null, even though what it's indirectly pointing to - // may be null, thus this is safe - let handle_ptr = NonNull::new(&mut handle as *mut _).unwrap_unchecked(); - ((self.install_protocol_interface)( - handle_ptr, + &mut handle, protocol, InterfaceType::NATIVE_INTERFACE, interface, @@ -678,8 +677,8 @@ impl BootServices { &self, handle: Handle, protocol: &Guid, - old_interface: Option>, - new_interface: Option>, + old_interface: *mut c_void, + new_interface: *mut c_void, ) -> Result<()> { (self.reinstall_protocol_interface)(handle, protocol, old_interface, new_interface).into() } @@ -698,7 +697,7 @@ impl BootServices { &self, handle: Handle, protocol: &Guid, - interface: Option>, + interface: *mut c_void, ) -> Result<()> { (self.uninstall_protocol_interface)(handle, protocol, interface).into() } @@ -752,12 +751,17 @@ impl BootServices { &self, protocol: &Guid, event: Event, - ) -> Result<(Event, SearchKey)> { - let mut key: MaybeUninit = MaybeUninit::uninit(); + ) -> Result<(Event, SearchType)> { + let mut key: MaybeUninit = MaybeUninit::uninit(); // Safety: we clone `event` a couple times, but there will be only one left once we return. unsafe { (self.register_protocol_notify)(protocol, event.unsafe_clone(), key.as_mut_ptr()) } // Safety: as long as this call is successful, `key` will be valid. - .into_with_val(|| unsafe { (event.unsafe_clone(), key.assume_init()) }) + .into_with_val(|| unsafe { + ( + event.unsafe_clone(), + SearchType::ByRegisterNotify(key.assume_init()), + ) + }) } /// Enumerates all handles installed on the system which match a certain query. @@ -1840,7 +1844,7 @@ pub enum SearchType<'guid> { ByProtocol(&'guid Guid), /// Return all handles that implement a protocol when an interface for that protocol /// is (re)installed. - ByRegisterNotify(SearchKey), + ByRegisterNotify(ProtocolSearchKey), } impl<'guid> SearchType<'guid> { @@ -1850,13 +1854,6 @@ impl<'guid> SearchType<'guid> { } } -impl SearchType<'_> { - /// Constructs a new search type from a SearchKey. - pub fn from_search_key(key: SearchKey) -> Self { - SearchType::ByRegisterNotify(key) - } -} - bitflags! { /// Flags describing the type of an UEFI event and its attributes. pub struct EventType: u32 { @@ -1970,3 +1967,9 @@ pub enum InterfaceType: i32 => { NATIVE_INTERFACE = 0, } } + +/// Opaque pointer returned by [`BootServices::register_protocol_notify`] to be used +/// with [`BootServices::locate_handle`] via [`SearchType::ByRegisterNotify`]. +#[derive(Debug, Clone, Copy)] +#[repr(transparent)] +pub struct ProtocolSearchKey(NonNull); diff --git a/uefi-test-runner/src/boot/misc.rs b/uefi-test-runner/src/boot/misc.rs index e9f4cfc66..8f45aeaf0 100644 --- a/uefi-test-runner/src/boot/misc.rs +++ b/uefi-test-runner/src/boot/misc.rs @@ -1,5 +1,5 @@ use core::ffi::c_void; -use core::ptr::NonNull; +use core::ptr::{self, NonNull}; use uefi::proto::Protocol; use uefi::table::boot::{BootServices, EventType, SearchType, TimerTrigger, Tpl}; @@ -108,7 +108,7 @@ fn test_install_protocol_interface(bt: &BootServices) { info!("Installing TestProtocol"); let _ = unsafe { - bt.install_protocol_interface(None, &TestProtocol::GUID, None) + bt.install_protocol_interface(None, &TestProtocol::GUID, ptr::null_mut()) .expect("Failed to install protocol interface") }; @@ -125,7 +125,12 @@ fn test_reinstall_protocol_interface(bt: &BootServices) { .handles()[0]; unsafe { - let _ = bt.reinstall_protocol_interface(handle, &TestProtocol::GUID, None, None); + let _ = bt.reinstall_protocol_interface( + handle, + &TestProtocol::GUID, + ptr::null_mut(), + ptr::null_mut(), + ); } } @@ -137,7 +142,7 @@ fn test_uninstall_protocol_interface(bt: &BootServices) { .handles()[0]; unsafe { - bt.uninstall_protocol_interface(handle, &TestProtocol::GUID, None) + bt.uninstall_protocol_interface(handle, &TestProtocol::GUID, ptr::null_mut()) .expect("Failed to uninstall protocol interface"); } }