File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use bootloader::{
1010} ;
1111use core:: {
1212 arch:: { asm, global_asm} ,
13+ cmp,
1314 panic:: PanicInfo ,
1415 slice,
1516} ;
@@ -84,15 +85,17 @@ fn bootloader_main(
8485 let ptr = usize_from ( memory_map_addr. as_u64 ( ) ) as * const E820MemoryRegion ;
8586 unsafe { slice:: from_raw_parts ( ptr, usize_from ( memory_map_entry_count) ) }
8687 } ;
87- let max_phys_addr = e820_memory_map
88- . iter ( )
89- . map ( |r| r. start_addr + r. len )
90- // Don't consider addresses > 4GiB when determining the maximum
91- // physical address for the bootloader, as we are in protected mode and
92- // cannot address more than 4 GiB of memory anyway.
93- . filter ( |& addr| addr < GIGABYTE * 4 )
94- . max ( )
95- . expect ( "no physical memory regions found" ) ;
88+ let max_phys_addr = {
89+ let max = e820_memory_map
90+ . iter ( )
91+ . map ( |r| r. start_addr + r. len )
92+ . max ( )
93+ . expect ( "no physical memory regions found" ) ;
94+ // Don't consider addresses > 4GiB when determining the maximum physical
95+ // address for the bootloader, as we are in protected mode and cannot
96+ // address more than 4 GiB of memory anyway.
97+ cmp:: min ( max, 4 * GIGABYTE )
98+ } ;
9699
97100 let mut frame_allocator = {
98101 let kernel_end = PhysFrame :: containing_address ( kernel_start + kernel_size - 1u64 ) ;
You can’t perform that action at this time.
0 commit comments