Skip to content

Commit 4b35d58

Browse files
authored
Merge pull request #118 from rust-osdev/custom-tags
multiboot2: Allow to get Custom Tags
2 parents b09c7df + cdfc1c7 commit 4b35d58

12 files changed

+552
-162
lines changed

multiboot2/Changelog.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
# CHANGELOG for crate `multiboot2`
22

3-
## Unreleased
3+
## 0.15.0 (2023-03-XX)
44
- MSRV is 1.56.1
5-
- **BREAKING** fixed lifetime issues: `VBEInfoTag` is no longer static
5+
- **BREAKING** fixed lifetime issues: `VBEInfoTag` is no longer `&static`
6+
- **BREAKING:** `TagType` is now split into `TagTypeId` and `TagType`
7+
- `TagTypeId` is a binary-compatible form of a Multiboot2 tag id
8+
- `TagType` is a higher-level abstraction for either specified or custom tags
9+
but not ABI compatible.
610
- fixed another internal lifetime issue
711
- `BootInformation::framebuffer_tag()` now returns
812
`Option<Result<FramebufferTag, UnknownFramebufferType>>` instead of
913
`Option<FramebufferTag>` which prevents a possible panic. If the `--unstable`
1014
feature is used, `UnknownFramebufferType` implements `core::error::Error`.
1115
- Fixed misleading documentation of the `BootInformation::efi_memory_map_tag`
12-
tag.
16+
- `BootInformation` now publicly exports the `get_tag` function allowing you to
17+
work with custom tags. An example is given in the function documentation.
18+
(check docs.rs). There is also a small unit test that you can use to learn
19+
from.
20+
- There exists a seamless integration between `u32`, `TagType`, and `TagTypeId`
21+
via `From` and `PartialEq`-implementations.
1322

1423
## 0.14.2 (2023-03-17)
1524
- documentation fixes

multiboot2/src/boot_loader_name.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::TagType;
1+
use crate::TagTypeId;
22
use core::str::Utf8Error;
33

44
/// This tag contains the name of the bootloader that is booting the kernel.
@@ -8,7 +8,7 @@ use core::str::Utf8Error;
88
#[derive(Clone, Copy, Debug)]
99
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
1010
pub struct BootLoaderNameTag {
11-
typ: TagType,
11+
typ: TagTypeId,
1212
size: u32,
1313
/// Null-terminated UTF-8 string
1414
string: u8,
@@ -47,7 +47,7 @@ mod tests {
4747
// size is: 4 bytes for tag + 4 bytes for size + length of null-terminated string
4848
let size = (4 + 4 + MSG.as_bytes().len() + 1) as u32;
4949
[
50-
&((TagType::BootLoaderName as u32).to_ne_bytes()),
50+
&((TagType::BootLoaderName.val()).to_ne_bytes()),
5151
&size.to_ne_bytes(),
5252
MSG.as_bytes(),
5353
// Null Byte

multiboot2/src/command_line.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Module for [CommandLineTag].
22
3-
use crate::TagType;
3+
use crate::TagTypeId;
44
use core::mem;
55
use core::slice;
66
use core::str;
@@ -12,7 +12,7 @@ use core::str;
1212
#[derive(Clone, Copy, Debug)]
1313
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
1414
pub struct CommandLineTag {
15-
typ: TagType,
15+
typ: TagTypeId,
1616
size: u32,
1717
/// Null-terminated UTF-8 string
1818
string: u8,
@@ -51,7 +51,7 @@ mod tests {
5151
// size is: 4 bytes for tag + 4 bytes for size + length of null-terminated string
5252
let size = (4 + 4 + MSG.as_bytes().len() + 1) as u32;
5353
[
54-
&((TagType::Cmdline as u32).to_ne_bytes()),
54+
&((TagType::Cmdline.val()).to_ne_bytes()),
5555
&size.to_ne_bytes(),
5656
MSG.as_bytes(),
5757
// Null Byte

multiboot2/src/efi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//! All MBI tags related to (U)EFI.
22
3-
use crate::TagType;
3+
use crate::TagTypeId;
44

55
/// EFI system table in 32 bit mode
66
#[derive(Clone, Copy, Debug)]
77
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
88
pub struct EFISdt32 {
9-
typ: TagType,
9+
typ: TagTypeId,
1010
size: u32,
1111
pointer: u32,
1212
}
@@ -22,7 +22,7 @@ impl EFISdt32 {
2222
#[derive(Clone, Copy, Debug)]
2323
#[repr(C)]
2424
pub struct EFISdt64 {
25-
typ: TagType,
25+
typ: TagTypeId,
2626
size: u32,
2727
pointer: u64,
2828
}
@@ -38,7 +38,7 @@ impl EFISdt64 {
3838
#[derive(Debug)]
3939
#[repr(C)]
4040
pub struct EFIImageHandle32 {
41-
typ: TagType,
41+
typ: TagTypeId,
4242
size: u32,
4343
pointer: u32,
4444
}
@@ -54,7 +54,7 @@ impl EFIImageHandle32 {
5454
#[derive(Debug)]
5555
#[repr(C)]
5656
pub struct EFIImageHandle64 {
57-
typ: TagType,
57+
typ: TagTypeId,
5858
size: u32,
5959
pointer: u64,
6060
}

multiboot2/src/elf_sections.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::tag_type::Tag;
2+
use crate::TagType;
23
use core::fmt::{Debug, Formatter};
34

45
/// This tag contains section header table from an ELF kernel.
@@ -11,7 +12,7 @@ pub struct ElfSectionsTag {
1112
}
1213

1314
pub unsafe fn elf_sections_tag(tag: &Tag, offset: usize) -> ElfSectionsTag {
14-
assert_eq!(9, tag.typ);
15+
assert_eq!(TagType::ElfSections.val(), tag.typ);
1516
let es = ElfSectionsTag {
1617
inner: (tag as *const Tag).offset(1) as *const ElfSectionsTagInner,
1718
offset,

multiboot2/src/image_load_addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use crate::TagType;
1+
use crate::TagTypeId;
22

33
/// If the image has relocatable header tag, this tag contains the image's
44
/// base physical address.
55
#[derive(Debug)]
66
#[repr(C)]
77
pub struct ImageLoadPhysAddr {
8-
typ: TagType,
8+
typ: TagTypeId,
99
size: u32,
1010
load_base_addr: u32,
1111
}

0 commit comments

Comments
 (0)