Expand description

Library with type definitions and parsing functions for Multiboot2 headers. This library is no_std and can be used in bootloaders.

Example

use multiboot2_header::builder::{InformationRequestHeaderTagBuilder, Multiboot2HeaderBuilder};
use multiboot2_header::{HeaderTagFlag, HeaderTagISA, MbiTagType, RelocatableHeaderTag, RelocatableHeaderTagPreference, Multiboot2Header};

// Small example that creates a Multiboot2 header and parses it afterwards.

// We create a Multiboot2 header during runtime here. A practical example is that your
// program gets the header from a file and parses it afterwards.
let mb2_hdr_bytes = Multiboot2HeaderBuilder::new(HeaderTagISA::I386)
    .relocatable_tag(RelocatableHeaderTag::new(
        HeaderTagFlag::Required,
        0x1337,
        0xdeadbeef,
        4096,
        RelocatableHeaderTagPreference::None,
    ))
    .information_request_tag(
        InformationRequestHeaderTagBuilder::new(HeaderTagFlag::Required)
            .add_irs(&[MbiTagType::Cmdline, MbiTagType::BootLoaderName]),
    )
    .build();

// Cast bytes in vector to Multiboot2 information structure
let mb2_hdr = unsafe { Multiboot2Header::from_addr(mb2_hdr_bytes.as_ptr() as usize) };
println!("{:#?}", mb2_hdr);

MSRV

The MSRV is 1.52.1 stable.

Modules

Module for the builder-feature.

Structs

This information does not need to be provided if the kernel image is in ELF format, but it must be provided if the image is in a.out format or in some other format. Required for legacy boot (BIOS). Determines load addresses.

Tells that a console must be available in MBI. Only relevant for legacy BIOS.

This tag indicates that payload supports starting without terminating UEFI boot services. Or in other words: The payload wants to use UEFI boot services.

Terminates a list of optional tags in a Multiboot2 header.

Specifies the physical address to which the boot loader should jump in order to start running the operating system. Not needed for ELF files.

This tag is taken into account only on EFI i386 platforms when Multiboot2 image header contains EFI boot services tag. Then entry point specified in ELF header and the entry address tag of Multiboot2 header are ignored.

This tag is taken into account only on EFI amd64 platforms when Multiboot2 image header contains EFI boot services tag. Then entry point specified in ELF header and the entry address tag of Multiboot2 header are ignored.

Specifies the preferred graphics mode. If this tag is present the bootloader assumes that the payload has framebuffer support. Note: This is only a recommended mode. Only relevant on legacy BIOS.

Common properties for all header tags. Other tags may have additional fields that depend on the typ and the size field. All tags share the same beginning of the struct.

Specifies what specific tag types the bootloader should provide inside the mbi.

Iterates the dynamically sized information request structure and finds all MBI tags that are requested.

If this tag is present, provided boot modules must be page aligned.

Use this only if you know what you do. You probably want to use Multiboot2Header instead.

Wrapper type around a pointer to the Multiboot2 header. The Multiboot2 header is the Multiboot2BasicHeader followed by all tags (see crate::tags::HeaderTagType). Use this if you get a pointer to the header and just want to parse it. If you want to construct the type by yourself, please look at crate::builder::Multiboot2HeaderBuilder.

Iterator over all tags of a Multiboot2 header. The number of items is derived by the size/length of the header.

This tag indicates that the image is relocatable.

Enums

Flags for Multiboot2 header tags.

ISA/ARCH in Multiboot2 header.

Possible types for header tags of a Multiboot2 header. The names and values are taken from the example C code at the bottom of the Multiboot2 specification. This value stands in the typ property of crate::tags::HeaderTag.

Re-export of multiboot2::TagType from multiboot2-crate as MbiTagType, i.e. tags that describe the entries in the Multiboot2 Information Structure (MBI). Possible types of a Tag in the Multiboot2 Information Structure (MBI), therefore the value of the the typ property. The names and values are taken from the example C code at the bottom of the Multiboot2 specification.

It contains load address placement suggestion for boot loader. Boot loader should follow it. ‘0’ means none, ‘1’ means load image at lowest possible address but not lower than min addr and ‘2’ means load image at highest possible address but not higher than max addr.

Constants

Magic value for a Multiboot2Header, as defined in spec.