diff --git a/Cargo.lock b/Cargo.lock index 99355fe..2fd3968 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,6 +129,7 @@ dependencies = [ name = "sprout" version = "0.1.0" dependencies = [ + "log", "serde", "toml", "uefi", diff --git a/Cargo.toml b/Cargo.toml index 87db0ea..6192c56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/src/modules/chainloader.rs b/src/modules/chainloader.rs index 978ad3a..8cbb0a5 100644 --- a/src/modules/chainloader.rs +++ b/src/modules/chainloader.rs @@ -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::(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::(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"); } diff --git a/src/setup.rs b/src/setup.rs index c63275d..ea787be 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -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"); }