@@ -69,7 +69,6 @@ fn efi_main(image: Handle, st: SystemTable<Boot>) -> Status {
69
69
70
70
fn main_inner ( image : Handle , mut st : SystemTable < Boot > ) -> Status {
71
71
// temporarily clone the y table for printing panics
72
-
73
72
unsafe {
74
73
* SYSTEM_TABLE . get ( ) = Some ( st. unsafe_clone ( ) ) ;
75
74
}
@@ -118,28 +117,25 @@ fn main_inner(image: Handle, mut st: SystemTable<Boot>) -> Status {
118
117
}
119
118
let mmap_storage = {
120
119
let mut memory_map_size = st. boot_services ( ) . memory_map_size ( ) ;
121
- let mut target_size = memory_map_size. map_size + ( 8 * memory_map_size. entry_size ) ;
122
120
loop {
123
121
let ptr = st
124
122
. boot_services ( )
125
- . allocate_pool ( MemoryType :: LOADER_DATA , target_size )
123
+ . allocate_pool ( MemoryType :: LOADER_DATA , memory_map_size . map_size )
126
124
. expect ( "Failed to allocate memory for mmap storage" ) ;
127
- let storage = unsafe { slice:: from_raw_parts_mut ( ptr, target_size) } ;
125
+
126
+ let storage = unsafe { slice:: from_raw_parts_mut ( ptr, memory_map_size. map_size ) } ;
127
+
128
128
if st. boot_services ( ) . memory_map ( storage) . is_ok ( ) {
129
129
break storage;
130
130
}
131
- // allocated memory region was not big enough -> free it again
132
- st. boot_services ( )
133
- . free_pool ( ptr)
134
- . expect ( "Failed to free temporary memory for memory map!" ) ;
135
131
136
132
// By measuring the size here, we can find out exactly how much we need.
137
133
// We may hit this code twice, if the map allocation ends up spanning more pages.
138
134
memory_map_size = st. boot_services ( ) . memory_map_size ( ) ;
139
-
140
- let next_target_size = memory_map_size . map_size + ( 8 * memory_map_size . entry_size ) ;
141
- target_size = next_target_size ;
142
-
135
+ // allocated memory region was not big enough -> free it again
136
+ st . boot_services ( )
137
+ . free_pool ( ptr )
138
+ . expect ( "Failed to free temporary memory for memory map!" ) ;
143
139
}
144
140
} ;
145
141
@@ -265,7 +261,7 @@ fn locate_and_open_protocol<P: ProtocolPointer>(
265
261
st : & SystemTable < Boot > ,
266
262
) -> Option < ScopedProtocol < P > > {
267
263
let this = st. boot_services ( ) ;
268
- let mut device_path = open_device_path_protocol ( image, st) ?;
264
+ let device_path = open_device_path_protocol ( image, st) ?;
269
265
let mut device_path = device_path. deref ( ) ;
270
266
271
267
let fs_handle = this. locate_device_path :: < P > ( & mut device_path) ;
0 commit comments