@@ -27,6 +27,8 @@ use r_efi::{
27
27
} ,
28
28
} ;
29
29
30
+ use crate :: boot;
31
+
30
32
mod alloc;
31
33
mod block;
32
34
mod console;
@@ -574,29 +576,13 @@ extern "win64" fn image_unload(_: Handle) -> Status {
574
576
efi:: Status :: UNSUPPORTED
575
577
}
576
578
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
-
589
579
const PAGE_SIZE : u64 = 4096 ;
590
580
591
581
// 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 {
600
586
ALLOCATOR . borrow_mut ( ) . add_initial_allocation (
601
587
MemoryType :: ConventionalMemory ,
602
588
entry. size / PAGE_SIZE ,
@@ -633,6 +619,7 @@ pub fn efi_exec(
633
619
address : u64 ,
634
620
loaded_address : u64 ,
635
621
loaded_size : u64 ,
622
+ info : & dyn boot:: Info ,
636
623
fs : & crate :: fat:: Filesystem ,
637
624
block : * const crate :: block:: VirtioBlockDevice ,
638
625
) {
@@ -715,7 +702,7 @@ pub fn efi_exec(
715
702
} ;
716
703
717
704
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 ( ) ;
719
706
720
707
let mut ct = if acpi_rsdp_ptr != 0 {
721
708
efi:: ConfigurationTable {
@@ -765,7 +752,7 @@ pub fn efi_exec(
765
752
configuration_table : & mut ct,
766
753
} ;
767
754
768
- populate_allocator ( loaded_address, loaded_size) ;
755
+ populate_allocator ( info , loaded_address, loaded_size) ;
769
756
770
757
let efi_part_id = unsafe { block:: populate_block_wrappers ( & mut BLOCK_WRAPPERS , block) } ;
771
758
0 commit comments