Skip to content

Commit

Permalink
Merge pull request #1226 from nicholasbishop/bishop-drop-init-param
Browse files Browse the repository at this point in the history
Drop SystemTable arg from uefi::helpers::init
  • Loading branch information
phip1611 authored Jul 7, 2024
2 parents 3d350f7 + 7131204 commit cc7a14c
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 19 deletions.
4 changes: 2 additions & 2 deletions template/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use uefi::prelude::*;

#[entry]
fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init(&mut system_table).unwrap();
fn main(_handle: Handle, system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init().unwrap();

Status::SUCCESS
}
4 changes: 2 additions & 2 deletions uefi-test-runner/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use uefi::prelude::*;

// ANCHOR: entry
#[entry]
fn main(_image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
fn main(_image_handle: Handle, system_table: SystemTable<Boot>) -> 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!");
Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/examples/loaded_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use uefi::{Identify, Result};

// ANCHOR: main
#[entry]
fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init(&mut system_table).unwrap();
fn main(image_handle: Handle, system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init().unwrap();
let boot_services = system_table.boot_services();

print_image_path(boot_services).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/examples/shell_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ use alloc::vec::Vec;

// ANCHOR: entry
#[entry]
fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
fn main(image_handle: Handle, system_table: SystemTable<Boot>) -> 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

Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/examples/sierpinski.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ fn draw_sierpinski(bt: &BootServices) -> Result {
}

#[entry]
fn main(_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init(&mut system_table).unwrap();
fn main(_handle: Handle, system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init().unwrap();
let bt = system_table.boot_services();
draw_sierpinski(bt).unwrap();
Status::SUCCESS
Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/examples/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use uefi::proto::misc::Timestamp;

// ANCHOR: entry
#[entry]
fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
fn main(image_handle: Handle, system_table: SystemTable<Boot>) -> 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

Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/src/bin/shell_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fn get_shell_app_device_path<'a>(
}

#[entry]
fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
uefi::helpers::init(&mut st).unwrap();
fn efi_main(image: Handle, st: SystemTable<Boot>) -> Status {
uefi::helpers::init().unwrap();
let boot_services = st.boot_services();

let mut storage = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion uefi-test-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mod runtime;
#[entry]
fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> 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

Expand Down
3 changes: 3 additions & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# uefi - [Unreleased]

## Changed
- **Breaking:** `uefi::helpers::init` no longer takes an argument.


# uefi - 0.29.0 (2024-07-02)

Expand Down
9 changes: 5 additions & 4 deletions uefi/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,19 @@ pub fn system_table() -> SystemTable<Boot> {
/// **PLEASE NOTE** that these helpers are meant for the pre exit boot service
/// 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<Boot>) -> Result<()> {
pub fn init() -> Result<()> {
// Setup logging and memory allocation

#[cfg(feature = "logger")]
unsafe {
logger::init(st);
let mut st = table::system_table_boot().expect("boot services are not active");
logger::init(&mut st);
}

#[cfg(feature = "global_allocator")]
unsafe {
crate::allocator::init(st);
let mut st = table::system_table_boot().expect("boot services are not active");
crate::allocator::init(&mut st);
}

Ok(())
Expand Down

0 comments on commit cc7a14c

Please sign in to comment.