3
3
[ ![ crates.io] ( https://img.shields.io/crates/v/multiboot2-header.svg )] ( https://crates.io/crates/multiboot2-header )
4
4
[ ![ docs] ( https://docs.rs/multiboot2-header/badge.svg )] ( https://docs.rs/multiboot2-header/ )
5
5
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.
8
9
9
10
What 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
12
14
- understanding Multiboot2 headers better
13
15
- analyze Multiboot2 headers at runtime
14
16
15
- What this library is not optimal for:
16
- - compiling a Multiboot2 header statically into an object file using only Rust code
17
-
18
17
## Features and ` no_std ` Compatibility
18
+
19
19
This library is always ` no_std ` without ` alloc ` . However, the default ` builder ` -
20
20
feature requires the ` alloc ` -crate and an ` #[global_allocator] ` to be available.
21
21
You 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 .
23
23
24
24
``` toml
25
25
# without `builder`-feature (and without `alloc`-crate)
@@ -29,6 +29,7 @@ multiboot2-header = "<latest>"
29
29
```
30
30
31
31
## Example 1: Builder + Parse
32
+
32
33
``` rust
33
34
use multiboot2_header :: builder :: {InformationRequestHeaderTagBuilder , Multiboot2HeaderBuilder };
34
35
use multiboot2_header :: {HeaderTagFlag , HeaderTagISA , MbiTagType , RelocatableHeaderTag , RelocatableHeaderTagPreference , Multiboot2Header };
@@ -58,17 +59,19 @@ fn main() {
58
59
```
59
60
60
61
## Example 2: Multiboot2 header as static data in Rust file
62
+
61
63
You can use the builder, construct a Multiboot2 header, write it to a file and include it like this:
62
64
```
63
65
#[used]
64
66
#[no_mangle]
65
67
#[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");
67
69
```
68
70
You may need a special linker script to place this in a LOAD segment with a file offset with less than 32768 bytes.
69
71
See specification.
70
72
71
73
## MSRV
74
+
72
75
The MSRV is 1.69.0 stable.
73
76
74
77
## License & Contribution
0 commit comments