begin documenting some functions and align error messages

This commit is contained in:
2025-10-14 12:47:33 -07:00
parent 7a0c32c191
commit e90b45f58d
15 changed files with 148 additions and 101 deletions

View File

@@ -28,7 +28,7 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
context.root().loaded_image_path()?,
&context.stamp(&configuration.path),
)
.context("failed to resolve chainload path")?;
.context("unable to resolve chainload path")?;
let image = uefi::boot::load_image(
sprout_image,
@@ -37,7 +37,7 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
boot_policy: uefi::proto::BootPolicy::ExactMatch,
},
)
.context("failed to load image")?;
.context("unable to load image")?;
let mut loaded_image_protocol = uefi::boot::open_protocol_exclusive::<LoadedImage>(image)
.context("unable to open loaded image protocol")?;
@@ -76,20 +76,20 @@ pub fn chainload(context: Rc<SproutContext>, configuration: &ChainloadConfigurat
if let Some(ref linux_initrd) = configuration.linux_initrd {
let initrd_path = context.stamp(linux_initrd);
let content = utils::read_file_contents(context.root().loaded_image_path()?, &initrd_path)
.context("failed to read linux initrd")?;
.context("unable to read linux initrd")?;
initrd_handle = Some(
register_linux_initrd(content.into_boxed_slice())
.context("failed to register linux initrd")?,
.context("unable to register linux initrd")?,
);
}
let (base, size) = loaded_image_protocol.info();
info!("loaded image: base={:#x} size={:#x}", base.addr(), size);
let result = uefi::boot::start_image(image).context("failed to start image");
let result = uefi::boot::start_image(image).context("unable to start image");
if let Some(initrd_handle) = initrd_handle {
unregister_linux_initrd(initrd_handle).context("failed to unregister linux initrd")?;
unregister_linux_initrd(initrd_handle).context("unable to unregister linux initrd")?;
}
result.context("failed to start image")?;
result.context("unable to start image")?;
drop(options_holder);
Ok(())
}

View File

@@ -25,9 +25,9 @@ pub fn default_splash_time() -> u32 {
fn setup_graphics() -> Result<ScopedProtocol<GraphicsOutput>> {
let gop_handle = uefi::boot::get_handle_for_protocol::<GraphicsOutput>()
.context("failed to get graphics output")?;
.context("unable to get graphics output")?;
uefi::boot::open_protocol_exclusive::<GraphicsOutput>(gop_handle)
.context("failed to open graphics output")
.context("unable to open graphics output")
}
fn fit_to_frame(image: &DynamicImage, frame: Rect) -> Rect {
@@ -99,7 +99,7 @@ pub fn splash(context: Rc<SproutContext>, configuration: &SplashConfiguration) -
let image = read_file_contents(context.root().loaded_image_path()?, &image)?;
let image = ImageReader::with_format(Cursor::new(image), ImageFormat::Png)
.decode()
.context("failed to decode splash image")?;
.context("unable to decode splash image")?;
draw(image)?;
std::thread::sleep(Duration::from_secs(configuration.time as u64));
Ok(())