11//! Module for [`Builder`].
22
33use crate :: apm:: ApmTag ;
4+ use crate :: bootdev:: BootdevTag ;
45use crate :: {
56 BasicMemoryInfoTag , BootInformationHeader , BootLoaderNameTag , CommandLineTag ,
67 EFIBootServicesNotExitedTag , EFIImageHandle32Tag , EFIImageHandle64Tag , EFIMemoryMapTag ,
@@ -19,7 +20,7 @@ pub struct Builder {
1920 bootloader : Option < Box < BootLoaderNameTag > > ,
2021 modules : Vec < Box < ModuleTag > > ,
2122 meminfo : Option < BasicMemoryInfoTag > ,
22- // missing bootdev: Option<BootDevice>
23+ bootdev : Option < BootdevTag > ,
2324 mmap : Option < Box < MemoryMapTag > > ,
2425 vbe : Option < VBEInfoTag > ,
2526 framebuffer : Option < Box < FramebufferTag > > ,
@@ -54,6 +55,7 @@ impl Builder {
5455 bootloader : None ,
5556 modules : vec ! [ ] ,
5657 meminfo : None ,
58+ bootdev : None ,
5759 mmap : None ,
5860 vbe : None ,
5961 framebuffer : None ,
@@ -101,6 +103,13 @@ impl Builder {
101103 self
102104 }
103105
106+ /// Sets the [`BootdevTag`] tag.
107+ #[ must_use]
108+ pub const fn bootdev ( mut self , bootdev : BootdevTag ) -> Self {
109+ self . bootdev = Some ( bootdev) ;
110+ self
111+ }
112+
104113 /// Sets the [`MemoryMapTag`] tag.
105114 #[ must_use]
106115 pub fn mmap ( mut self , mmap : Box < MemoryMapTag > ) -> Self {
@@ -131,7 +140,7 @@ impl Builder {
131140
132141 /// Sets the [`ApmTag`] tag.
133142 #[ must_use]
134- pub fn apm ( mut self , apm : ApmTag ) -> Self {
143+ pub const fn apm ( mut self , apm : ApmTag ) -> Self {
135144 self . apm = Some ( apm) ;
136145 self
137146 }
@@ -223,9 +232,6 @@ impl Builder {
223232 pub fn build ( self ) -> Box < DynSizedStructure < BootInformationHeader > > {
224233 let header = BootInformationHeader :: new ( 0 ) ;
225234 let mut byte_refs = Vec :: new ( ) ;
226- if let Some ( tag) = self . apm . as_ref ( ) {
227- byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
228- }
229235 if let Some ( tag) = self . cmdline . as_ref ( ) {
230236 byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
231237 }
@@ -238,6 +244,9 @@ impl Builder {
238244 if let Some ( tag) = self . meminfo . as_ref ( ) {
239245 byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
240246 }
247+ if let Some ( tag) = self . bootdev . as_ref ( ) {
248+ byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
249+ }
241250 if let Some ( tag) = self . mmap . as_ref ( ) {
242251 byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
243252 }
@@ -308,6 +317,7 @@ mod tests {
308317 . add_module ( ModuleTag :: new ( 0x1000 , 0x2000 , "module 1" ) )
309318 . add_module ( ModuleTag :: new ( 0x3000 , 0x4000 , "module 2" ) )
310319 . meminfo ( BasicMemoryInfoTag :: new ( 0x4000 , 0x5000 ) )
320+ . bootdev ( BootdevTag :: new ( 0x00 , 0x00 , 0x00 ) )
311321 . mmap ( MemoryMapTag :: new ( & [ MemoryArea :: new (
312322 0x1000000 ,
313323 0x1000 ,
@@ -331,6 +341,7 @@ mod tests {
331341 FramebufferType :: Text ,
332342 ) )
333343 . elf_sections ( ElfSectionsTag :: new ( 0 , 32 , 0 , & [ ] ) )
344+ . apm ( ApmTag :: new ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) )
334345 . efi32 ( EFISdt32Tag :: new ( 0x1000 ) )
335346 . efi64 ( EFISdt64Tag :: new ( 0x1000 ) )
336347 . add_smbios ( SmbiosTag :: new ( 0 , 0 , & [ 1 , 2 , 3 ] ) )
@@ -341,6 +352,7 @@ mod tests {
341352 MemoryDescriptor :: default ( ) ,
342353 MemoryDescriptor :: default ( ) ,
343354 ] ) )
355+ . network ( NetworkTag :: new ( & [ 0 ; 1500 ] ) )
344356 . efi_bs ( EFIBootServicesNotExitedTag :: new ( ) )
345357 . efi32_ih ( EFIImageHandle32Tag :: new ( 0x1000 ) )
346358 . efi64_ih ( EFIImageHandle64Tag :: new ( 0x1000 ) )
0 commit comments