33[ ![ crates.io] ( https://img.shields.io/crates/v/multiboot2-header.svg )] ( https://crates.io/crates/multiboot2-header )
44[ ![ docs] ( https://docs.rs/multiboot2-header/badge.svg )] ( https://docs.rs/multiboot2-header/ )
55
6- Rust library with type definitions and parsing functions for Multiboot2 headers.
7- This library is ` no_std ` and can be used in bootloaders.
6+ Rust library with type definitions and parsing functions for Multiboot2 headers,
7+ as well as a builder to build them at runtime. This library is ` no_std ` and can
8+ be used in bootloaders.
89
910What this library is good for:
10- - writing a small binary which writes you a valid Multiboot2 header
11- into a file (such as ` header.bin ` )
11+ - construct a Multiboot2 header at runtime (constructing one at build-time with
12+ macros is not done yet, contributions are welcome!)
13+ - write a Multiboot2-bootloader that parses a Multiboot2-header
1214- understanding Multiboot2 headers better
1315- analyze Multiboot2 headers at runtime
1416
15- What this library is not optimal for:
16- - compiling a Multiboot2 header statically into an object file using only Rust code
17-
1817## Features and ` no_std ` Compatibility
18+
1919This library is always ` no_std ` without ` alloc ` . However, the default ` builder ` -
2020feature requires the ` alloc ` -crate and an ` #[global_allocator] ` to be available.
2121You need the ` builder ` only if you want to construct new headers at runtime.
22- For parsing, this is not relevant, and you can deactivate the default feature .
22+ For parsing, the feature is not relevant, and you can deactivate it .
2323
2424``` toml
2525# without `builder`-feature (and without `alloc`-crate)
@@ -29,6 +29,7 @@ multiboot2-header = "<latest>"
2929```
3030
3131## Example 1: Builder + Parse
32+
3233``` rust
3334use multiboot2_header :: builder :: {InformationRequestHeaderTagBuilder , Multiboot2HeaderBuilder };
3435use multiboot2_header :: {HeaderTagFlag , HeaderTagISA , MbiTagType , RelocatableHeaderTag , RelocatableHeaderTagPreference , Multiboot2Header };
@@ -58,17 +59,19 @@ fn main() {
5859```
5960
6061## Example 2: Multiboot2 header as static data in Rust file
62+
6163You can use the builder, construct a Multiboot2 header, write it to a file and include it like this:
6264```
6365#[used]
6466#[no_mangle]
6567#[link_section = ".text.multiboot2_header"]
66- static MULTIBOOT2_HDR: & [u8; 64] = include_bytes!("mb2_hdr_dump.bin");
68+ static MULTIBOOT2_HDR: [u8; 64] = * include_bytes!("mb2_hdr_dump.bin");
6769```
68- You may need a special linker script to place this in a LOAD segment with a file offset with less than 32768 bytes.
69- See specification.
70+ You may need a special linker script to place this symbol in the first 32768
71+ bytes of the ELF. See Multiboot2 specification.
7072
7173## MSRV
74+
7275The MSRV is 1.69.0 stable.
7376
7477## License & Contribution
0 commit comments