Skip to content

multiboot2: Allow to get Custom Tags #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions multiboot2/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
# CHANGELOG for crate `multiboot2`

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

## 0.14.2 (2023-03-17)
- documentation fixes
Expand Down
6 changes: 3 additions & 3 deletions multiboot2/src/boot_loader_name.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::TagType;
use crate::TagTypeId;
use core::str::Utf8Error;

/// This tag contains the name of the bootloader that is booting the kernel.
Expand All @@ -8,7 +8,7 @@ use core::str::Utf8Error;
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
pub struct BootLoaderNameTag {
typ: TagType,
typ: TagTypeId,
size: u32,
/// Null-terminated UTF-8 string
string: u8,
Expand Down Expand Up @@ -47,7 +47,7 @@ mod tests {
// size is: 4 bytes for tag + 4 bytes for size + length of null-terminated string
let size = (4 + 4 + MSG.as_bytes().len() + 1) as u32;
[
&((TagType::BootLoaderName as u32).to_ne_bytes()),
&((TagType::BootLoaderName.val()).to_ne_bytes()),
&size.to_ne_bytes(),
MSG.as_bytes(),
// Null Byte
Expand Down
6 changes: 3 additions & 3 deletions multiboot2/src/command_line.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Module for [CommandLineTag].

use crate::TagType;
use crate::TagTypeId;
use core::mem;
use core::slice;
use core::str;
Expand All @@ -12,7 +12,7 @@ use core::str;
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
pub struct CommandLineTag {
typ: TagType,
typ: TagTypeId,
size: u32,
/// Null-terminated UTF-8 string
string: u8,
Expand Down Expand Up @@ -51,7 +51,7 @@ mod tests {
// size is: 4 bytes for tag + 4 bytes for size + length of null-terminated string
let size = (4 + 4 + MSG.as_bytes().len() + 1) as u32;
[
&((TagType::Cmdline as u32).to_ne_bytes()),
&((TagType::Cmdline.val()).to_ne_bytes()),
&size.to_ne_bytes(),
MSG.as_bytes(),
// Null Byte
Expand Down
10 changes: 5 additions & 5 deletions multiboot2/src/efi.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! All MBI tags related to (U)EFI.

use crate::TagType;
use crate::TagTypeId;

/// EFI system table in 32 bit mode
#[derive(Clone, Copy, Debug)]
#[repr(C, packed)] // only repr(C) would add unwanted padding before first_section
pub struct EFISdt32 {
typ: TagType,
typ: TagTypeId,
size: u32,
pointer: u32,
}
Expand All @@ -22,7 +22,7 @@ impl EFISdt32 {
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct EFISdt64 {
typ: TagType,
typ: TagTypeId,
size: u32,
pointer: u64,
}
Expand All @@ -38,7 +38,7 @@ impl EFISdt64 {
#[derive(Debug)]
#[repr(C)]
pub struct EFIImageHandle32 {
typ: TagType,
typ: TagTypeId,
size: u32,
pointer: u32,
}
Expand All @@ -54,7 +54,7 @@ impl EFIImageHandle32 {
#[derive(Debug)]
#[repr(C)]
pub struct EFIImageHandle64 {
typ: TagType,
typ: TagTypeId,
size: u32,
pointer: u64,
}
Expand Down
3 changes: 2 additions & 1 deletion multiboot2/src/elf_sections.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::tag_type::Tag;
use crate::TagType;
use core::fmt::{Debug, Formatter};

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

pub unsafe fn elf_sections_tag(tag: &Tag, offset: usize) -> ElfSectionsTag {
assert_eq!(9, tag.typ);
assert_eq!(TagType::ElfSections.val(), tag.typ);
let es = ElfSectionsTag {
inner: (tag as *const Tag).offset(1) as *const ElfSectionsTagInner,
offset,
Expand Down
4 changes: 2 additions & 2 deletions multiboot2/src/image_load_addr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::TagType;
use crate::TagTypeId;

/// If the image has relocatable header tag, this tag contains the image's
/// base physical address.
#[derive(Debug)]
#[repr(C)]
pub struct ImageLoadPhysAddr {
typ: TagType,
typ: TagTypeId,
size: u32,
load_base_addr: u32,
}
Expand Down
Loading