|
@@ -3,23 +3,23 @@
|
|
|
[](https://crates.io/crates/multiboot2-header)
|
|
|
[](https://docs.rs/multiboot2-header/)
|
|
|
|
|
|
-Rust library with type definitions and parsing functions for Multiboot2 headers.
|
|
|
-This library is `no_std` and can be used in bootloaders.
|
|
|
+Rust library with type definitions and parsing functions for Multiboot2 headers,
|
|
|
+as well as a builder to build them at runtime. This library is `no_std` and can
|
|
|
+be used in bootloaders.
|
|
|
|
|
|
What this library is good for:
|
|
|
-- writing a small binary which writes you a valid Multiboot2 header
|
|
|
- into a file (such as `header.bin`)
|
|
|
+- construct a Multiboot2 header at runtime (constructing one at build-time with
|
|
|
+ macros is not done yet, contributions are welcome!)
|
|
|
+- write a Multiboot2-bootloader that parses a Multiboot2-header
|
|
|
- understanding Multiboot2 headers better
|
|
|
- analyze Multiboot2 headers at runtime
|
|
|
|
|
|
-What this library is not optimal for:
|
|
|
-- compiling a Multiboot2 header statically into an object file using only Rust code
|
|
|
-
|
|
|
## Features and `no_std` Compatibility
|
|
|
+
|
|
|
This library is always `no_std` without `alloc`. However, the default `builder`-
|
|
|
feature requires the `alloc`-crate and an `#[global_allocator]` to be available.
|
|
|
You need the `builder` only if you want to construct new headers at runtime.
|
|
|
-For parsing, this is not relevant, and you can deactivate the default feature.
|
|
|
+For parsing, the feature is not relevant, and you can deactivate it.
|
|
|
|
|
|
```toml
|
|
|
# without `builder`-feature (and without `alloc`-crate)
|
|
@@ -29,6 +29,7 @@ multiboot2-header = "<latest>"
|
|
|
```
|
|
|
|
|
|
## Example 1: Builder + Parse
|
|
|
+
|
|
|
```rust
|
|
|
use multiboot2_header::builder::{InformationRequestHeaderTagBuilder, Multiboot2HeaderBuilder};
|
|
|
use multiboot2_header::{HeaderTagFlag, HeaderTagISA, MbiTagType, RelocatableHeaderTag, RelocatableHeaderTagPreference, Multiboot2Header};
|
|
@@ -58,17 +59,19 @@ fn main() {
|
|
|
```
|
|
|
|
|
|
## Example 2: Multiboot2 header as static data in Rust file
|
|
|
+
|
|
|
You can use the builder, construct a Multiboot2 header, write it to a file and include it like this:
|
|
|
```
|
|
|
#[used]
|
|
|
#[no_mangle]
|
|
|
#[link_section = ".text.multiboot2_header"]
|
|
|
-static MULTIBOOT2_HDR: &[u8; 64] = include_bytes!("mb2_hdr_dump.bin");
|
|
|
+static MULTIBOOT2_HDR: [u8; 64] = *include_bytes!("mb2_hdr_dump.bin");
|
|
|
```
|
|
|
-You may need a special linker script to place this in a LOAD segment with a file offset with less than 32768 bytes.
|
|
|
-See specification.
|
|
|
+You may need a special linker script to place this symbol in the first 32768
|
|
|
+bytes of the ELF. See Multiboot2 specification.
|
|
|
|
|
|
## MSRV
|
|
|
+
|
|
|
The MSRV is 1.69.0 stable.
|
|
|
|
|
|
## License & Contribution
|