11use alloc:: vec:: Vec ;
22use uefi:: boot;
3- use uefi:: mem:: memory_map:: { MemoryMap , MemoryMapMut , MemoryType } ;
3+ use uefi:: mem:: memory_map:: { MemoryMap , MemoryMapMut , MemoryMapOwned , MemoryType } ;
44use uefi:: table:: boot:: { AllocateType , BootServices } ;
55
66pub fn test ( bt : & BootServices ) {
@@ -14,6 +14,7 @@ pub fn test(bt: &BootServices) {
1414 alloc_alignment ( ) ;
1515
1616 memory_map ( bt) ;
17+ memory_map_freestanding ( ) ;
1718}
1819
1920fn test_allocate_pages_freestanding ( ) {
@@ -93,13 +94,7 @@ fn alloc_alignment() {
9394 assert_eq ! ( value. as_ptr( ) as usize % 0x100 , 0 , "Wrong alignment" ) ;
9495}
9596
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 ) {
10398 memory_map. sort ( ) ;
10499
105100 // Collect the descriptors into a vector
@@ -130,3 +125,22 @@ fn memory_map(bt: &BootServices) {
130125 let page_count = first_desc. page_count ;
131126 assert ! ( page_count != 0 , "Memory map entry has size zero" ) ;
132127}
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