pub struct Builder { /* private fields */ }
Expand description
Builder for a Multiboot2 header information.
Implementations§
Source§impl Builder
impl Builder
Sourcepub const fn new(arch: HeaderTagISA) -> Self
pub const fn new(arch: HeaderTagISA) -> Self
Set the RelocatableHeaderTag
tag.
Examples found in repository?
examples/minimal.rs (line 13)
9fn main() {
10 // We create a Multiboot2 header during runtime here. A more practical
11 // example, however, would be that you parse the header from kernel binary
12 // at runtime.
13 let mb2_hdr_bytes = Builder::new(HeaderTagISA::I386)
14 .relocatable_tag(RelocatableHeaderTag::new(
15 HeaderTagFlag::Required,
16 0x1337,
17 0xdeadbeef,
18 4096,
19 RelocatableHeaderTagPreference::None,
20 ))
21 .information_request_tag(InformationRequestHeaderTag::new(
22 HeaderTagFlag::Required,
23 &[
24 MbiTagType::Cmdline.into(),
25 MbiTagType::BootLoaderName.into(),
26 ],
27 ))
28 .build();
29
30 // Cast bytes in vector to Multiboot2 information structure
31 let ptr = mb2_hdr_bytes.as_bytes().as_ptr();
32 let mb2_hdr = unsafe { Multiboot2Header::load(ptr.cast()) };
33 let mb2_hdr = mb2_hdr.unwrap();
34 println!("{mb2_hdr:#?}");
35}
Sourcepub fn information_request_tag(
self,
information_request_tag: Box<InformationRequestHeaderTag>,
) -> Self
pub fn information_request_tag( self, information_request_tag: Box<InformationRequestHeaderTag>, ) -> Self
Set the InformationRequestHeaderTag
tag.
Examples found in repository?
examples/minimal.rs (lines 21-27)
9fn main() {
10 // We create a Multiboot2 header during runtime here. A more practical
11 // example, however, would be that you parse the header from kernel binary
12 // at runtime.
13 let mb2_hdr_bytes = Builder::new(HeaderTagISA::I386)
14 .relocatable_tag(RelocatableHeaderTag::new(
15 HeaderTagFlag::Required,
16 0x1337,
17 0xdeadbeef,
18 4096,
19 RelocatableHeaderTagPreference::None,
20 ))
21 .information_request_tag(InformationRequestHeaderTag::new(
22 HeaderTagFlag::Required,
23 &[
24 MbiTagType::Cmdline.into(),
25 MbiTagType::BootLoaderName.into(),
26 ],
27 ))
28 .build();
29
30 // Cast bytes in vector to Multiboot2 information structure
31 let ptr = mb2_hdr_bytes.as_bytes().as_ptr();
32 let mb2_hdr = unsafe { Multiboot2Header::load(ptr.cast()) };
33 let mb2_hdr = mb2_hdr.unwrap();
34 println!("{mb2_hdr:#?}");
35}
Sourcepub const fn address_tag(self, address_tag: AddressHeaderTag) -> Self
pub const fn address_tag(self, address_tag: AddressHeaderTag) -> Self
Set the AddressHeaderTag
tag.
Sourcepub const fn entry_tag(self, entry_tag: EntryAddressHeaderTag) -> Self
pub const fn entry_tag(self, entry_tag: EntryAddressHeaderTag) -> Self
Set the EntryAddressHeaderTag
tag.
Sourcepub const fn console_tag(self, console_tag: ConsoleHeaderTag) -> Self
pub const fn console_tag(self, console_tag: ConsoleHeaderTag) -> Self
Set the ConsoleHeaderTag
tag.
Sourcepub const fn framebuffer_tag(
self,
framebuffer_tag: FramebufferHeaderTag,
) -> Self
pub const fn framebuffer_tag( self, framebuffer_tag: FramebufferHeaderTag, ) -> Self
Set the FramebufferHeaderTag
tag.
Sourcepub const fn module_align_tag(
self,
module_align_tag: ModuleAlignHeaderTag,
) -> Self
pub const fn module_align_tag( self, module_align_tag: ModuleAlignHeaderTag, ) -> Self
Set the ModuleAlignHeaderTag
tag.
Sourcepub const fn efi_bs_tag(self, efi_bs_tag: EfiBootServiceHeaderTag) -> Self
pub const fn efi_bs_tag(self, efi_bs_tag: EfiBootServiceHeaderTag) -> Self
Set the EfiBootServiceHeaderTag
tag.
Sourcepub const fn efi_32_tag(self, efi_32_tag: EntryEfi32HeaderTag) -> Self
pub const fn efi_32_tag(self, efi_32_tag: EntryEfi32HeaderTag) -> Self
Set the EntryEfi32HeaderTag
tag.
Sourcepub const fn efi_64_tag(self, efi_64_tag: EntryEfi64HeaderTag) -> Self
pub const fn efi_64_tag(self, efi_64_tag: EntryEfi64HeaderTag) -> Self
Set the EntryEfi64HeaderTag
tag.
Sourcepub const fn relocatable_tag(
self,
relocatable_tag: RelocatableHeaderTag,
) -> Self
pub const fn relocatable_tag( self, relocatable_tag: RelocatableHeaderTag, ) -> Self
Set the RelocatableHeaderTag
tag.
Examples found in repository?
examples/minimal.rs (lines 14-20)
9fn main() {
10 // We create a Multiboot2 header during runtime here. A more practical
11 // example, however, would be that you parse the header from kernel binary
12 // at runtime.
13 let mb2_hdr_bytes = Builder::new(HeaderTagISA::I386)
14 .relocatable_tag(RelocatableHeaderTag::new(
15 HeaderTagFlag::Required,
16 0x1337,
17 0xdeadbeef,
18 4096,
19 RelocatableHeaderTagPreference::None,
20 ))
21 .information_request_tag(InformationRequestHeaderTag::new(
22 HeaderTagFlag::Required,
23 &[
24 MbiTagType::Cmdline.into(),
25 MbiTagType::BootLoaderName.into(),
26 ],
27 ))
28 .build();
29
30 // Cast bytes in vector to Multiboot2 information structure
31 let ptr = mb2_hdr_bytes.as_bytes().as_ptr();
32 let mb2_hdr = unsafe { Multiboot2Header::load(ptr.cast()) };
33 let mb2_hdr = mb2_hdr.unwrap();
34 println!("{mb2_hdr:#?}");
35}
Sourcepub fn build(self) -> Box<DynSizedStructure<Multiboot2BasicHeader>>
pub fn build(self) -> Box<DynSizedStructure<Multiboot2BasicHeader>>
Returns properly aligned bytes on the heap representing a valid Multiboot2 header structure.
Examples found in repository?
examples/minimal.rs (line 28)
9fn main() {
10 // We create a Multiboot2 header during runtime here. A more practical
11 // example, however, would be that you parse the header from kernel binary
12 // at runtime.
13 let mb2_hdr_bytes = Builder::new(HeaderTagISA::I386)
14 .relocatable_tag(RelocatableHeaderTag::new(
15 HeaderTagFlag::Required,
16 0x1337,
17 0xdeadbeef,
18 4096,
19 RelocatableHeaderTagPreference::None,
20 ))
21 .information_request_tag(InformationRequestHeaderTag::new(
22 HeaderTagFlag::Required,
23 &[
24 MbiTagType::Cmdline.into(),
25 MbiTagType::BootLoaderName.into(),
26 ],
27 ))
28 .build();
29
30 // Cast bytes in vector to Multiboot2 information structure
31 let ptr = mb2_hdr_bytes.as_bytes().as_ptr();
32 let mb2_hdr = unsafe { Multiboot2Header::load(ptr.cast()) };
33 let mb2_hdr = mb2_hdr.unwrap();
34 println!("{mb2_hdr:#?}");
35}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more