diff --git a/uefi-test-runner/src/proto/driver.rs b/uefi-test-runner/src/proto/driver.rs index 267d1f1df..8ee3858fb 100644 --- a/uefi-test-runner/src/proto/driver.rs +++ b/uefi-test-runner/src/proto/driver.rs @@ -1,6 +1,6 @@ +use uefi::boot::{self, ScopedProtocol, SearchType}; use uefi::prelude::*; use uefi::proto::driver::{ComponentName, ComponentName2, LanguageError, LanguageIter}; -use uefi::table::boot::{ScopedProtocol, SearchType}; use uefi::{CStr16, Result}; #[allow(deprecated)] @@ -8,8 +8,8 @@ use uefi::proto::driver::ComponentName1; /// Generic interface for testing `ComponentName1`, `ComponentName2`, and /// `ComponentName`. -trait ComponentNameInterface<'a>: Sized { - fn open(boot_services: &'a BootServices, handle: Handle) -> Result; +trait ComponentNameInterface: Sized { + fn open(handle: Handle) -> Result; fn supported_languages(&self) -> core::result::Result; fn driver_name(&self, language: &str) -> Result<&CStr16>; fn controller_name( @@ -21,9 +21,9 @@ trait ComponentNameInterface<'a>: Sized { } #[allow(deprecated)] -impl<'a> ComponentNameInterface<'a> for ScopedProtocol<'a, ComponentName1> { - fn open(boot_services: &'a BootServices, handle: Handle) -> Result { - boot_services.open_protocol_exclusive::(handle) +impl ComponentNameInterface for ScopedProtocol { + fn open(handle: Handle) -> Result { + boot::open_protocol_exclusive::(handle) } fn supported_languages(&self) -> core::result::Result { @@ -44,9 +44,9 @@ impl<'a> ComponentNameInterface<'a> for ScopedProtocol<'a, ComponentName1> { } } -impl<'a> ComponentNameInterface<'a> for ScopedProtocol<'a, ComponentName2> { - fn open(boot_services: &'a BootServices, handle: Handle) -> Result { - boot_services.open_protocol_exclusive::(handle) +impl ComponentNameInterface for ScopedProtocol { + fn open(handle: Handle) -> Result { + boot::open_protocol_exclusive::(handle) } fn supported_languages(&self) -> core::result::Result { @@ -67,9 +67,9 @@ impl<'a> ComponentNameInterface<'a> for ScopedProtocol<'a, ComponentName2> { } } -impl<'a> ComponentNameInterface<'a> for ComponentName<'a> { - fn open(boot_services: &'a BootServices, handle: Handle) -> Result { - Self::open(boot_services, handle) +impl ComponentNameInterface for ComponentName { + fn open(handle: Handle) -> Result { + Self::open(handle) } fn supported_languages(&self) -> core::result::Result { @@ -90,13 +90,8 @@ impl<'a> ComponentNameInterface<'a> for ComponentName<'a> { } } -fn test_component_name<'a, C: ComponentNameInterface<'a>>( - boot_services: &'a BootServices, - english: &str, -) { - let all_handles = boot_services - .locate_handle_buffer(SearchType::AllHandles) - .unwrap(); +fn test_component_name(english: &str) { + let all_handles = boot::locate_handle_buffer(SearchType::AllHandles).unwrap(); let fat_driver_name = cstr16!("FAT File System Driver"); let fat_controller_name = cstr16!("FAT File System"); @@ -105,7 +100,7 @@ fn test_component_name<'a, C: ComponentNameInterface<'a>>( let component_name: C = all_handles .iter() .find_map(|handle| { - let component_name = C::open(boot_services, *handle).ok()?; + let component_name = C::open(*handle).ok()?; assert!(component_name .supported_languages() @@ -138,11 +133,11 @@ fn test_component_name<'a, C: ComponentNameInterface<'a>>( .expect("failed to find FAT controller"); } -pub fn test(boot_services: &BootServices) { +pub fn test() { info!("Running component name test"); #[allow(deprecated)] - test_component_name::>(boot_services, "eng"); - test_component_name::>(boot_services, "en"); - test_component_name::(boot_services, "en"); + test_component_name::>("eng"); + test_component_name::>("en"); + test_component_name::("en"); } diff --git a/uefi-test-runner/src/proto/mod.rs b/uefi-test-runner/src/proto/mod.rs index 09a9fd5ef..a1335b3af 100644 --- a/uefi-test-runner/src/proto/mod.rs +++ b/uefi-test-runner/src/proto/mod.rs @@ -16,7 +16,7 @@ pub fn test(st: &mut SystemTable) { debug::test(bt); device_path::test(bt); - driver::test(bt); + driver::test(); load::test(bt); loaded_image::test(bt); media::test(bt); diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 22837ec96..2c794c4c5 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -12,6 +12,8 @@ how to integrate the `uefi` crate into them. take a `BootServices` argument. The global system table is used instead. - **Breaking:** `GraphicsOutput::modes` no longer takes a `BootServices` argument. The global system table is used instead. +- **Breaking:** `ComponentName::open` no longer takes a `BootServices` + argument. The global system table is used instead. - `allocator::init` and `allocator::exit_boot_services` have been deprecated. These functions are now no-ops. The allocator now internally uses the global system table. diff --git a/uefi/src/proto/driver/component_name.rs b/uefi/src/proto/driver/component_name.rs index f3b647ebb..395e6730f 100644 --- a/uefi/src/proto/driver/component_name.rs +++ b/uefi/src/proto/driver/component_name.rs @@ -4,8 +4,8 @@ // allow more fine-grained, see https://github.com/rust-lang/rust/issues/62398. #![allow(deprecated)] +use crate::boot::{self, ScopedProtocol}; use crate::proto::unsafe_protocol; -use crate::table::boot::{BootServices, ScopedProtocol}; use crate::{CStr16, Error, Handle, Result, Status, StatusExt}; use core::fmt::{self, Debug, Display, Formatter}; use core::{ptr, slice}; @@ -153,24 +153,24 @@ impl ComponentName2 { /// Wrapper around [`ComponentName1`] and [`ComponentName2`]. This will use /// [`ComponentName2`] if available, otherwise it will back to /// [`ComponentName1`]. -pub enum ComponentName<'a> { +pub enum ComponentName { /// Opened [`ComponentName1`] protocol. - V1(ScopedProtocol<'a, ComponentName1>), + V1(ScopedProtocol), /// Opened [`ComponentName2`] protocol. - V2(ScopedProtocol<'a, ComponentName2>), + V2(ScopedProtocol), } -impl<'a> ComponentName<'a> { +impl ComponentName { /// Open the [`ComponentName2`] protocol if available, otherwise fall back to /// [`ComponentName1`]. - pub fn open(boot_services: &'a BootServices, handle: Handle) -> Result { - if let Ok(cn2) = boot_services.open_protocol_exclusive::(handle) { + pub fn open(handle: Handle) -> Result { + if let Ok(cn2) = boot::open_protocol_exclusive::(handle) { Ok(Self::V2(cn2)) } else { - Ok(Self::V1( - boot_services.open_protocol_exclusive::(handle)?, - )) + Ok(Self::V1(boot::open_protocol_exclusive::( + handle, + )?)) } } @@ -219,11 +219,11 @@ impl<'a> ComponentName<'a> { } } -impl<'a> Debug for ComponentName<'a> { +impl Debug for ComponentName { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { match self { - ComponentName::V1(_) => f.debug_tuple("V1").finish(), - ComponentName::V2(_) => f.debug_tuple("V2").finish(), + Self::V1(_) => f.debug_tuple("V1").finish(), + Self::V2(_) => f.debug_tuple("V2").finish(), } } }