@@ -58,7 +58,7 @@ pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, Frameb
58
58
pub use image_load_addr:: ImageLoadPhysAddr ;
59
59
pub use memory_map:: {
60
60
BasicMemoryInfoTag , EFIBootServicesNotExited , EFIMemoryAreaType , EFIMemoryDesc ,
61
- EFIMemoryMapTag , MemoryArea , MemoryAreaIter , MemoryAreaType , MemoryMapTag ,
61
+ EFIMemoryMapTag , MemoryArea , MemoryAreaType , MemoryMapTag ,
62
62
} ;
63
63
pub use module:: { ModuleIter , ModuleTag } ;
64
64
pub use rsdp:: { RsdpV1Tag , RsdpV2Tag } ;
@@ -514,7 +514,10 @@ impl fmt::Debug for BootInformation {
514
514
/// This crate uses the [`Pointee`]-abstraction of the [`ptr_meta`] crate to
515
515
/// create fat pointers.
516
516
pub trait TagTrait : Pointee {
517
- /// Returns
517
+ /// Returns the amount of items in the dynamically sized portion of the
518
+ /// DST. Note that this is not the amount of bytes. So if the dynamically
519
+ /// sized portion is 16 bytes in size and each element is 4 bytes big, then
520
+ /// this function must return 4.
518
521
fn dst_size ( base_tag : & Tag ) -> Self :: Metadata ;
519
522
520
523
/// Creates a reference to a (dynamically sized) tag type in a safe way.
@@ -1218,27 +1221,33 @@ mod tests {
1218
1221
let addr = bytes. 0 . as_ptr ( ) as usize ;
1219
1222
let bi = unsafe { load ( addr) } ;
1220
1223
let bi = bi. unwrap ( ) ;
1221
- test_grub2_boot_info ( bi, addr, string_addr, & bytes. 0 , & string_bytes. 0 ) ;
1224
+
1225
+ test_grub2_boot_info ( & bi, addr, string_addr, & bytes. 0 , & string_bytes. 0 ) ;
1222
1226
let bi = unsafe { load_with_offset ( addr, 0 ) } ;
1223
1227
let bi = bi. unwrap ( ) ;
1224
- test_grub2_boot_info ( bi, addr, string_addr, & bytes. 0 , & string_bytes. 0 ) ;
1228
+ test_grub2_boot_info ( & bi, addr, string_addr, & bytes. 0 , & string_bytes. 0 ) ;
1225
1229
let offset = 8usize ;
1226
1230
for i in 0 ..8 {
1227
1231
bytes. 0 [ 796 + i] = ( ( string_addr - offset as u64 ) >> ( i * 8 ) ) as u8 ;
1228
1232
}
1229
1233
let bi = unsafe { load_with_offset ( addr - offset, offset) } ;
1230
1234
let bi = bi. unwrap ( ) ;
1231
1235
test_grub2_boot_info (
1232
- bi,
1236
+ & bi,
1233
1237
addr,
1234
1238
string_addr - offset as u64 ,
1235
1239
& bytes. 0 ,
1236
1240
& string_bytes. 0 ,
1237
1241
) ;
1242
+
1243
+ // Check that the MBI's debug output can be printed without SEGFAULT.
1244
+ // If this works, it is a good indicator than transitively a lot of
1245
+ // stuff works.
1246
+ println ! ( "{bi:#?}" ) ;
1238
1247
}
1239
1248
1240
1249
fn test_grub2_boot_info (
1241
- bi : BootInformation ,
1250
+ bi : & BootInformation ,
1242
1251
addr : usize ,
1243
1252
string_addr : u64 ,
1244
1253
bytes : & [ u8 ] ,
@@ -1317,7 +1326,12 @@ mod tests {
1317
1326
assert_eq ! ( ElfSectionFlags :: empty( ) , s8. flags( ) ) ;
1318
1327
assert_eq ! ( ElfSectionType :: StringTable , s8. section_type( ) ) ;
1319
1328
assert ! ( es. next( ) . is_none( ) ) ;
1320
- let mut mm = bi. memory_map_tag ( ) . unwrap ( ) . available_memory_areas ( ) ;
1329
+ let mut mm = bi
1330
+ . memory_map_tag ( )
1331
+ . unwrap ( )
1332
+ . memory_areas ( )
1333
+ . iter ( )
1334
+ . filter ( |area| area. typ ( ) == MemoryAreaType :: Available ) ;
1321
1335
let mm1 = mm. next ( ) . unwrap ( ) ;
1322
1336
assert_eq ! ( 0x00000000 , mm1. start_address( ) ) ;
1323
1337
assert_eq ! ( 0x009_FC00 , mm1. end_address( ) ) ;
0 commit comments