@@ -13,6 +13,9 @@ pub trait LegacyMemoryRegion: Copy + core::fmt::Debug {
1313 fn len ( & self ) -> u64 ;
1414 /// Returns the type of the region, e.g. whether it is usable or reserved.
1515 fn kind ( & self ) -> MemoryRegionKind ;
16+
17+ /// Mark additional regions as usable just before the bootloader jumps to the kernel.
18+ fn on_bootloader_exit ( & mut self ) { }
1619}
1720
1821/// A physical frame allocator based on a BIOS or UEFI provided memory map.
@@ -101,10 +104,11 @@ where
101104 ) -> & mut [ MemoryRegion ] {
102105 let mut next_index = 0 ;
103106
104- for descriptor in self . original {
107+ for mut descriptor in self . original {
105108 let mut start = descriptor. start ( ) ;
106109 let end = start + descriptor. len ( ) ;
107110 let next_free = self . next_frame . start_address ( ) ;
111+ descriptor. on_bootloader_exit ( ) ;
108112 let kind = match descriptor. kind ( ) {
109113 MemoryRegionKind :: Usable => {
110114 if end <= next_free {
@@ -126,19 +130,6 @@ where
126130 MemoryRegionKind :: Usable
127131 }
128132 }
129- // some mappings created by the UEFI firmware become usable again at this point
130- MemoryRegionKind :: UnknownUefi ( other) => {
131- use uefi:: table:: boot:: MemoryType as M ;
132- match M ( other) {
133- M :: LOADER_CODE
134- | M :: LOADER_DATA
135- | M :: BOOT_SERVICES_CODE
136- | M :: BOOT_SERVICES_DATA
137- | M :: RUNTIME_SERVICES_CODE
138- | M :: RUNTIME_SERVICES_DATA => MemoryRegionKind :: Usable ,
139- other => MemoryRegionKind :: UnknownUefi ( other. 0 ) ,
140- }
141- }
142133 other => other,
143134 } ;
144135
0 commit comments