swap to uefi logger

This commit is contained in:
2025-10-01 19:15:42 -07:00
parent 3fdaad42ad
commit 3b8243d401
4 changed files with 29 additions and 3 deletions

1
Cargo.lock generated
View File

@@ -129,6 +129,7 @@ dependencies = [
name = "sprout"
version = "0.1.0"
dependencies = [
"log",
"serde",
"toml",
"uefi",

View File

@@ -5,6 +5,7 @@ edition = "2024"
[dependencies]
toml = "0.9.7"
log = "0.4.28"
[dependencies.serde]
version = "1.0.228"
@@ -12,4 +13,18 @@ features = ["derive"]
[dependencies.uefi]
version = "0.35.0"
features = ["alloc"]
features = ["alloc", "logger"]
[profile.release]
lto = "thin"
strip = "symbols"
[profile.release-debuginfo]
inherits = "release"
strip = "none"
debug = 1
[profile.dev-fast]
inherits = "dev"
strip = "debuginfo"
debug = 0

View File

@@ -1,4 +1,6 @@
use crate::config::ChainloaderConfiguration;
use log::info;
use uefi::proto::loaded_image::LoadedImage;
use uefi::{
CString16,
proto::device_path::{
@@ -24,7 +26,7 @@ pub fn chainloader(configuration: ChainloaderConfiguration) {
let sprout_image = uefi::boot::image_handle();
let image_device_path_protocol =
uefi::boot::open_protocol_exclusive::<LoadedImageDevicePath>(sprout_image)
.expect("unable to open loaded image protocol");
.expect("unable to open loaded image device path protocol");
let image_device_path: &DevicePath = &image_device_path_protocol;
let mut full_path = image_device_path
@@ -45,7 +47,7 @@ pub fn chainloader(configuration: ChainloaderConfiguration) {
full_path.push('/');
full_path.push_str(&configuration.path);
println!("chainloader: path={}", full_path);
info!("path={}", full_path);
let device_path = text_to_device_path(&full_path);
@@ -57,5 +59,11 @@ pub fn chainloader(configuration: ChainloaderConfiguration) {
},
)
.expect("failed to load image");
let image_device_path_protocol = uefi::boot::open_protocol_exclusive::<LoadedImage>(image)
.expect("unable to open loaded image protocol");
let (base, size) = image_device_path_protocol.info();
info!("loaded image base={:#x} size={:#x}", base.addr(), size);
uefi::boot::start_image(image).expect("failed to start image");
}

View File

@@ -13,4 +13,6 @@ pub fn init() {
.expect("unable to resolve image handle");
uefi::boot::set_image_handle(handle);
}
uefi::helpers::init().expect("failed to initialize uefi");
}