From 381f73e0a64fad49a5cd887cad71998696f82f5f Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Tue, 22 Nov 2022 01:39:05 +0100 Subject: [PATCH] Boot a Linux kernel --- rust/src/main.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 7a2d9f7..e822c4c 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -110,17 +110,26 @@ fn main(handle: Handle, mut system_table: SystemTable) -> Status { debug!("Found root"); let mut file = root - .open(cstr16!("foo.txt"), FileMode::Read, FileAttribute::empty()) + .open(cstr16!("linux.efi"), FileMode::Read, FileAttribute::empty()) .unwrap() .into_regular_file() .unwrap(); debug!("Opened file"); - debug!( - "Data: {}", - alloc::str::from_utf8(&read_all(&mut file).unwrap()).unwrap() - ); + let kernel = read_all(&mut file).unwrap(); + + let kernel_image = boot_services + .load_image( + handle, + uefi::table::boot::LoadImageSource::FromBuffer { + buffer: &kernel, + file_path: None, + }, + ) + .unwrap(); + + boot_services.start_image(kernel_image).unwrap(); Status::SUCCESS }