11//! Exports item [`InformationBuilder`].
2- use crate :: builder:: { AsBytes , BoxedDst } ;
2+ use crate :: builder:: AsBytes ;
33use crate :: util:: increase_to_alignment;
44use crate :: {
55 BasicMemoryInfoTag , BootInformationHeader , BootLoaderNameTag , CommandLineTag ,
66 EFIBootServicesNotExitedTag , EFIImageHandle32Tag , EFIImageHandle64Tag , EFIMemoryMapTag ,
77 EFISdt32Tag , EFISdt64Tag , ElfSectionsTag , EndTag , FramebufferTag , ImageLoadPhysAddrTag ,
8- MemoryMapTag , ModuleTag , RsdpV1Tag , RsdpV2Tag , SmbiosTag , TagTrait , TagType ,
8+ MemoryMapTag , ModuleTag , RsdpV1Tag , RsdpV2Tag , SmbiosTag , TagTrait , TagType , ALIGNMENT ,
99} ;
10+ use alloc:: boxed:: Box ;
1011use alloc:: vec:: Vec ;
1112use core:: fmt:: { Display , Formatter } ;
1213use core:: mem:: size_of;
@@ -115,8 +116,6 @@ impl InformationBuilder {
115116 /// Constructs the bytes for a valid Multiboot2 information with the given properties.
116117 #[ must_use]
117118 pub fn build ( self ) -> BootInformationBytes {
118- const ALIGN : usize = 8 ;
119-
120119 // PHASE 1/2: Prepare Vector
121120
122121 // We allocate more than necessary so that we can ensure an correct
@@ -134,7 +133,7 @@ impl InformationBuilder {
134133 // Unfortunately, it is not possible to reliably test this in a unit
135134 // test as long as the allocator_api feature is not stable.
136135 // Due to my manual testing, however, it works.
137- let offset = bytes. as_ptr ( ) . align_offset ( ALIGN ) ;
136+ let offset = bytes. as_ptr ( ) . align_offset ( ALIGNMENT ) ;
138137 bytes. extend ( [ 0 ] . repeat ( offset) ) ;
139138
140139 // -----------------------------------------------
@@ -182,6 +181,8 @@ impl InformationBuilder {
182181 . 0
183182 . iter ( )
184183 . map ( |( typ, _) | * typ)
184+ // TODO make a type for tag_is_allowed_multiple_times so that we can
185+ // link to it in the doc.
185186 . any ( |typ| typ == T :: ID && !Self :: tag_is_allowed_multiple_times ( typ) ) ;
186187
187188 if is_redundant_tag {
@@ -205,13 +206,13 @@ impl InformationBuilder {
205206
206207 /// Adds a 'bootloader name' tag (represented by [`BootLoaderNameTag`]) to the builder.
207208 #[ must_use]
208- pub fn bootloader_name_tag ( self , tag : BoxedDst < BootLoaderNameTag > ) -> Self {
209+ pub fn bootloader_name_tag ( self , tag : Box < BootLoaderNameTag > ) -> Self {
209210 self . add_tag ( & * tag) . unwrap ( )
210211 }
211212
212213 /// Adds a 'command line' tag (represented by [`CommandLineTag`]) to the builder.
213214 #[ must_use]
214- pub fn command_line_tag ( self , tag : BoxedDst < CommandLineTag > ) -> Self {
215+ pub fn command_line_tag ( self , tag : Box < CommandLineTag > ) -> Self {
215216 self . add_tag ( & * tag) . unwrap ( )
216217 }
217218
@@ -247,19 +248,19 @@ impl InformationBuilder {
247248
248249 /// Adds a 'EFI Memory map' tag (represented by [`EFIMemoryMapTag`]) to the builder.
249250 #[ must_use]
250- pub fn efi_memory_map_tag ( self , tag : BoxedDst < EFIMemoryMapTag > ) -> Self {
251+ pub fn efi_memory_map_tag ( self , tag : Box < EFIMemoryMapTag > ) -> Self {
251252 self . add_tag ( & * tag) . unwrap ( )
252253 }
253254
254255 /// Adds a 'ELF-Symbols' tag (represented by [`ElfSectionsTag`]) to the builder.
255256 #[ must_use]
256- pub fn elf_sections_tag ( self , tag : BoxedDst < ElfSectionsTag > ) -> Self {
257+ pub fn elf_sections_tag ( self , tag : Box < ElfSectionsTag > ) -> Self {
257258 self . add_tag ( & * tag) . unwrap ( )
258259 }
259260
260261 /// Adds a 'Framebuffer info' tag (represented by [`FramebufferTag`]) to the builder.
261262 #[ must_use]
262- pub fn framebuffer_tag ( self , tag : BoxedDst < FramebufferTag > ) -> Self {
263+ pub fn framebuffer_tag ( self , tag : Box < FramebufferTag > ) -> Self {
263264 self . add_tag ( & * tag) . unwrap ( )
264265 }
265266
@@ -271,14 +272,14 @@ impl InformationBuilder {
271272
272273 /// Adds a (*none EFI*) 'memory map' tag (represented by [`MemoryMapTag`]) to the builder.
273274 #[ must_use]
274- pub fn memory_map_tag ( self , tag : BoxedDst < MemoryMapTag > ) -> Self {
275+ pub fn memory_map_tag ( self , tag : Box < MemoryMapTag > ) -> Self {
275276 self . add_tag ( & * tag) . unwrap ( )
276277 }
277278
278279 /// Adds a 'Modules' tag (represented by [`ModuleTag`]) to the builder.
279280 /// This tag can occur multiple times in boot information.
280281 #[ must_use]
281- pub fn add_module_tag ( self , tag : BoxedDst < ModuleTag > ) -> Self {
282+ pub fn add_module_tag ( self , tag : Box < ModuleTag > ) -> Self {
282283 self . add_tag ( & * tag) . unwrap ( )
283284 }
284285
@@ -296,7 +297,7 @@ impl InformationBuilder {
296297
297298 /// Adds a 'SMBIOS tables' tag (represented by [`SmbiosTag`]) to the builder.
298299 #[ must_use]
299- pub fn smbios_tag ( self , tag : BoxedDst < SmbiosTag > ) -> Self {
300+ pub fn smbios_tag ( self , tag : Box < SmbiosTag > ) -> Self {
300301 self . add_tag ( & * tag) . unwrap ( )
301302 }
302303
@@ -309,7 +310,6 @@ impl InformationBuilder {
309310}
310311
311312#[ cfg( test) ]
312- #[ cfg( not( miri) ) ]
313313mod tests {
314314 use crate :: builder:: information:: InformationBuilder ;
315315 use crate :: { BasicMemoryInfoTag , BootInformation , CommandLineTag , ModuleTag } ;
@@ -353,7 +353,6 @@ mod tests {
353353 }
354354
355355 #[ test]
356- #[ cfg_attr( miri, ignore) ]
357356 fn test_builder ( ) {
358357 // Step 1/2: Build MBI
359358 let mb2i_data = create_builder ( ) . build ( ) ;
0 commit comments