1
1
use alloc:: vec:: Vec ;
2
2
use uefi:: boot;
3
- use uefi:: mem:: memory_map:: { MemoryMap , MemoryMapMut , MemoryType } ;
3
+ use uefi:: mem:: memory_map:: { MemoryMap , MemoryMapMut , MemoryMapOwned , MemoryType } ;
4
4
use uefi:: table:: boot:: { AllocateType , BootServices } ;
5
5
6
6
pub fn test ( bt : & BootServices ) {
@@ -14,6 +14,7 @@ pub fn test(bt: &BootServices) {
14
14
alloc_alignment ( ) ;
15
15
16
16
memory_map ( bt) ;
17
+ memory_map_freestanding ( ) ;
17
18
}
18
19
19
20
fn test_allocate_pages_freestanding ( ) {
@@ -93,13 +94,7 @@ fn alloc_alignment() {
93
94
assert_eq ! ( value. as_ptr( ) as usize % 0x100 , 0 , "Wrong alignment" ) ;
94
95
}
95
96
96
- fn memory_map ( bt : & BootServices ) {
97
- info ! ( "Testing memory map functions" ) ;
98
-
99
- let mut memory_map = bt
100
- . memory_map ( MemoryType :: LOADER_DATA )
101
- . expect ( "Failed to retrieve UEFI memory map" ) ;
102
-
97
+ fn check_memory_map ( mut memory_map : MemoryMapOwned ) {
103
98
memory_map. sort ( ) ;
104
99
105
100
// Collect the descriptors into a vector
@@ -130,3 +125,22 @@ fn memory_map(bt: &BootServices) {
130
125
let page_count = first_desc. page_count ;
131
126
assert ! ( page_count != 0 , "Memory map entry has size zero" ) ;
132
127
}
128
+
129
+ fn memory_map ( bt : & BootServices ) {
130
+ info ! ( "Testing memory map functions" ) ;
131
+
132
+ let memory_map = bt
133
+ . memory_map ( MemoryType :: LOADER_DATA )
134
+ . expect ( "Failed to retrieve UEFI memory map" ) ;
135
+
136
+ check_memory_map ( memory_map) ;
137
+ }
138
+
139
+ fn memory_map_freestanding ( ) {
140
+ info ! ( "Testing memory map functions (freestanding)" ) ;
141
+
142
+ let memory_map =
143
+ boot:: memory_map ( MemoryType :: LOADER_DATA ) . expect ( "Failed to retrieve UEFI memory map" ) ;
144
+
145
+ check_memory_map ( memory_map) ;
146
+ }
0 commit comments