diff --git a/uefi-test-runner/src/main.rs b/uefi-test-runner/src/main.rs index d6af3b28a..594b9cad5 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); } @@ -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); } } 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/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..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. @@ -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(); } diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index d6dafc190..bde43e5cc 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,7 +1,12 @@ # uefi - [Unreleased] +See [Deprecating SystemTable/BootServices/RuntimeServices][funcmigrate] for +details of the deprecated items that were removed in this release. + ## Changed -- **Breaking:** Deleted deprecated function `helpers::system_table`. +- **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 deprecated conversion from `uefi::table::boot::ScopedProtocol` has been removed. 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/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/mod.rs b/uefi/src/table/mod.rs index 6cb848a62..c991743c9 100644 --- a/uefi/src/table/mod.rs +++ b/uefi/src/table/mod.rs @@ -2,14 +2,13 @@ pub mod boot; pub mod cfg; -pub mod runtime; mod header; 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}; @@ -79,25 +78,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 diff --git a/uefi/src/table/runtime.rs b/uefi/src/table/runtime.rs deleted file mode 100644 index 2c9d4d22a..000000000 --- a/uefi/src/table/runtime.rs +++ /dev/null @@ -1,422 +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