11//! Module for [`Builder`].
22
3+ use crate :: apm:: ApmTag ;
4+ use crate :: bootdev:: BootdevTag ;
5+ use crate :: network:: NetworkTag ;
36use crate :: {
47 BasicMemoryInfoTag , BootInformationHeader , BootLoaderNameTag , CommandLineTag ,
58 EFIBootServicesNotExitedTag , EFIImageHandle32Tag , EFIImageHandle64Tag , EFIMemoryMapTag ,
@@ -18,18 +21,18 @@ pub struct Builder {
1821 bootloader : Option < Box < BootLoaderNameTag > > ,
1922 modules : Vec < Box < ModuleTag > > ,
2023 meminfo : Option < BasicMemoryInfoTag > ,
21- // missing bootdev: Option<BootDevice>
24+ bootdev : Option < BootdevTag > ,
2225 mmap : Option < Box < MemoryMapTag > > ,
2326 vbe : Option < VBEInfoTag > ,
2427 framebuffer : Option < Box < FramebufferTag > > ,
2528 elf_sections : Option < Box < ElfSectionsTag > > ,
26- // missing apm:
29+ apm : Option < ApmTag > ,
2730 efi32 : Option < EFISdt32Tag > ,
2831 efi64 : Option < EFISdt64Tag > ,
2932 smbios : Vec < Box < SmbiosTag > > ,
3033 rsdpv1 : Option < RsdpV1Tag > ,
3134 rsdpv2 : Option < RsdpV2Tag > ,
32- // missing: network
35+ network : Option < Box < NetworkTag > > ,
3336 efi_mmap : Option < Box < EFIMemoryMapTag > > ,
3437 efi_bs : Option < EFIBootServicesNotExitedTag > ,
3538 efi32_ih : Option < EFIImageHandle32Tag > ,
@@ -53,16 +56,19 @@ impl Builder {
5356 bootloader : None ,
5457 modules : vec ! [ ] ,
5558 meminfo : None ,
59+ bootdev : None ,
5660 mmap : None ,
5761 vbe : None ,
5862 framebuffer : None ,
5963 elf_sections : None ,
64+ apm : None ,
6065 efi32 : None ,
6166 efi64 : None ,
6267 smbios : vec ! [ ] ,
6368 rsdpv1 : None ,
6469 rsdpv2 : None ,
6570 efi_mmap : None ,
71+ network : None ,
6672 efi_bs : None ,
6773 efi32_ih : None ,
6874 efi64_ih : None ,
@@ -99,6 +105,13 @@ impl Builder {
99105 self
100106 }
101107
108+ /// Sets the [`BootdevTag`] tag.
109+ #[ must_use]
110+ pub const fn bootdev ( mut self , bootdev : BootdevTag ) -> Self {
111+ self . bootdev = Some ( bootdev) ;
112+ self
113+ }
114+
102115 /// Sets the [`MemoryMapTag`] tag.
103116 #[ must_use]
104117 pub fn mmap ( mut self , mmap : Box < MemoryMapTag > ) -> Self {
@@ -127,6 +140,13 @@ impl Builder {
127140 self
128141 }
129142
143+ /// Sets the [`ApmTag`] tag.
144+ #[ must_use]
145+ pub const fn apm ( mut self , apm : ApmTag ) -> Self {
146+ self . apm = Some ( apm) ;
147+ self
148+ }
149+
130150 /// Sets the [`EFISdt32Tag`] tag.
131151 #[ must_use]
132152 pub const fn efi32 ( mut self , efi32 : EFISdt32Tag ) -> Self {
@@ -169,6 +189,13 @@ impl Builder {
169189 self
170190 }
171191
192+ /// Sets the [`NetworkTag`] tag.
193+ #[ must_use]
194+ pub fn network ( mut self , network : Box < NetworkTag > ) -> Self {
195+ self . network = Some ( network) ;
196+ self
197+ }
198+
172199 /// Sets the [`EFIBootServicesNotExitedTag`] tag.
173200 #[ must_use]
174201 pub const fn efi_bs ( mut self , efi_bs : EFIBootServicesNotExitedTag ) -> Self {
@@ -226,6 +253,9 @@ impl Builder {
226253 if let Some ( tag) = self . meminfo . as_ref ( ) {
227254 byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
228255 }
256+ if let Some ( tag) = self . bootdev . as_ref ( ) {
257+ byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
258+ }
229259 if let Some ( tag) = self . mmap . as_ref ( ) {
230260 byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
231261 }
@@ -238,6 +268,9 @@ impl Builder {
238268 if let Some ( tag) = self . elf_sections . as_ref ( ) {
239269 byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
240270 }
271+ if let Some ( tag) = self . apm . as_ref ( ) {
272+ byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
273+ }
241274 if let Some ( tag) = self . efi32 . as_ref ( ) {
242275 byte_refs. push ( tag. as_bytes ( ) . as_ref ( ) ) ;
243276 }
@@ -293,6 +326,7 @@ mod tests {
293326 . add_module ( ModuleTag :: new ( 0x1000 , 0x2000 , "module 1" ) )
294327 . add_module ( ModuleTag :: new ( 0x3000 , 0x4000 , "module 2" ) )
295328 . meminfo ( BasicMemoryInfoTag :: new ( 0x4000 , 0x5000 ) )
329+ . bootdev ( BootdevTag :: new ( 0x00 , 0x00 , 0x00 ) )
296330 . mmap ( MemoryMapTag :: new ( & [ MemoryArea :: new (
297331 0x1000000 ,
298332 0x1000 ,
@@ -316,6 +350,7 @@ mod tests {
316350 FramebufferType :: Text ,
317351 ) )
318352 . elf_sections ( ElfSectionsTag :: new ( 0 , 32 , 0 , & [ ] ) )
353+ . apm ( ApmTag :: new ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ) )
319354 . efi32 ( EFISdt32Tag :: new ( 0x1000 ) )
320355 . efi64 ( EFISdt64Tag :: new ( 0x1000 ) )
321356 . add_smbios ( SmbiosTag :: new ( 0 , 0 , & [ 1 , 2 , 3 ] ) )
@@ -326,6 +361,7 @@ mod tests {
326361 MemoryDescriptor :: default ( ) ,
327362 MemoryDescriptor :: default ( ) ,
328363 ] ) )
364+ . network ( NetworkTag :: new ( & [ 0 ; 1500 ] ) )
329365 . efi_bs ( EFIBootServicesNotExitedTag :: new ( ) )
330366 . efi32_ih ( EFIImageHandle32Tag :: new ( 0x1000 ) )
331367 . efi64_ih ( EFIImageHandle64Tag :: new ( 0x1000 ) )
0 commit comments