Crate multiboot2

Source
Expand description

Convenient and safe parsing of Multiboot2 Boot Information (MBI) structures and the contained information tags. Usable in no_std environments, such as a kernel. An optional builder feature also allows the construction of the corresponding structures.

§Design

For every Multiboot2 structure, there is an ABI-compatible rusty type. This enables a zero-copying parsing design while also enabling the creation of these structures via convenient constructors on the corresponding types.

§Example

use multiboot2::{BootInformation, BootInformationHeader};

fn kernel_entry(mb_magic: u32, mbi_ptr: u32) {
    if mb_magic == multiboot2::MAGIC {
        let boot_info = unsafe { BootInformation::load(mbi_ptr as *const BootInformationHeader).unwrap() };
        let _cmd = boot_info.command_line_tag();
    } else { /* Panic or use multiboot1 flow. */ }
}

§MSRV

The MSRV is 1.75.0 stable.

Structs§

ApmTag
The Advanced Power Management (APM) tag.
BasicMemoryInfoTag
Basic memory info tag.
BootInformation
A Multiboot 2 Boot Information (MBI) accessor.
BootInformationHeader
The basic header of a BootInformation as sized Rust type.
BootLoaderNameTag
The bootloader name tag.
BootdevTag
The end tag ends the information struct.
Builder
Builder for a Multiboot2 header information.
CommandLineTag
This tag contains the command line string.
DynSizedStructure
An C ABI-compatible dynamically sized type with a common sized Header and a dynamic amount of bytes without hidden implicit padding.
EFIBootServicesNotExitedTag
EFI ExitBootServices was not called tag. This tag has no payload and is just a marker.
EFIImageHandle32Tag
Tag that contains the pointer to the boot loader’s UEFI image handle (32-bit).
EFIImageHandle64Tag
Tag that contains the pointer to the boot loader’s UEFI image handle (64-bit).
EFIMemoryAreaType
The type of a memory range.
EFIMemoryAttribute
Flags describing the capabilities of a memory range.
EFIMemoryDesc
A structure describing a region of memory. This type corresponds to version of this struct in the UEFI spec and is always bound to a corresponding UEFI memory map.
EFIMemoryMapTag
EFI memory map tag. The embedded EFIMemoryDescs follows the EFI specification.
EFISdt32Tag
EFI system table in 32 bit mode tag.
EFISdt64Tag
EFI system table in 64 bit mode tag.
ElfSection
A single generic ELF Section.
ElfSectionFlags
ELF Section bitflags.
ElfSectionIter
An iterator over ElfSections.
ElfSectionsTag
This tag contains the section header table from an ELF binary.
EndTag
The end tag ends the information struct.
FramebufferColor
A framebuffer color descriptor in the palette.
FramebufferField
An RGB color type field.
FramebufferTag
The VBE Framebuffer information tag.
ImageLoadPhysAddrTag
The physical load address tag. Typically, this is only available if the binary was relocated, for example if the relocatable header tag was specified.
MemoryArea
A descriptor for an available or taken area of physical memory.
MemoryAreaTypeId
ABI-friendly version of MemoryAreaType.
MemoryMapTag
This tag provides an initial host memory map (legacy boot, not UEFI).
ModuleIter
An iterator over all module tags.
ModuleTag
The module tag can occur multiple times and specifies passed boot modules (blobs in memory). The tag itself doesn’t include the blog, but references its location.
NetworkTag
The end tag ends the information struct.
RsdpV1Tag
This tag contains a copy of RSDP as defined per ACPI 1.0 specification.
RsdpV2Tag
This tag contains a copy of RSDP as defined per ACPI 2.0 or later specification.
SmbiosTag
This tag contains a copy of SMBIOS tables as well as their version.
TagHeader
The common header that all tags have in common. This type is ABI compatible.
TagTypeId
Serialized form of TagType that matches the binary representation (u32).
VBECapabilities
The Capabilities field indicates the support of specific features in the graphics environment.
VBEControlInfo
VBE controller information.
VBEDirectColorAttributes
The DirectColorModeInfo field describes important characteristics of direct color modes.
VBEField
A VBE colour field.
VBEInfoTag
This tag contains VBE metadata, VBE controller information returned by the VBE Function 00h and VBE mode information returned by the VBE Function 01h.
VBEModeAttributes
A Mode attributes bitfield.
VBEModeInfo
Extended information about a specific VBE display mode from the mode list returned by VBEControlInfo (VBE Function 00h).
VBEWindowAttributes
The WindowAttributes describe the characteristics of the CPU windowing scheme such as whether the windows exist and are read/writeable, as follows:

Enums§

ElfSectionType
An enum abstraction over raw ELF section types.
FramebufferType
Structured accessory to the provided framebuffer type that is not ABI compatible.
LoadError
Errors that occur when a chunk of memory can’t be parsed as BootInformation.
MemoryAreaType
Abstraction over defined memory types for the memory map as well as custom ones. Types 1 to 5 are defined in the Multiboot2 spec and correspond to the entry types of e820 memory maps.
StringError
Error type describing failures when parsing the string from a tag.
TagType
Higher level abstraction for TagTypeId that assigns each possible value to a specific semantic according to the specification.
VBEMemoryModel
The MemoryModel field specifies the general type of memory organization used in modes.

Constants§

MAGIC
Magic number that a Multiboot2-compliant boot loader will use to identify the handoff. The location depends on the architecture and the targeted machine state.

Traits§

MaybeDynSized
A trait to abstract sized and unsized structures (DSTs). It enables casting a DynSizedStructure to sized or unsized structures using DynSizedStructure::cast.
Pointee
Provides the pointer metadata type of any pointed-to type.
Tag
Extension of MaybeDynSized for Tags.

Functions§

parse_slice_as_string
Parses the provided byte sequence as Multiboot string, which maps to a str.

Type Aliases§

TagIter
Iterator over the tags of a Multiboot2 boot information.

Derive Macros§

Pointee
Generates an implementation of Pointee for structs with a DST as its last field.