Skip to content

multiboot2-v0.15 #122

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 14 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
44 changes: 31 additions & 13 deletions .github/workflows/_build-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,51 @@ on:
required: false
default: x86_64-unknown-linux-gnu
description: Rust target for the build step. Clippy and tests are still executed with the default target.
features:
type: string
required: false
# Make sure we always an empty string to "--features <FEATURES>"
default: '""'
description: Comma-separated String with additional Rust features relevant for a certain job.
do-style-check:
type: boolean
required: false
default: true
description: Whether style checks should be done.
description: Perform code and doc style checks.
do-test:
type: boolean
required: false
default: true
description: Whether tests should be executed.
description: Execute tests.

jobs:
build:
check_rust:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Install Rust
- name: Set up rustup cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.rustup/downloads
~/.rustup/toolchains
# key: ${{ runner.os }}-rustup-${{ inputs.rust-version }}-${{ inputs.rust-target }}-${{ hashFiles('**/rustup-toolchain.toml') }}
key: ${{ runner.os }}-rustup-${{ inputs.rust-version }}-${{ inputs.rust-target }}
# The effect of this is must smaller than the cache for Cargo. However, it
# still saves a few seconds. Note that many CI runs within a week may
# quickly bring you close to the 10GB limit:
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#managing-caches
- name: Install Rust Toolchain via Rustup
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ inputs.rust-version }}
override: true
components: clippy, rustfmt
target: ${{ inputs.rust-target }}
- name: Set up cargo cache
- name: Set up Cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
Expand All @@ -54,23 +73,22 @@ jobs:
target/
# We do not have a Cargo.lock here, so I hash Cargo.toml
key: ${{ runner.os }}-rust-${{ inputs.rust-version }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-cargo-${{ inputs.rust-version }}
- run: cargo version
- name: Build (library)
run: cargo build --target ${{ inputs.rust-target }} --features ${{ inputs.features }}
- name: Build (all targets)
run: cargo build --all-targets --features ${{ inputs.features }}
- name: Code Formatting
if: ${{ inputs.do-style-check }}
run: cargo fmt --all -- --check
- name: Build (library)
run: cargo build --target ${{ inputs.rust-target }}
- name: Build (all targets)
run: cargo build --all-targets
- name: Code Style and Doc Style
if: ${{ inputs.do-style-check }}
run: |
cargo doc --document-private-items
cargo clippy --all-targets
cargo doc --document-private-items --features ${{ inputs.features }}
cargo clippy --all-targets --features ${{ inputs.features }}
- name: Unit Test
if: ${{ inputs.do-test }}
run: |
curl -LsSf https://get.nexte.st/latest/linux | tar zxf -
chmod u+x cargo-nextest
./cargo-nextest nextest run
./cargo-nextest nextest run --features ${{ inputs.features }}
6 changes: 6 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
CARGO_TERM_COLOR: always

jobs:
### Regular Build #########################
build_msrv:
name: build (msrv)
uses: ./.github/workflows/_build-rust.yml
Expand All @@ -35,7 +36,9 @@ jobs:
with:
rust-version: nightly
do-style-check: false
features: unstable

### no-std Build #########################
build_nostd_msrv:
name: build no_std (msrv)
needs: build_msrv
Expand All @@ -62,7 +65,9 @@ jobs:
rust-version: nightly
do-style-check: false
rust-target: thumbv7em-none-eabihf
features: unstable

### Style Checks + Doc #####################
style_msrv:
name: style (msrv)
needs: build_msrv
Expand All @@ -89,3 +94,4 @@ jobs:
rust-version: nightly
do-style-check: true
do-test: false
features: unstable
2 changes: 1 addition & 1 deletion multiboot2-header/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
"Philipp Schuster <[email protected]>"
]
license = "MIT/Apache-2.0"
edition = "2018"
edition = "2021"
categories = [
"no-std",
"parsing",
Expand Down
3 changes: 3 additions & 0 deletions multiboot2-header/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG for crate `multiboot2-header`

## Unreleased
- MSRV is 1.56.1

## v0.2.0 (2022-05-03)
- **BREAKING** renamed `EntryHeaderTag` to `EntryAddressHeaderTag`
- **BREAKING** some paths changed from `multiboot2_header::header` to `multiboot2_header::builder`
Expand Down
2 changes: 1 addition & 1 deletion multiboot2-header/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You may need a special linker script to place this in a LOAD segment with a file
See specification.

## MSRV
The MSRV is 1.52.1 stable.
The MSRV is 1.56.1 stable.

## License & Contribution

Expand Down
4 changes: 2 additions & 2 deletions multiboot2-header/src/builder/information_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct InformationRequestHeaderTagBuilder {
#[cfg(feature = "builder")]
impl InformationRequestHeaderTagBuilder {
/// New builder.
#[allow(clippy::missing_const_for_fn)] // TODO remove once MSRV is higher than 1.52.1
#[allow(clippy::missing_const_for_fn)] // TODO remove once MSRV is higher than 1.65.0
pub fn new(flag: HeaderTagFlag) -> Self {
Self {
irs: BTreeSet::new(),
Expand All @@ -31,7 +31,7 @@ impl InformationRequestHeaderTagBuilder {

/// Returns the expected length of the information request tag,
/// when the `build`-method gets called.
#[allow(clippy::missing_const_for_fn)] // TODO remove once MSRV is higher than 1.52.1
#[allow(clippy::missing_const_for_fn)] // TODO remove once MSRV is higher than 1.65.0
pub fn expected_len(&self) -> usize {
let basic_header_size = size_of::<InformationRequestHeaderTag<0>>();
let req_tags_size = self.irs.len() * size_of::<MbiTagType>();
Expand Down
2 changes: 1 addition & 1 deletion multiboot2-header/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! ```
//!
//! ## MSRV
//! The MSRV is 1.52.1 stable.
//! The MSRV is 1.56.1 stable.

#![no_std]
#![deny(rustdoc::all)]
Expand Down
2 changes: 1 addition & 1 deletion multiboot2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ authors = [
"Philipp Schuster <[email protected]>"
]
license = "MIT/Apache-2.0"
edition = "2018"
edition = "2021"
categories = [
"no-std",
"parsing",
Expand Down
20 changes: 20 additions & 0 deletions multiboot2/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# CHANGELOG for crate `multiboot2`

## 0.15.0 (2023-03-XX)
- MSRV is 1.56.1
- **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`
- `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
- `MbiLoadError` now implements `Display`
Expand Down
2 changes: 1 addition & 1 deletion multiboot2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ other fields | variable
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`.

## MSRV
The MSRV is 1.52.1 stable.
The MSRV is 1.56.1 stable.

## License & Contribution

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
Loading