From 82503e4073286875c5402faa393e5ceff69eee7a Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 7 Jul 2024 13:34:41 -0400 Subject: [PATCH] Drop SystemTable arg from uefi::helpers::init Use the global system table pointer instead. --- uefi-test-runner/examples/hello_world.rs | 4 ++-- uefi-test-runner/examples/loaded_image.rs | 4 ++-- uefi-test-runner/examples/shell_params.rs | 4 ++-- uefi-test-runner/examples/sierpinski.rs | 4 ++-- uefi-test-runner/examples/timestamp.rs | 4 ++-- uefi-test-runner/src/bin/shell_launcher.rs | 4 ++-- uefi-test-runner/src/main.rs | 2 +- uefi/CHANGELOG.md | 3 +++ uefi/src/helpers/mod.rs | 8 +++++--- 9 files changed, 21 insertions(+), 16 deletions(-) diff --git a/uefi-test-runner/examples/hello_world.rs b/uefi-test-runner/examples/hello_world.rs index a2b46d826..91081cb9e 100644 --- a/uefi-test-runner/examples/hello_world.rs +++ b/uefi-test-runner/examples/hello_world.rs @@ -11,10 +11,10 @@ use uefi::prelude::*; // ANCHOR: entry #[entry] -fn main(_image_handle: Handle, mut system_table: SystemTable) -> Status { +fn main(_image_handle: Handle, system_table: SystemTable) -> Status { // ANCHOR_END: entry // ANCHOR: services - uefi::helpers::init(&mut system_table).unwrap(); + uefi::helpers::init().unwrap(); // ANCHOR_END: services // ANCHOR: log info!("Hello world!"); diff --git a/uefi-test-runner/examples/loaded_image.rs b/uefi-test-runner/examples/loaded_image.rs index 01debc0cb..216af7a89 100644 --- a/uefi-test-runner/examples/loaded_image.rs +++ b/uefi-test-runner/examples/loaded_image.rs @@ -13,8 +13,8 @@ use uefi::{Identify, Result}; // ANCHOR: main #[entry] -fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { - uefi::helpers::init(&mut system_table).unwrap(); +fn main(image_handle: Handle, system_table: SystemTable) -> Status { + uefi::helpers::init().unwrap(); let boot_services = system_table.boot_services(); print_image_path(boot_services).unwrap(); diff --git a/uefi-test-runner/examples/shell_params.rs b/uefi-test-runner/examples/shell_params.rs index ad95a89f4..90d72bcb8 100644 --- a/uefi-test-runner/examples/shell_params.rs +++ b/uefi-test-runner/examples/shell_params.rs @@ -17,10 +17,10 @@ use alloc::vec::Vec; // ANCHOR: entry #[entry] -fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { +fn main(image_handle: Handle, system_table: SystemTable) -> Status { // ANCHOR_END: entry // ANCHOR: services - uefi::helpers::init(&mut system_table).unwrap(); + uefi::helpers::init().unwrap(); let boot_services = system_table.boot_services(); // ANCHOR_END: services diff --git a/uefi-test-runner/examples/sierpinski.rs b/uefi-test-runner/examples/sierpinski.rs index ac690eaef..f0b0912c3 100644 --- a/uefi-test-runner/examples/sierpinski.rs +++ b/uefi-test-runner/examples/sierpinski.rs @@ -144,8 +144,8 @@ fn draw_sierpinski(bt: &BootServices) -> Result { } #[entry] -fn main(_handle: Handle, mut system_table: SystemTable) -> Status { - uefi::helpers::init(&mut system_table).unwrap(); +fn main(_handle: Handle, system_table: SystemTable) -> Status { + uefi::helpers::init().unwrap(); let bt = system_table.boot_services(); draw_sierpinski(bt).unwrap(); Status::SUCCESS diff --git a/uefi-test-runner/examples/timestamp.rs b/uefi-test-runner/examples/timestamp.rs index deccc7e98..1ce578614 100644 --- a/uefi-test-runner/examples/timestamp.rs +++ b/uefi-test-runner/examples/timestamp.rs @@ -16,10 +16,10 @@ use uefi::proto::misc::Timestamp; // ANCHOR: entry #[entry] -fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { +fn main(image_handle: Handle, system_table: SystemTable) -> Status { // ANCHOR_END: entry // ANCHOR: services - uefi::helpers::init(&mut system_table).unwrap(); + uefi::helpers::init().unwrap(); let boot_services = system_table.boot_services(); // ANCHOR_END: services diff --git a/uefi-test-runner/src/bin/shell_launcher.rs b/uefi-test-runner/src/bin/shell_launcher.rs index 4accdca6f..123307bd6 100644 --- a/uefi-test-runner/src/bin/shell_launcher.rs +++ b/uefi-test-runner/src/bin/shell_launcher.rs @@ -45,8 +45,8 @@ fn get_shell_app_device_path<'a>( } #[entry] -fn efi_main(image: Handle, mut st: SystemTable) -> Status { - uefi::helpers::init(&mut st).unwrap(); +fn efi_main(image: Handle, st: SystemTable) -> Status { + uefi::helpers::init().unwrap(); let boot_services = st.boot_services(); let mut storage = Vec::new(); diff --git a/uefi-test-runner/src/main.rs b/uefi-test-runner/src/main.rs index c61411e27..56c90f7f6 100644 --- a/uefi-test-runner/src/main.rs +++ b/uefi-test-runner/src/main.rs @@ -23,7 +23,7 @@ mod runtime; #[entry] fn efi_main(image: Handle, mut st: SystemTable) -> Status { // Initialize utilities (logging, memory allocation...) - uefi::helpers::init(&mut st).expect("Failed to initialize utilities"); + uefi::helpers::init().expect("Failed to initialize utilities"); // unit tests here diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index c0cf43177..e746ab9c9 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,5 +1,8 @@ # uefi - [Unreleased] +## Changed +- **Breaking:** `uefi::helpers::init` no longer takes an argument. + # uefi - 0.29.0 (2024-07-02) diff --git a/uefi/src/helpers/mod.rs b/uefi/src/helpers/mod.rs index e7afe9a6e..b944f2bc8 100644 --- a/uefi/src/helpers/mod.rs +++ b/uefi/src/helpers/mod.rs @@ -55,17 +55,19 @@ pub fn system_table() -> SystemTable { /// epoch. Limited functionality might work after exiting them, such as logging /// to the debugcon device. #[allow(unused_variables)] // `st` is unused if logger and allocator are disabled -pub fn init(st: &mut SystemTable) -> Result<()> { +pub fn init() -> Result<()> { // Setup logging and memory allocation + let mut st = table::system_table_boot().expect("boot services are not active"); + #[cfg(feature = "logger")] unsafe { - logger::init(st); + logger::init(&mut st); } #[cfg(feature = "global_allocator")] unsafe { - crate::allocator::init(st); + crate::allocator::init(&mut st); } Ok(())