Skip to content

Commit

Permalink
test-runner: Use freestanding boot functions in shell_launcher
Browse files Browse the repository at this point in the history
Use boot::load_image and boot::start_image in shell_launcher. Drop the
`efi_main` args as they are no longer needed.
  • Loading branch information
nicholasbishop committed Jul 31, 2024
1 parent 450c4e6 commit 4216052
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions uefi-test-runner/src/bin/shell_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ extern crate alloc;

use alloc::vec::Vec;
use log::info;
use uefi::boot;
use uefi::boot::{self, LoadImageSource};
use uefi::prelude::*;
use uefi::proto::device_path::build::{self, DevicePathBuilder};
use uefi::proto::device_path::{DevicePath, DeviceSubType, DeviceType, LoadedImageDevicePath};
use uefi::proto::loaded_image::LoadedImage;
use uefi::table::boot::LoadImageSource;

/// Get the device path of the shell app. This is the same as the
/// currently-loaded image's device path, but with the file path part changed.
Expand All @@ -43,23 +42,21 @@ fn get_shell_app_device_path(storage: &mut Vec<u8>) -> &DevicePath {
}

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

let mut storage = Vec::new();
let shell_image_path = get_shell_app_device_path(&mut storage);

// Load the shell app.
let shell_image_handle = boot_services
.load_image(
image,
LoadImageSource::FromDevicePath {
device_path: shell_image_path,
from_boot_manager: false,
},
)
.expect("failed to load shell app");
let shell_image_handle = boot::load_image(
boot::image_handle(),
LoadImageSource::FromDevicePath {
device_path: shell_image_path,
from_boot_manager: false,
},
)
.expect("failed to load shell app");

// Set the command line passed to the shell app so that it will run the
// test-runner app. This automatically turns off the five-second delay.
Expand All @@ -74,9 +71,7 @@ fn efi_main(image: Handle, st: SystemTable<Boot>) -> Status {
}

info!("launching the shell app");
boot_services
.start_image(shell_image_handle)
.expect("failed to launch the shell app");
boot::start_image(shell_image_handle).expect("failed to launch the shell app");

Status::SUCCESS
}

0 comments on commit 4216052

Please sign in to comment.