Skip to content

Commit fda2f73

Browse files
committedMar 26, 2024
change to read hermit application from directory at runtime
1 parent 416387a commit fda2f73

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed
 

‎src/arch/x86_64/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,6 @@ pub fn output_message_byte(byte: u8) {
100100
unsafe { COM1.send(byte) };
101101
}
102102

103-
// Right now, the kernel binary has to be hardcoded into the loader.
104-
// The binary has to be in the same directory (or its whereabouts have to specified in the "include_bytes!" statement).
105-
#[cfg(target_os = "uefi")]
106-
pub unsafe fn find_kernel() -> &'static [u8] {
107-
include_bytes!("hermit-rs-template")
108-
}
109-
110103
/// This is the actual boot function.
111104
/// The bootstack is cleared and provided/calculated BOOT_INFO is written into before the actual call to the assembly code to jump into the kernel.
112105
#[cfg(target_os = "uefi")]

‎src/uefi.rs

+20
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@ use uefi::{
1111
table::{boot::*, cfg},
1212
};
1313

14+
/// This function reads the provided kernelbinary
15+
/// req. location: same subdir as the bootloader itself
16+
/// reg. name: hermit_app
17+
fn read_app(bt: &BootServices) -> Vec<u8> {
18+
let fs = bt
19+
.get_image_file_system(bt.image_handle())
20+
.expect("should open file system");
21+
22+
let path = Path::new(cstr16!(r"\efi\boot\hermit_app"));
23+
24+
let data = FileSystem::new(fs)
25+
.read(path)
26+
.expect("should read file content");
27+
28+
let len = data.len();
29+
info!("Read Hermit application from \"{path}\" (size = {len} B)");
30+
31+
data
32+
}
33+
1434
/// Entry Point of the UEFI Loader
1535
/// This function gets a so-called "EFI System Table" (see UEFI Specification, Section 4: EFI System Table) from the Firmware Interface.
1636
/// Here, the RSDP (for BOOT_INFO) and the kernel are located and the kernel is parsed and loaded into memory.

0 commit comments

Comments
 (0)