From f52d60da5fb707407f014c8e058af4145500d3e5 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 00:48:01 -0400 Subject: [PATCH 1/8] test-runner: Remove tests for RuntimeServices --- uefi-test-runner/src/main.rs | 4 +- uefi-test-runner/src/runtime/mod.rs | 5 +- uefi-test-runner/src/runtime/vars.rs | 72 +++------------------------- 3 files changed, 11 insertions(+), 70 deletions(-) diff --git a/uefi-test-runner/src/main.rs b/uefi-test-runner/src/main.rs index d6af3b28a..6cb046a9e 100644 --- a/uefi-test-runner/src/main.rs +++ b/uefi-test-runner/src/main.rs @@ -1,7 +1,7 @@ #![no_std] #![no_main] // TODO: temporarily allow deprecated code so that we can continue to test -// SystemTable/BootServices/RuntimeServices. +// SystemTable/BootServices. #![allow(deprecated)] #[macro_use] @@ -63,7 +63,7 @@ fn efi_main(image: Handle, mut st: SystemTable) -> Status { // probably want to test them after exit_boot_services. However, // exit_boot_services is currently called during shutdown. - runtime::test(st.runtime_services()); + runtime::test(); shutdown(st); } diff --git a/uefi-test-runner/src/runtime/mod.rs b/uefi-test-runner/src/runtime/mod.rs index 92769bfe4..7b233ab3c 100644 --- a/uefi-test-runner/src/runtime/mod.rs +++ b/uefi-test-runner/src/runtime/mod.rs @@ -1,11 +1,10 @@ mod vars; use uefi::runtime::{self, Daylight, Time, TimeParams}; -use uefi::table::runtime::RuntimeServices; -pub fn test(rt: &RuntimeServices) { +pub fn test() { info!("Testing runtime services"); - vars::test(rt); + vars::test(); test_time(); } diff --git a/uefi-test-runner/src/runtime/vars.rs b/uefi-test-runner/src/runtime/vars.rs index 208a628fe..0e750976b 100644 --- a/uefi-test-runner/src/runtime/vars.rs +++ b/uefi-test-runner/src/runtime/vars.rs @@ -16,63 +16,8 @@ const VALUE: &[u8] = b"TestValue"; const ATTRS: VariableAttributes = VariableAttributes::BOOTSERVICE_ACCESS.union(VariableAttributes::RUNTIME_ACCESS); -fn test_variables(rt: &RuntimeServices) { - info!("Testing set_variable"); - rt.set_variable(NAME, VENDOR, ATTRS, VALUE) - .expect("failed to set variable"); - - info!("Testing get_variable_size"); - let size = rt - .get_variable_size(NAME, VENDOR) - .expect("failed to get variable size"); - assert_eq!(size, VALUE.len()); - - info!("Testing get_variable"); - let mut buf = [0u8; 9]; - let (data, attrs) = rt - .get_variable(NAME, VENDOR, &mut buf) - .expect("failed to get variable"); - assert_eq!(data, VALUE); - assert_eq!(attrs, ATTRS); - - info!("Testing get_variable_boxed"); - let (data, attrs) = rt - .get_variable_boxed(NAME, VENDOR) - .expect("failed to get variable"); - assert_eq!(&*data, VALUE); - assert_eq!(attrs, ATTRS); - - info!("Testing variable_keys"); - let variable_keys = rt.variable_keys().expect("failed to get variable keys"); - info!("Found {} variables", variable_keys.len()); - // There are likely a bunch of variables, only print out the first one - // during the test to avoid spamming the log. - if let Some(key) = variable_keys.first() { - info!("First variable: {}", key); - } - - // Test that the `runtime::variable_keys` iterator gives exactly the same - // list as the `RuntimeServices::variable_keys` function. - assert_eq!( - runtime::variable_keys() - .map(|k| k.unwrap()) - .collect::>(), - variable_keys - ); - - info!("Testing delete_variable()"); - rt.delete_variable(NAME, VENDOR) - .expect("failed to delete variable"); - assert_eq!( - rt.get_variable(NAME, VENDOR, &mut buf) - .unwrap_err() - .status(), - Status::NOT_FOUND - ); -} - /// Test the variable functions in `uefi::runtime`. -fn test_variables_freestanding() { +fn test_variables() { assert!(!runtime::variable_exists(NAME, VENDOR).unwrap()); // Create the test variable. @@ -121,20 +66,17 @@ fn test_variables_freestanding() { assert!(!find_by_key()); } -fn test_variable_info(rt: &RuntimeServices) { +fn test_variable_info() { let attr = VariableAttributes::BOOTSERVICE_ACCESS | VariableAttributes::NON_VOLATILE; - let info = rt.query_variable_info(attr).unwrap(); + let info = runtime::query_variable_info(attr).unwrap(); info!("Storage for non-volatile boot-services variables: {info:?}"); - assert_eq!(info, runtime::query_variable_info(attr).unwrap()); let attr = VariableAttributes::BOOTSERVICE_ACCESS | VariableAttributes::RUNTIME_ACCESS; - let info = rt.query_variable_info(attr).unwrap(); + let info = runtime::query_variable_info(attr).unwrap(); info!("Storage for volatile runtime variables: {info:?}"); - assert_eq!(info, runtime::query_variable_info(attr).unwrap()); } -pub fn test(rt: &RuntimeServices) { - test_variables(rt); - test_variable_info(rt); - test_variables_freestanding(); +pub fn test() { + test_variable_info(); + test_variables(); } From 23948cf6152cdbf6135eee3c5046beacbbaf4e45 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 00:58:06 -0400 Subject: [PATCH 2/8] uefi: Delete the deprecated table::system_table_runtime function --- uefi/CHANGELOG.md | 3 ++- uefi/src/table/mod.rs | 19 ------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index d6dafc190..01fc2eb05 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,7 +1,8 @@ # uefi - [Unreleased] ## Changed -- **Breaking:** Deleted deprecated function `helpers::system_table`. +- **Breaking:** Deleted deprecated functions `helpers::system_table` and + `table::system_table_runtime`. - **Breaking:** `FileSystem` no longer has a lifetime parameter, and the deprecated conversion from `uefi::table::boot::ScopedProtocol` has been removed. diff --git a/uefi/src/table/mod.rs b/uefi/src/table/mod.rs index 6cb848a62..114fcf117 100644 --- a/uefi/src/table/mod.rs +++ b/uefi/src/table/mod.rs @@ -79,25 +79,6 @@ pub fn system_table_boot() -> Option> { } } -/// Get the system table while runtime services are active. -#[deprecated = "Use the uefi::runtime module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"] -#[allow(deprecated)] -pub fn system_table_runtime() -> Option> { - let st = SYSTEM_TABLE.load(Ordering::Acquire); - if st.is_null() { - return None; - } - - // SAFETY: the system table is valid per the requirements of `set_system_table`. - unsafe { - if (*st).runtime_services.is_null() { - None - } else { - Some(SystemTable::::from_ptr(st.cast()).unwrap()) - } - } -} - /// Common trait implemented by all standard UEFI tables. pub trait Table { /// A unique number assigned by the UEFI specification From 36d9b5139905646e0e146a0754dcda6b03a75242 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 00:59:37 -0400 Subject: [PATCH 3/8] uefi: Delete `impl SystemTable` --- uefi/src/table/runtime.rs | 10 ------ uefi/src/table/system.rs | 65 ++------------------------------------- 2 files changed, 2 insertions(+), 73 deletions(-) diff --git a/uefi/src/table/runtime.rs b/uefi/src/table/runtime.rs index 2c9d4d22a..76eb256c8 100644 --- a/uefi/src/table/runtime.rs +++ b/uefi/src/table/runtime.rs @@ -288,16 +288,6 @@ impl RuntimeServices { unsafe { (self.0.reset_system)(rt, status, size, data) } } - pub(crate) unsafe fn set_virtual_address_map( - &self, - map_size: usize, - desc_size: usize, - desc_version: u32, - virtual_map: *mut crate::mem::memory_map::MemoryDescriptor, - ) -> Status { - (self.0.set_virtual_address_map)(map_size, desc_size, desc_version, virtual_map) - } - /// Passes capsules to the firmware. Capsules are most commonly used to update system firmware. pub fn update_capsule( &self, diff --git a/uefi/src/table/system.rs b/uefi/src/table/system.rs index 9fc0b8054..80c3b107d 100644 --- a/uefi/src/table/system.rs +++ b/uefi/src/table/system.rs @@ -4,14 +4,12 @@ use super::boot::BootServices; use super::runtime::{ResetType, RuntimeServices}; use super::{cfg, Revision}; use crate::proto::console::text; -use crate::{CStr16, Result, Status, StatusExt}; +use crate::{CStr16, Result, Status}; use core::ffi::c_void; use core::marker::PhantomData; use core::ptr::NonNull; use core::slice; -use uefi::mem::memory_map::{ - MemoryDescriptor, MemoryMapBackingMemory, MemoryMapMeta, MemoryMapOwned, MemoryType, -}; +use uefi::mem::memory_map::{MemoryMapBackingMemory, MemoryMapMeta, MemoryMapOwned, MemoryType}; /// Marker trait used to provide different views of the UEFI System Table. #[deprecated = "Use the uefi::system, uefi::boot, and uefi::runtime modules instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"] @@ -291,65 +289,6 @@ impl SystemTable { } } -// These parts of the SystemTable struct are only visible after exit from UEFI -// boot services. They provide unsafe access to the UEFI runtime services, which -// which were already available before but in safe form. -impl SystemTable { - /// Access runtime services - /// - /// # Safety - /// - /// This is unsafe because UEFI runtime services require an elaborate - /// CPU configuration which may not be preserved by OS loaders. See the - /// "Calling Conventions" chapter of the UEFI specification for details. - #[must_use] - pub const unsafe fn runtime_services(&self) -> &RuntimeServices { - &*(*self.table).runtime_services.cast_const().cast() - } - - /// Changes the runtime addressing mode of EFI firmware from physical to virtual. - /// It is up to the caller to translate the old SystemTable address to a new virtual - /// address and provide it for this function. - /// See [`get_current_system_table_addr`] - /// - /// # Safety - /// - /// Setting new virtual memory map is unsafe and may cause undefined behaviors. - /// - /// [`get_current_system_table_addr`]: SystemTable::get_current_system_table_addr - pub unsafe fn set_virtual_address_map( - self, - map: &mut [MemoryDescriptor], - new_system_table_virtual_addr: u64, - ) -> Result { - // Unsafe Code Guidelines guarantees that there is no padding in an array or a slice - // between its elements if the element type is `repr(C)`, which is our case. - // - // See https://rust-lang.github.io/unsafe-code-guidelines/layout/arrays-and-slices.html - let map_size = core::mem::size_of_val(map); - let entry_size = core::mem::size_of::(); - let entry_version = MemoryDescriptor::VERSION; - let map_ptr = map.as_mut_ptr(); - self.runtime_services() - .set_virtual_address_map(map_size, entry_size, entry_version, map_ptr) - .to_result_with_val(|| { - let new_table_ref = &mut *(new_system_table_virtual_addr as usize - as *mut uefi_raw::table::system::SystemTable); - Self { - table: new_table_ref, - _marker: PhantomData, - } - }) - } - - /// Return the address of the SystemTable that resides in a UEFI runtime services - /// memory region. - #[must_use] - pub fn get_current_system_table_addr(&self) -> u64 { - self.table as u64 - } -} - impl super::Table for SystemTable { const SIGNATURE: u64 = 0x5453_5953_2049_4249; } From d8d24d2a3010ae4c5df7b98ab6f46e26aae34f93 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 01:02:43 -0400 Subject: [PATCH 4/8] test-runner: Switch exit_boot_services to freestanding version --- uefi-test-runner/src/main.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/uefi-test-runner/src/main.rs b/uefi-test-runner/src/main.rs index 6cb046a9e..594b9cad5 100644 --- a/uefi-test-runner/src/main.rs +++ b/uefi-test-runner/src/main.rs @@ -218,7 +218,7 @@ fn shutdown(mut st: SystemTable) -> ! { info!("Testing complete, exiting boot services..."); // Exit boot services as a proof that it works :) - let (st, mmap) = unsafe { st.exit_boot_services(MemoryType::LOADER_DATA) }; + let mmap = unsafe { uefi::boot::exit_boot_services(MemoryType::LOADER_DATA) }; info!("Memory Map:"); for desc in mmap.entries() { @@ -235,9 +235,6 @@ fn shutdown(mut st: SystemTable) -> ! { #[cfg(target_arch = "x86_64")] { - // Prevent unused variable warning. - let _ = st; - use qemu_exit::QEMUExit; let custom_exit_success = 3; let qemu_exit_handle = qemu_exit::X86::new(0xF4, custom_exit_success); @@ -247,11 +244,6 @@ fn shutdown(mut st: SystemTable) -> ! { #[cfg(not(target_arch = "x86_64"))] { // Shut down the system - let rt = unsafe { st.runtime_services() }; - rt.reset( - uefi::table::runtime::ResetType::SHUTDOWN, - Status::SUCCESS, - None, - ); + uefi::runtime::reset(uefi::runtime::ResetType::SHUTDOWN, Status::SUCCESS, None); } } From 0e545910d44d5e232ede789710a17f9797058f81 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 01:04:19 -0400 Subject: [PATCH 5/8] uefi: Drop exit boot services from SystemTable --- uefi/src/table/boot.rs | 24 -------- uefi/src/table/system.rs | 121 +-------------------------------------- 2 files changed, 2 insertions(+), 143 deletions(-) diff --git a/uefi/src/table/boot.rs b/uefi/src/table/boot.rs index 055ea60d2..9f491b1c6 100644 --- a/uefi/src/table/boot.rs +++ b/uefi/src/table/boot.rs @@ -882,30 +882,6 @@ impl BootServices { ) } - /// Exits the UEFI boot services - /// - /// This unsafe method is meant to be an implementation detail of the safe - /// `SystemTable::exit_boot_services()` method, which is why it is not - /// public. - /// - /// Everything that is explained in the documentation of the high-level - /// `SystemTable` method is also true here, except that this function - /// is one-shot (no automatic retry) and does not prevent you from shooting - /// yourself in the foot by calling invalid boot services after a failure. - /// - /// # Errors - /// - /// See section `EFI_BOOT_SERVICES.ExitBootServices()` in the UEFI Specification for more details. - /// - /// * [`uefi::Status::INVALID_PARAMETER`] - pub(super) unsafe fn exit_boot_services( - &self, - image: Handle, - mmap_key: MemoryMapKey, - ) -> Result { - (self.0.exit_boot_services)(image.as_ptr(), mmap_key.0).to_result() - } - /// Stalls the processor for an amount of time. /// /// The time is in microseconds. diff --git a/uefi/src/table/system.rs b/uefi/src/table/system.rs index 80c3b107d..0125525ee 100644 --- a/uefi/src/table/system.rs +++ b/uefi/src/table/system.rs @@ -1,15 +1,14 @@ #![allow(deprecated)] use super::boot::BootServices; -use super::runtime::{ResetType, RuntimeServices}; +use super::runtime::RuntimeServices; use super::{cfg, Revision}; use crate::proto::console::text; -use crate::{CStr16, Result, Status}; +use crate::CStr16; use core::ffi::c_void; use core::marker::PhantomData; use core::ptr::NonNull; use core::slice; -use uefi::mem::memory_map::{MemoryMapBackingMemory, MemoryMapMeta, MemoryMapOwned, MemoryType}; /// Marker trait used to provide different views of the UEFI System Table. #[deprecated = "Use the uefi::system, uefi::boot, and uefi::runtime modules instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"] @@ -156,122 +155,6 @@ impl SystemTable { unsafe { &*(*self.table).boot_services.cast_const().cast() } } - /// Get the current memory map and exit boot services. - unsafe fn get_memory_map_and_exit_boot_services( - &self, - buf: &mut [u8], - ) -> Result { - let boot_services = self.boot_services(); - - // Get the memory map. - let memory_map = boot_services.get_memory_map(buf)?; - - // Try to exit boot services using the memory map key. Note that after - // the first call to `exit_boot_services`, there are restrictions on - // what boot services functions can be called. In UEFI 2.8 and earlier, - // only `get_memory_map` and `exit_boot_services` are allowed. Starting - // in UEFI 2.9 other memory allocation functions may also be called. - boot_services - .exit_boot_services(boot_services.image_handle(), memory_map.map_key) - .map(move |()| memory_map) - } - - /// Exit the UEFI boot services. - /// - /// After this function completes, UEFI hands over control of the hardware - /// to the executing OS loader, which implies that the UEFI boot services - /// are shut down and cannot be used anymore. Only UEFI configuration tables - /// and run-time services can be used, and the latter requires special care - /// from the OS loader. We model this situation by consuming the - /// `SystemTable` view of the System Table and returning a more - /// restricted `SystemTable` view as an output. - /// - /// The memory map at the time of exiting boot services is also - /// returned. The map is backed by a allocation with given `memory_type`. - /// Since the boot services function to free that memory is no - /// longer available after calling `exit_boot_services`, the allocation is - /// live until the program ends. The lifetime of the memory map is therefore - /// `'static`. - /// - /// Note that once the boot services are exited, associated loggers and - /// allocators can't use the boot services anymore. For the corresponding - /// abstractions provided by this crate (see the [`helpers`] module), - /// invoking this function will automatically disable them. If the - /// `global_allocator` feature is enabled, attempting to use the allocator - /// after exiting boot services will panic. - /// - /// # Safety - /// - /// The caller is responsible for ensuring that no references to - /// boot-services data remain. A non-exhaustive list of resources to check: - /// - /// * All protocols will be invalid after exiting boot services. This - /// includes the [`Output`] protocols attached to stdout/stderr. The - /// caller must ensure that no protocol references remain. - /// * The pool allocator is not usable after exiting boot services. Types - /// such as [`PoolString`] which call [`BootServices::free_pool`] on drop - /// must be cleaned up before calling `exit_boot_services`, or leaked to - /// avoid drop ever being called. - /// * All data in the memory map marked as - /// [`MemoryType::BOOT_SERVICES_CODE`] and - /// [`MemoryType::BOOT_SERVICES_DATA`] will become free memory, the caller - /// must ensure that no references to such memory exist. - /// - /// # Errors - /// - /// This function will fail if it is unable to allocate memory for - /// the memory map, if it fails to retrieve the memory map, or if - /// exiting boot services fails (with up to one retry). - /// - /// All errors are treated as unrecoverable because the system is - /// now in an undefined state. Rather than returning control to the - /// caller, the system will be reset. - /// - /// [`helpers`]: crate::helpers - /// [`Output`]: crate::proto::console::text::Output - /// [`PoolString`]: crate::proto::device_path::text::PoolString - #[must_use] - pub unsafe fn exit_boot_services( - self, - memory_type: MemoryType, - ) -> (SystemTable, MemoryMapOwned) { - crate::helpers::exit(); - - // Reboot the device. - let reset = |status| -> ! { - { - log::warn!("Resetting the machine"); - self.runtime_services().reset(ResetType::COLD, status, None) - } - }; - - let mut buf = MemoryMapBackingMemory::new(memory_type).expect("Failed to allocate memory"); - - // Calling `exit_boot_services` can fail if the memory map key is not - // current. Retry a second time if that occurs. This matches the - // behavior of the Linux kernel: - // https://github.com/torvalds/linux/blob/e544a0743/drivers/firmware/efi/libstub/efi-stub-helper.c#L375 - let mut status = Status::ABORTED; - for _ in 0..2 { - match unsafe { self.get_memory_map_and_exit_boot_services(buf.as_mut_slice()) } { - Ok(memory_map) => { - let st = SystemTable { - table: self.table, - _marker: PhantomData, - }; - return (st, MemoryMapOwned::from_initialized_mem(buf, memory_map)); - } - Err(err) => { - log::error!("Error retrieving the memory map for exiting the boot services"); - status = err.status() - } - } - } - - // Failed to exit boot services. - reset(status) - } - /// Clone this boot-time UEFI system table interface /// /// # Safety From 8bfa226321ca846f4a7f18ecc59cf0ba11c59783 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 01:05:02 -0400 Subject: [PATCH 6/8] uefi: Delete SystemTable --- uefi/src/table/mod.rs | 2 +- uefi/src/table/system.rs | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/uefi/src/table/mod.rs b/uefi/src/table/mod.rs index 114fcf117..07eb1a8f2 100644 --- a/uefi/src/table/mod.rs +++ b/uefi/src/table/mod.rs @@ -9,7 +9,7 @@ mod system; pub use header::Header; #[allow(deprecated)] -pub use system::{Boot, Runtime, SystemTable}; +pub use system::{Boot, SystemTable}; pub use uefi_raw::table::Revision; use core::ptr::{self, NonNull}; diff --git a/uefi/src/table/system.rs b/uefi/src/table/system.rs index 0125525ee..2d32219f1 100644 --- a/uefi/src/table/system.rs +++ b/uefi/src/table/system.rs @@ -1,7 +1,6 @@ #![allow(deprecated)] use super::boot::BootServices; -use super::runtime::RuntimeServices; use super::{cfg, Revision}; use crate::proto::console::text; use crate::CStr16; @@ -20,12 +19,6 @@ pub trait SystemTableView {} pub struct Boot; impl SystemTableView for Boot {} -/// Marker struct associated with the run-time view of the UEFI System Table. -#[deprecated = "Use the uefi::runtime module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"] -#[derive(Debug)] -pub struct Runtime; -impl SystemTableView for Runtime {} - /// UEFI System Table interface /// /// The UEFI System Table is the gateway to all UEFI services which an UEFI @@ -143,12 +136,6 @@ impl SystemTable { unsafe { &mut *(*self.table).stderr.cast() } } - /// Access runtime services - #[must_use] - pub const fn runtime_services(&self) -> &RuntimeServices { - unsafe { &*(*self.table).runtime_services.cast_const().cast() } - } - /// Access boot services #[must_use] pub const fn boot_services(&self) -> &BootServices { From 44ca8892198d775b45d267ca7b4cef667f92ada6 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 01:07:37 -0400 Subject: [PATCH 7/8] test-runner: Clean up a few old imports of uefi::table::runtime --- uefi-test-runner/src/proto/media.rs | 2 +- uefi-test-runner/src/proto/misc.rs | 4 ++-- uefi-test-runner/src/runtime/vars.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/uefi-test-runner/src/proto/media.rs b/uefi-test-runner/src/proto/media.rs index 3ba3a00e7..c4be2a0bd 100644 --- a/uefi-test-runner/src/proto/media.rs +++ b/uefi-test-runner/src/proto/media.rs @@ -13,7 +13,7 @@ use uefi::proto::media::file::{ }; use uefi::proto::media::fs::SimpleFileSystem; use uefi::proto::media::partition::{MbrOsType, PartitionInfo}; -use uefi::table::runtime::{Daylight, Time, TimeParams}; +use uefi::runtime::{Daylight, Time, TimeParams}; /// Test directory entry iteration. fn test_existing_dir(directory: &mut Directory) { diff --git a/uefi-test-runner/src/proto/misc.rs b/uefi-test-runner/src/proto/misc.rs index c7b1664f7..6fd55b624 100644 --- a/uefi-test-runner/src/proto/misc.rs +++ b/uefi-test-runner/src/proto/misc.rs @@ -1,6 +1,6 @@ use uefi::prelude::*; use uefi::proto::misc::ResetNotification; -use uefi::table::runtime; +use uefi::runtime::ResetType; pub fn test(bt: &BootServices) { test_reset_notification(bt); @@ -19,7 +19,7 @@ pub fn test_reset_notification(bt: &BootServices) { // value efi_reset_fn is the type of ResetSystemFn, a function pointer unsafe extern "efiapi" fn efi_reset_fn( - rt: runtime::ResetType, + rt: ResetType, status: Status, data_size: usize, data: *const u8, diff --git a/uefi-test-runner/src/runtime/vars.rs b/uefi-test-runner/src/runtime/vars.rs index 0e750976b..930141c02 100644 --- a/uefi-test-runner/src/runtime/vars.rs +++ b/uefi-test-runner/src/runtime/vars.rs @@ -1,6 +1,6 @@ use log::info; use uefi::prelude::*; -use uefi::table::runtime::{VariableAttributes, VariableVendor}; +use uefi::runtime::{VariableAttributes, VariableVendor}; use uefi::{guid, runtime, CStr16, Error}; /// Test variable name. From bdb925cd7acb52219cc9f71743a2b0302b915620 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 20 Sep 2024 01:07:52 -0400 Subject: [PATCH 8/8] uefi: Delete the uefi::table::runtime module --- uefi/CHANGELOG.md | 4 + uefi/src/prelude.rs | 2 - uefi/src/table/mod.rs | 1 - uefi/src/table/runtime.rs | 412 -------------------------------------- 4 files changed, 4 insertions(+), 415 deletions(-) delete mode 100644 uefi/src/table/runtime.rs diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 01fc2eb05..bde43e5cc 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,6 +1,10 @@ # uefi - [Unreleased] +See [Deprecating SystemTable/BootServices/RuntimeServices][funcmigrate] for +details of the deprecated items that were removed in this release. + ## Changed +- **Breaking:** Deleted the deprecated `RuntimeServices` struct. - **Breaking:** Deleted deprecated functions `helpers::system_table` and `table::system_table_runtime`. - **Breaking:** `FileSystem` no longer has a lifetime parameter, and the diff --git a/uefi/src/prelude.rs b/uefi/src/prelude.rs index c346023b2..77dd0218f 100644 --- a/uefi/src/prelude.rs +++ b/uefi/src/prelude.rs @@ -10,6 +10,4 @@ pub use crate::{ #[allow(deprecated)] pub use crate::table::boot::BootServices; #[allow(deprecated)] -pub use crate::table::runtime::RuntimeServices; -#[allow(deprecated)] pub use crate::table::{Boot, SystemTable}; diff --git a/uefi/src/table/mod.rs b/uefi/src/table/mod.rs index 07eb1a8f2..c991743c9 100644 --- a/uefi/src/table/mod.rs +++ b/uefi/src/table/mod.rs @@ -2,7 +2,6 @@ pub mod boot; pub mod cfg; -pub mod runtime; mod header; mod system; diff --git a/uefi/src/table/runtime.rs b/uefi/src/table/runtime.rs deleted file mode 100644 index 76eb256c8..000000000 --- a/uefi/src/table/runtime.rs +++ /dev/null @@ -1,412 +0,0 @@ -//! UEFI services available at runtime, even after the OS boots. - -#![allow(deprecated)] - -pub use crate::runtime::{ - CapsuleInfo, Time, TimeByteConversionError, TimeError, TimeParams, VariableStorageInfo, -}; -pub use uefi_raw::capsule::{CapsuleBlockDescriptor, CapsuleFlags, CapsuleHeader}; -pub use uefi_raw::table::runtime::{ - ResetType, TimeCapabilities, VariableAttributes, VariableVendor, -}; -pub use uefi_raw::time::Daylight; -pub use uefi_raw::PhysicalAddress; - -#[cfg(feature = "alloc")] -pub use crate::runtime::VariableKey; - -use super::Revision; -use crate::{CStr16, Error, Result, Status, StatusExt}; -use core::mem::MaybeUninit; -use core::ptr; -#[cfg(feature = "alloc")] -use { - crate::Guid, - alloc::boxed::Box, - alloc::{vec, vec::Vec}, - core::mem, -}; - -/// Contains pointers to all of the runtime services. -/// -/// This table, and the function pointers it contains are valid -/// even after the UEFI OS loader and OS have taken control of the platform. -/// -/// # Accessing `RuntimeServices` -/// -/// A reference to `RuntimeServices` can only be accessed by calling [`SystemTable::runtime_services`]. -/// -/// [`SystemTable::runtime_services`]: crate::table::SystemTable::runtime_services -#[deprecated = "Use the uefi::runtime module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"] -#[derive(Debug)] -#[repr(C)] -pub struct RuntimeServices(uefi_raw::table::runtime::RuntimeServices); - -impl RuntimeServices { - /// Query the current time and date information - pub fn get_time(&self) -> Result