11mod allocator;
22mod console;
33
4+ use alloc:: string:: String ;
45use alloc:: vec:: Vec ;
56use core:: ffi:: c_void;
67use core:: mem:: MaybeUninit ;
@@ -14,7 +15,7 @@ use hermit_entry::elf::{KernelObject, LoadedKernel};
1415use log:: info;
1516use sptr:: Strict ;
1617use uefi:: boot:: { AllocateType , MemoryType , PAGE_SIZE } ;
17- use uefi:: fs:: { FileSystem , Path } ;
18+ use uefi:: fs:: { self , FileSystem , Path } ;
1819use uefi:: prelude:: * ;
1920use uefi:: table:: cfg;
2021
@@ -40,11 +41,15 @@ fn main() -> Status {
4041
4142 drop ( kernel_image) ;
4243
43- let fdt = Fdt :: new ( "uefi" )
44+ let mut fdt = Fdt :: new ( "uefi" )
4445 . unwrap ( )
4546 . rsdp ( u64:: try_from ( rsdp. expose_addr ( ) ) . unwrap ( ) )
4647 . unwrap ( ) ;
4748
49+ if let Some ( bootargs) = read_bootargs ( ) {
50+ fdt = fdt. bootargs ( bootargs) . unwrap ( ) ;
51+ }
52+
4853 allocator:: exit_boot_services ( ) ;
4954 let mut memory_map = unsafe { boot:: exit_boot_services ( None ) } ;
5055
@@ -69,6 +74,25 @@ fn read_app() -> Vec<u8> {
6974 data
7075}
7176
77+ fn read_bootargs ( ) -> Option < String > {
78+ let image_handle = boot:: image_handle ( ) ;
79+ let fs = boot:: get_image_file_system ( image_handle) . expect ( "should open file system" ) ;
80+
81+ let path = Path :: new ( cstr16 ! ( r"\efi\boot\hermit-bootargs" ) ) ;
82+
83+ match FileSystem :: new ( fs) . read_to_string ( path) {
84+ Ok ( bootargs) => {
85+ info ! ( "Read Hermit bootargs from from \" {path}\" : {bootargs}" ) ;
86+ Some ( bootargs)
87+ }
88+ Err ( fs:: Error :: Io ( err) ) if err. uefi_error . status ( ) == Status :: NOT_FOUND => {
89+ info ! ( "Hermit bootargs file does not exist: \" {path}\" " ) ;
90+ None
91+ }
92+ Err ( err) => panic ! ( "{err:?}" ) ,
93+ }
94+ }
95+
7296pub unsafe fn boot_kernel ( kernel_info : LoadedKernel , fdt : Vec < u8 > ) -> ! {
7397 let LoadedKernel {
7498 load_info,
0 commit comments