pub struct Builder { /* private fields */ }Expand description
Builder for a Multiboot2 header.
Implementations§
Source§impl Builder
impl Builder
Sourcepub const fn new(arch: HeaderTagISA) -> Self
pub const fn new(arch: HeaderTagISA) -> Self
Creates a new builder for the specified architecture.
Examples found in repository?
examples/minimal.rs (line 11)
7fn main() {
8 // We create a Multiboot2 header during runtime here. A more practical
9 // example, however, would be that you parse the header from kernel binary
10 // at runtime.
11 let header_bytes = Builder::new(HeaderTagISA::I386)
12 .relocatable_tag(RelocatableHeaderTag::new(
13 HeaderTagFlag::Required,
14 0x1337,
15 0xdeadbeef,
16 4096,
17 RelocatableHeaderTagPreference::None,
18 ))
19 .information_request_tag(InformationRequestHeaderTag::new(
20 HeaderTagFlag::Required,
21 &[
22 MbiTagType::Cmdline.into(),
23 MbiTagType::BootLoaderName.into(),
24 ],
25 ))
26 .build();
27
28 let header = unsafe { Header::load(header_bytes.as_ptr()) }.unwrap();
29 println!("{header:#?}");
30}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 19-25)
7fn main() {
8 // We create a Multiboot2 header during runtime here. A more practical
9 // example, however, would be that you parse the header from kernel binary
10 // at runtime.
11 let header_bytes = Builder::new(HeaderTagISA::I386)
12 .relocatable_tag(RelocatableHeaderTag::new(
13 HeaderTagFlag::Required,
14 0x1337,
15 0xdeadbeef,
16 4096,
17 RelocatableHeaderTagPreference::None,
18 ))
19 .information_request_tag(InformationRequestHeaderTag::new(
20 HeaderTagFlag::Required,
21 &[
22 MbiTagType::Cmdline.into(),
23 MbiTagType::BootLoaderName.into(),
24 ],
25 ))
26 .build();
27
28 let header = unsafe { Header::load(header_bytes.as_ptr()) }.unwrap();
29 println!("{header:#?}");
30}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 12-18)
7fn main() {
8 // We create a Multiboot2 header during runtime here. A more practical
9 // example, however, would be that you parse the header from kernel binary
10 // at runtime.
11 let header_bytes = Builder::new(HeaderTagISA::I386)
12 .relocatable_tag(RelocatableHeaderTag::new(
13 HeaderTagFlag::Required,
14 0x1337,
15 0xdeadbeef,
16 4096,
17 RelocatableHeaderTagPreference::None,
18 ))
19 .information_request_tag(InformationRequestHeaderTag::new(
20 HeaderTagFlag::Required,
21 &[
22 MbiTagType::Cmdline.into(),
23 MbiTagType::BootLoaderName.into(),
24 ],
25 ))
26 .build();
27
28 let header = unsafe { Header::load(header_bytes.as_ptr()) }.unwrap();
29 println!("{header:#?}");
30}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 26)
7fn main() {
8 // We create a Multiboot2 header during runtime here. A more practical
9 // example, however, would be that you parse the header from kernel binary
10 // at runtime.
11 let header_bytes = Builder::new(HeaderTagISA::I386)
12 .relocatable_tag(RelocatableHeaderTag::new(
13 HeaderTagFlag::Required,
14 0x1337,
15 0xdeadbeef,
16 4096,
17 RelocatableHeaderTagPreference::None,
18 ))
19 .information_request_tag(InformationRequestHeaderTag::new(
20 HeaderTagFlag::Required,
21 &[
22 MbiTagType::Cmdline.into(),
23 MbiTagType::BootLoaderName.into(),
24 ],
25 ))
26 .build();
27
28 let header = unsafe { Header::load(header_bytes.as_ptr()) }.unwrap();
29 println!("{header:#?}");
30}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 UnsafeUnpin 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