@@ -27,6 +27,8 @@ use r_efi::{
2727 } ,
2828} ;
2929
30+ use crate :: boot;
31+
3032mod alloc;
3133mod block;
3234mod console;
@@ -574,29 +576,13 @@ extern "win64" fn image_unload(_: Handle) -> Status {
574576 efi:: Status :: UNSUPPORTED
575577}
576578
577- /// The 'zero page', a.k.a linux kernel bootparams.
578- pub const ZERO_PAGE_START : usize = 0x7000 ;
579-
580- const E820_RAM : u32 = 1 ;
581-
582- #[ repr( C , packed) ]
583- struct E820Entry {
584- addr : u64 ,
585- size : u64 ,
586- entry_type : u32 ,
587- }
588-
589579const PAGE_SIZE : u64 = 4096 ;
590580
591581// Populate allocator from E820, fixed ranges for the firmware and the loaded binary.
592- fn populate_allocator ( image_address : u64 , image_size : u64 ) {
593- let mut zero_page = crate :: mem:: MemoryRegion :: new ( ZERO_PAGE_START as u64 , 4096 ) ;
594-
595- let e820_count = zero_page. read_u8 ( 0x1e8 ) ;
596- let e820_table = zero_page. as_mut_slice :: < E820Entry > ( 0x2d0 , u64:: from ( e820_count) ) ;
597-
598- for entry in e820_table {
599- if entry. entry_type == E820_RAM {
582+ fn populate_allocator ( info : & dyn boot:: Info , image_address : u64 , image_size : u64 ) {
583+ for i in 0 ..info. num_entries ( ) {
584+ let entry = info. entry ( i) ;
585+ if entry. entry_type == boot:: E820Entry :: RAM_TYPE {
600586 ALLOCATOR . borrow_mut ( ) . add_initial_allocation (
601587 MemoryType :: ConventionalMemory ,
602588 entry. size / PAGE_SIZE ,
@@ -633,6 +619,7 @@ pub fn efi_exec(
633619 address : u64 ,
634620 loaded_address : u64 ,
635621 loaded_size : u64 ,
622+ info : & dyn boot:: Info ,
636623 fs : & crate :: fat:: Filesystem ,
637624 block : * const crate :: block:: VirtioBlockDevice ,
638625) {
@@ -715,7 +702,7 @@ pub fn efi_exec(
715702 } ;
716703
717704 let vendor_data = 0u32 ;
718- let acpi_rsdp_ptr = unsafe { * ( ( ZERO_PAGE_START + 0x70 ) as u64 as * const u64 ) } ;
705+ let acpi_rsdp_ptr = info . rsdp_addr ( ) ;
719706
720707 let mut ct = if acpi_rsdp_ptr != 0 {
721708 efi:: ConfigurationTable {
@@ -765,7 +752,7 @@ pub fn efi_exec(
765752 configuration_table : & mut ct,
766753 } ;
767754
768- populate_allocator ( loaded_address, loaded_size) ;
755+ populate_allocator ( info , loaded_address, loaded_size) ;
769756
770757 let efi_part_id = unsafe { block:: populate_block_wrappers ( & mut BLOCK_WRAPPERS , block) } ;
771758
0 commit comments