@@ -58,7 +58,7 @@ pub use framebuffer::{FramebufferColor, FramebufferField, FramebufferTag, Frameb
5858pub use image_load_addr:: ImageLoadPhysAddr ;
5959pub use memory_map:: {
6060 BasicMemoryInfoTag , EFIBootServicesNotExited , EFIMemoryAreaType , EFIMemoryDesc ,
61- EFIMemoryMapTag , MemoryArea , MemoryAreaIter , MemoryAreaType , MemoryMapTag ,
61+ EFIMemoryMapTag , MemoryArea , MemoryAreaType , MemoryMapTag ,
6262} ;
6363pub use module:: { ModuleIter , ModuleTag } ;
6464pub use rsdp:: { RsdpV1Tag , RsdpV2Tag } ;
@@ -514,7 +514,10 @@ impl fmt::Debug for BootInformation {
514514/// This crate uses the [`Pointee`]-abstraction of the [`ptr_meta`] crate to
515515/// create fat pointers.
516516pub 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.
518521 fn dst_size ( base_tag : & Tag ) -> Self :: Metadata ;
519522
520523 /// Creates a reference to a (dynamically sized) tag type in a safe way.
@@ -1218,27 +1221,33 @@ mod tests {
12181221 let addr = bytes. 0 . as_ptr ( ) as usize ;
12191222 let bi = unsafe { load ( addr) } ;
12201223 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 ) ;
12221226 let bi = unsafe { load_with_offset ( addr, 0 ) } ;
12231227 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 ) ;
12251229 let offset = 8usize ;
12261230 for i in 0 ..8 {
12271231 bytes. 0 [ 796 + i] = ( ( string_addr - offset as u64 ) >> ( i * 8 ) ) as u8 ;
12281232 }
12291233 let bi = unsafe { load_with_offset ( addr - offset, offset) } ;
12301234 let bi = bi. unwrap ( ) ;
12311235 test_grub2_boot_info (
1232- bi,
1236+ & bi,
12331237 addr,
12341238 string_addr - offset as u64 ,
12351239 & bytes. 0 ,
12361240 & string_bytes. 0 ,
12371241 ) ;
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:#?}" ) ;
12381247 }
12391248
12401249 fn test_grub2_boot_info (
1241- bi : BootInformation ,
1250+ bi : & BootInformation ,
12421251 addr : usize ,
12431252 string_addr : u64 ,
12441253 bytes : & [ u8 ] ,
@@ -1317,7 +1326,12 @@ mod tests {
13171326 assert_eq ! ( ElfSectionFlags :: empty( ) , s8. flags( ) ) ;
13181327 assert_eq ! ( ElfSectionType :: StringTable , s8. section_type( ) ) ;
13191328 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 ) ;
13211335 let mm1 = mm. next ( ) . unwrap ( ) ;
13221336 assert_eq ! ( 0x00000000 , mm1. start_address( ) ) ;
13231337 assert_eq ! ( 0x009_FC00 , mm1. end_address( ) ) ;
0 commit comments