Skip to content

Commit 813aa19

Browse files
authored
Merge pull request #87 from rust-osdev/cargo-toml-prepare-relase-v0.12
Cargo toml prepare relase v0.12 + changelog
2 parents 98ade37 + c2a0fe9 commit 813aa19

File tree

4 files changed

+72
-55
lines changed

4 files changed

+72
-55
lines changed

Cargo.toml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
[package]
22
name = "multiboot2"
3-
version = "0.11.0"
4-
authors = ["Philipp Oppermann <[email protected]>", "Calvin Lee <[email protected]>", "Isaac Woods"]
3+
description = """
4+
Library that helps you to parse the multiboot information structure (mbi) from
5+
Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the specification
6+
including full support for the sections of ELF-64. This library is `no_std` and can be
7+
used in a Multiboot2-kernel.
8+
"""
9+
version = "0.12.0"
10+
authors = [
11+
"Philipp Oppermann <[email protected]>",
12+
"Calvin Lee <[email protected]>",
13+
"Isaac Woods",
14+
"Philipp Schuster <[email protected]>"
15+
]
516
license = "MIT/Apache-2.0"
6-
description = "An experimental Multiboot 2 crate for ELF-64/32 kernels."
7-
repository = "https://github.com/rust-osdev/multiboot2-elf64"
817
edition = "2018"
18+
categories = [
19+
"parsing",
20+
]
21+
keywords = [
22+
"Multiboot2",
23+
"kernel",
24+
"boot",
25+
]
26+
# without this, sometimes crates.io doesn't show the preview of the README
27+
# I expeciended this multiple times in the past
28+
readme = "README.md"
29+
homepage = "https://github.com/rust-osdev/multiboot2"
30+
repository = "https://github.com/rust-osdev/multiboot2"
31+
documentation = "https://docs.rs/multiboot2"
932

1033
[dependencies]
1134
bitflags = "1"

Changelog.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# 0.12.0
2+
3+
- **breaking:** `load()` and `load_with_offset` now returns a result
4+
- added public constant `MULTIBOOT2_BOOTLOADER_MAGIC`
5+
- Rust edition 2018 (instead of 2015)
6+
- internal code improvements
7+
8+
# 0.11.0
9+
10+
- lib now contains public `TagType`-enum that contains
11+
all possible mbi tags that are specified (taken from spec)
12+
- much improved debug-formatting of `BootInformation`
13+
- internal code improvements / formatting
14+
15+
# 0.10.0
16+
- allow access to all memory regions (MemoryMap-Tag)
17+
- internal code improvements
18+
119
# 0.9.0
220

321
- Add a `checksum_is_valid` method to the RSDP tags ([#64](https://github.com/rust-osdev/multiboot2-elf64/pull/64))

README.md

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
[![crates.io](https://img.shields.io/crates/v/multiboot2.svg)](https://crates.io/crates/multiboot2)
44
[![docs](https://docs.rs/multiboot2/badge.svg)](https://docs.rs/multiboot2/)
55

6-
An experimental Multiboot 2 crate for ELF-64 kernels. It's still incomplete, so please open an issue if you're missing some functionality. Contributions welcome!
6+
Library that helps you to parse the multiboot information structure (mbi) from
7+
Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the specification
8+
including full support for the sections of ELF-64. This library is `no_std` and can be
9+
used in a Multiboot2-kernel.
710

8-
It uses the Multiboot 2.0 specification at https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html and the ELF 64 specification at http://www.uclibc.org/docs/elf-64-gen.pdf.
11+
It follows the Multiboot 2.0 specification at https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html and the ELF 64 specification at http://www.uclibc.org/docs/elf-64-gen.pdf.
912

10-
Below is the draft for a blog post about this. I don't plan to finish it but maybe it's helpful as documentation.
11-
12-
## The Multiboot 2 Information Structure
13+
## Background: The Multiboot 2 Information Structure
1314
The Multiboot information structure looks like this:
1415

1516
Field | Type
@@ -27,46 +28,7 @@ type | u32
2728
size | u32
2829
other fields | variable
2930

30-
All tags are 8-byte aligned. The last tag must be the _end tag_, which is a tag of type `0` and size `8`.
31-
32-
## Tags
33-
34-
We are interested in two tags, the _Elf-symbols_ tag and the _memory map_ tag. For a full list of possible tags see section 3.4 in the Multiboot 2 specification ([PDF][Multiboot 2]).
35-
36-
[Multiboot 2]: http://nongnu.askapache.com/grub/phcoder/multiboot.pdf
37-
38-
### The Elf-Symbols Tag
39-
The Elf-symbols tag contains a list of all sections of the loaded [ELF] kernel. It has the following format:
40-
41-
[ELF]: http://www.uclibc.org/docs/elf-64-gen.pdf
42-
43-
Field | Type
44-
--------------------------- | -----------------
45-
type = 9 | u32
46-
size | u32
47-
number of entries | u32
48-
entry size | u32
49-
string table | u32
50-
section headers | variable
51-
52-
Note that this format differs from the description in the Multiboot specification because it seems to be wrong for ELF 64 kernels: The `number of entries`, `entry size`, and `string table` fields seem to be `u32` instead of `u16`. The `multiboot2.h` file in the example section of the specification also specifies these fields as being `u32`, which suggests that the `u16` fields are an editing error. The GRUB2 bootloader [uses u32 fields](https://github.com/josefbacik/grub2/blob/96695ad84ce9c93f057ba53ae77d04d8561586e9/include/multiboot2.h#L298-L300), too.
53-
54-
The section headers are just copied from the ELF file, so we need to look at the ELF specification to find the corresponding structure definition. Our kernel is a 64-bit ELF file, so we need to look at the ELF-64 specification ([PDF][ELF specification]). According to section 4 and figure 3, a section header has the following format:
55-
56-
[ELF specification]: http://www.uclibc.org/docs/elf-64-gen.pdf
57-
58-
Field | Type | Value
59-
--------------------------- | ---------------- | -----------
60-
name | u32 | string table index
61-
type | u32 | `0` (unused), `1` (section of program), `3` (string table), `8` (uninitialized section), etc.
62-
flags | u64 | `0x1` (writable), `0x2` (loaded), `0x4` (executable), etc.
63-
address | u64 | virtual start address of section (0 if not loaded)
64-
file offset | u64 | offset (in bytes) of section contents in the file
65-
size | u64 | size of the section in bytes
66-
link | u32 | associated section (only for some section types)
67-
info | u32 | extra information (only for some section types)
68-
address align | u64 | required alignment of section (power of 2)
69-
entry size | u64 | contains the entry size for table sections (e.g. string table)
31+
All tags and the mbi itself are 8-byte aligned. The last tag must be the _end tag_, which is a tag of type `0` and size `8`.
7032

7133
## License
7234

src/lib.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22
#![deny(missing_debug_implementations)]
33
#![deny(missing_docs)]
44

5-
//! An experimental Multiboot 2 crate for ELF-64/32 kernels.
5+
//! Library that helps you to parse the multiboot information structure (mbi) from
6+
//! Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the specification
7+
//! including full support for the sections of ELF-64. This library is `no_std` and can be
8+
//! used in a Multiboot2-kernel.
69
//!
7-
//! The GNU Multiboot specification aims provide to a standardised
10+
//! The GNU Multiboot(2) specification aims to provide a standardised
811
//! method of sharing commonly used information about the host machine at
9-
//! boot time.
12+
//! boot time and give the payload, i.e. a kernel, a well defined machien
13+
//! state.
14+
//!
15+
//! ## Example
16+
//!
17+
//! ```ignore
18+
//! use multiboot::load;
19+
//! fn kmain(multiboot_info_ptr: u32) {
20+
//! let boot_info = unsafe { load(ptr as usize).unwrap() };
21+
//! println!("{:?}", boot_info);
22+
//! }
23+
//! ```
1024
1125
use core::fmt;
1226

@@ -55,7 +69,7 @@ mod vbe_info;
5569
/// use multiboot::load;
5670
///
5771
/// fn kmain(multiboot_info_ptr: u32) {
58-
/// let boot_info = load(ptr as usize).unwrap();
72+
/// let boot_info = unsafe { load(ptr as usize).unwrap() };
5973
/// println!("{:?}", boot_info);
6074
/// }
6175
/// ```
@@ -68,10 +82,10 @@ pub unsafe fn load(address: usize) -> Result<BootInformation, MbiLoadError> {
6882
/// Examples
6983
///
7084
/// ```ignore
71-
/// use multiboot::load;
85+
/// use multiboot::load_with_offset;
7286
///
7387
/// let ptr = 0xDEADBEEF as *const _;
74-
/// let boot_info = load_with_offset(ptr as usize, 0xCAFEBABE).unwrap();
88+
/// let boot_info = unsafe { load_with_offset(ptr as usize, 0xCAFEBABE).unwrap() };
7589
/// println!("{:?}", boot_info);
7690
/// ```
7791
pub unsafe fn load_with_offset(address: usize, offset: usize) -> Result<BootInformation, MbiLoadError> {

0 commit comments

Comments
 (0)