Skip to content

Commit f6991f9

Browse files
authored
Merge pull request #240 from rust-osdev/doc2
multiboot2-common: improve README and diagrams
2 parents 260d35c + eefbe9b commit f6991f9

File tree

7 files changed

+663
-140
lines changed

7 files changed

+663
-140
lines changed

multiboot2-common/README.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,33 @@
55

66
Common helpers for the `multiboot2` and `multiboot2-header` crates.
77

8-
## Architecture
8+
## Architecture Diagrams
99

1010
The following figures, not displayable in `lib.rs` / on `docs.rs` unfortunately,
11-
outline the design of this crate:
12-
13-
![Overview Multiboot2 Structures](./overview-multiboot2-structures.drawio.png "Overview Multiboot2 Structures")
14-
15-
Overview of Multiboot2 structures: Multiboot2 boot information, boot
16-
information tags, Multiboot2 headers, and Multiboot2 header tags all share the
17-
same technical foundation: They have a common header and a possible dynamic
18-
size, depending on the header.
19-
20-
![Crate Architecture Overview](./architecture.drawio.png "Crate Architecture Overview")
21-
22-
Overview of how raw bytes are modelled to be representable by high-level
23-
ABI-compatible rusty types.
11+
outline the design of this crate. In the following figure, you can see the
12+
four classes of Multiboot2 structures and their memory properties. The four
13+
kinds of Multiboot2 structures are boot information, boot information
14+
tags, header, and header tags. All share the same technical foundation: They
15+
have a common header and a possible dynamic size, depending on the header.
16+
17+
![Overview Multiboot2 structures](./overview-multiboot2-structures.drawio.png "Overview of Multiboot2 structures and their memory properties")
18+
19+
In the next figure, you see how the types from `multiboot2-common` are used
20+
to parse a raw byte slice as the corresponding Multiboot2 structure a safe
21+
manner. The `BytesRef` wrapper ensures basic memory guarantees for the
22+
underlying `&[u8]` slice, while `DynSizedStructure` can then be used to
23+
safely cast to the target type.
24+
25+
![Parsing flow overview](./parsing-flow.drawio.png "Parsing flow overview: From raw bytes to specific structures")
26+
27+
The last complex figure shows all traits and structs from `multiboot2-common`,
28+
their internal relation, and how consumers (`multiboot2` and
29+
`multiboot2-header`) consume them. As this figure is quite complex, we recommend
30+
to first study the inner box (`multiboot2-common`) and then study how types from
31+
`multiboot2` (orange) and `multiboot2-header` (green) interface with
32+
`multiboot2-common`.
33+
34+
![Architecture overview](./architecture.drawio.png "Architecture overview")
2435

2536
## MSRV
2637

349 KB
Loading

multiboot2-common/architecture.drawio.xml

Lines changed: 415 additions & 125 deletions
Large diffs are not rendered by default.
183 KB
Loading

multiboot2-common/parsing-flow.drawio.xml

Lines changed: 217 additions & 0 deletions
Large diffs are not rendered by default.

multiboot2-common/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,14 @@
143143
//!
144144
//! # Architecture & Provided Abstractions
145145
//!
146-
//! Figure 2 in the [README](https://crates.io/crates/multiboot2-common)
146+
//! The figures in the [README](https://crates.io/crates/multiboot2-common)
147147
//! (currently not embeddable in lib.rs unfortunately) provides an overview of
148148
//! the parsing of Multiboot2 structures and how the definitions from this
149149
//! crate are used.
150150
//!
151+
//! Note that although the diagrams seem complex, most logic is in
152+
//! `multiboot2-common`. For downstream users, the usage is quite simple.
153+
//!
151154
//! ## Parsing and Casting
152155
//!
153156
//! First, we need byte slices which are guaranteed to be aligned and are a

multiboot2-common/src/tag.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ pub trait Tag: MaybeDynSized {
9090
const ID: Self::IDType;
9191
}
9292

93+
// This implementation is not needed for parsing but for creation, when
94+
// downstream types just wrap this type.
9395
impl<H: Header> MaybeDynSized for DynSizedStructure<H> {
9496
type Header = H;
9597

0 commit comments

Comments
 (0)