File tree 1 file changed +12
-9
lines changed
1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use bootloader::{
10
10
} ;
11
11
use core:: {
12
12
arch:: { asm, global_asm} ,
13
+ cmp,
13
14
panic:: PanicInfo ,
14
15
slice,
15
16
} ;
@@ -84,15 +85,17 @@ fn bootloader_main(
84
85
let ptr = usize_from ( memory_map_addr. as_u64 ( ) ) as * const E820MemoryRegion ;
85
86
unsafe { slice:: from_raw_parts ( ptr, usize_from ( memory_map_entry_count) ) }
86
87
} ;
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
+ } ;
96
99
97
100
let mut frame_allocator = {
98
101
let kernel_end = PhysFrame :: containing_address ( kernel_start + kernel_size - 1u64 ) ;
You can’t perform that action at this time.
0 commit comments