diff options
| author | Vaze <vaze@vaze.dev> | 2026-05-24 11:12:58 +0200 |
|---|---|---|
| committer | Vaze <vaze@vaze.dev> | 2026-05-24 11:12:58 +0200 |
| commit | 00552fcd03f86bffed8c2f6a9d110981cb869489 (patch) | |
| tree | 9ec457e586317584a9c422cae06e6f83f1266fa2 /bootloader/src | |
| parent | 83e4e3051395c6dcf20ef05682b247f9da479502 (diff) | |
Added functionality to bootloader so it can now read the kernel file to memory.
Diffstat (limited to 'bootloader/src')
| -rw-r--r-- | bootloader/src/main.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/bootloader/src/main.rs b/bootloader/src/main.rs index 87432af..04afe41 100644 --- a/bootloader/src/main.rs +++ b/bootloader/src/main.rs @@ -3,13 +3,41 @@ use core::time::Duration; use log::info; +use uefi::print; use uefi::prelude::*; +use uefi::Result; +use uefi::Status; +use uefi::CString16; +use uefi::fs::{FileSystem, FileSystemResult}; +use uefi::proto::media::fs::SimpleFileSystem; +use uefi::boot::{self, ScopedProtocol}; + +extern crate alloc; +use alloc::vec::Vec; #[entry] fn main() -> Status { uefi::helpers::init().unwrap(); - info!("Hello world!"); + info!("Hello from bootloader!"); + load_kernel().unwrap(); + info!("Entry fuction regained control!"); boot::stall(Duration::from_secs(10)); + info!("exiting!"); Status::SUCCESS } +fn load_kernel() -> Result { + info!("Entered load_kernel function"); + let kernel = read_file(r"\EFI\BOOT\kernel.elf").unwrap(); + info!("Read kernel into memory!"); + print!("{:x?}", kernel[..10].to_vec()); + info!("I printed my dump"); + return Ok(()); +} + +fn read_file(path: &str) -> FileSystemResult<Vec<u8>> { + let path: CString16 = CString16::try_from(path).unwrap(); + let fs: ScopedProtocol<SimpleFileSystem> = boot::get_image_file_system(boot::image_handle()).unwrap(); + let mut fs = FileSystem::new(fs); + fs.read(path.as_ref()) +} |
