1
1
//! Exports item [`InformationBuilder`].
2
- use crate :: builder:: { AsBytes , BoxedDst } ;
2
+ use crate :: builder:: AsBytes ;
3
3
use crate :: util:: increase_to_alignment;
4
4
use crate :: {
5
5
BasicMemoryInfoTag , BootInformationHeader , BootLoaderNameTag , CommandLineTag ,
6
6
EFIBootServicesNotExitedTag , EFIImageHandle32Tag , EFIImageHandle64Tag , EFIMemoryMapTag ,
7
7
EFISdt32Tag , EFISdt64Tag , ElfSectionsTag , EndTag , FramebufferTag , ImageLoadPhysAddrTag ,
8
- MemoryMapTag , ModuleTag , RsdpV1Tag , RsdpV2Tag , SmbiosTag , TagTrait , TagType ,
8
+ MemoryMapTag , ModuleTag , RsdpV1Tag , RsdpV2Tag , SmbiosTag , TagTrait , TagType , ALIGNMENT ,
9
9
} ;
10
+ use alloc:: boxed:: Box ;
10
11
use alloc:: vec:: Vec ;
11
12
use core:: fmt:: { Display , Formatter } ;
12
13
use core:: mem:: size_of;
@@ -115,8 +116,6 @@ impl InformationBuilder {
115
116
/// Constructs the bytes for a valid Multiboot2 information with the given properties.
116
117
#[ must_use]
117
118
pub fn build ( self ) -> BootInformationBytes {
118
- const ALIGN : usize = 8 ;
119
-
120
119
// PHASE 1/2: Prepare Vector
121
120
122
121
// We allocate more than necessary so that we can ensure an correct
@@ -134,7 +133,7 @@ impl InformationBuilder {
134
133
// Unfortunately, it is not possible to reliably test this in a unit
135
134
// test as long as the allocator_api feature is not stable.
136
135
// 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 ) ;
138
137
bytes. extend ( [ 0 ] . repeat ( offset) ) ;
139
138
140
139
// -----------------------------------------------
@@ -182,6 +181,8 @@ impl InformationBuilder {
182
181
. 0
183
182
. iter ( )
184
183
. 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.
185
186
. any ( |typ| typ == T :: ID && !Self :: tag_is_allowed_multiple_times ( typ) ) ;
186
187
187
188
if is_redundant_tag {
@@ -205,13 +206,13 @@ impl InformationBuilder {
205
206
206
207
/// Adds a 'bootloader name' tag (represented by [`BootLoaderNameTag`]) to the builder.
207
208
#[ must_use]
208
- pub fn bootloader_name_tag ( self , tag : BoxedDst < BootLoaderNameTag > ) -> Self {
209
+ pub fn bootloader_name_tag ( self , tag : Box < BootLoaderNameTag > ) -> Self {
209
210
self . add_tag ( & * tag) . unwrap ( )
210
211
}
211
212
212
213
/// Adds a 'command line' tag (represented by [`CommandLineTag`]) to the builder.
213
214
#[ must_use]
214
- pub fn command_line_tag ( self , tag : BoxedDst < CommandLineTag > ) -> Self {
215
+ pub fn command_line_tag ( self , tag : Box < CommandLineTag > ) -> Self {
215
216
self . add_tag ( & * tag) . unwrap ( )
216
217
}
217
218
@@ -247,19 +248,19 @@ impl InformationBuilder {
247
248
248
249
/// Adds a 'EFI Memory map' tag (represented by [`EFIMemoryMapTag`]) to the builder.
249
250
#[ 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 {
251
252
self . add_tag ( & * tag) . unwrap ( )
252
253
}
253
254
254
255
/// Adds a 'ELF-Symbols' tag (represented by [`ElfSectionsTag`]) to the builder.
255
256
#[ must_use]
256
- pub fn elf_sections_tag ( self , tag : BoxedDst < ElfSectionsTag > ) -> Self {
257
+ pub fn elf_sections_tag ( self , tag : Box < ElfSectionsTag > ) -> Self {
257
258
self . add_tag ( & * tag) . unwrap ( )
258
259
}
259
260
260
261
/// Adds a 'Framebuffer info' tag (represented by [`FramebufferTag`]) to the builder.
261
262
#[ must_use]
262
- pub fn framebuffer_tag ( self , tag : BoxedDst < FramebufferTag > ) -> Self {
263
+ pub fn framebuffer_tag ( self , tag : Box < FramebufferTag > ) -> Self {
263
264
self . add_tag ( & * tag) . unwrap ( )
264
265
}
265
266
@@ -271,14 +272,14 @@ impl InformationBuilder {
271
272
272
273
/// Adds a (*none EFI*) 'memory map' tag (represented by [`MemoryMapTag`]) to the builder.
273
274
#[ must_use]
274
- pub fn memory_map_tag ( self , tag : BoxedDst < MemoryMapTag > ) -> Self {
275
+ pub fn memory_map_tag ( self , tag : Box < MemoryMapTag > ) -> Self {
275
276
self . add_tag ( & * tag) . unwrap ( )
276
277
}
277
278
278
279
/// Adds a 'Modules' tag (represented by [`ModuleTag`]) to the builder.
279
280
/// This tag can occur multiple times in boot information.
280
281
#[ must_use]
281
- pub fn add_module_tag ( self , tag : BoxedDst < ModuleTag > ) -> Self {
282
+ pub fn add_module_tag ( self , tag : Box < ModuleTag > ) -> Self {
282
283
self . add_tag ( & * tag) . unwrap ( )
283
284
}
284
285
@@ -296,7 +297,7 @@ impl InformationBuilder {
296
297
297
298
/// Adds a 'SMBIOS tables' tag (represented by [`SmbiosTag`]) to the builder.
298
299
#[ must_use]
299
- pub fn smbios_tag ( self , tag : BoxedDst < SmbiosTag > ) -> Self {
300
+ pub fn smbios_tag ( self , tag : Box < SmbiosTag > ) -> Self {
300
301
self . add_tag ( & * tag) . unwrap ( )
301
302
}
302
303
@@ -309,7 +310,6 @@ impl InformationBuilder {
309
310
}
310
311
311
312
#[ cfg( test) ]
312
- #[ cfg( not( miri) ) ]
313
313
mod tests {
314
314
use crate :: builder:: information:: InformationBuilder ;
315
315
use crate :: { BasicMemoryInfoTag , BootInformation , CommandLineTag , ModuleTag } ;
@@ -353,7 +353,6 @@ mod tests {
353
353
}
354
354
355
355
#[ test]
356
- #[ cfg_attr( miri, ignore) ]
357
356
fn test_builder ( ) {
358
357
// Step 1/2: Build MBI
359
358
let mb2i_data = create_builder ( ) . build ( ) ;
0 commit comments