Skip to content

Commit 9692c61

Browse files
committed
bumped crate versions + better build environment with cargo
1 parent 4908653 commit 9692c61

File tree

9 files changed

+66
-68
lines changed

9 files changed

+66
-68
lines changed

Cargo.lock

Lines changed: 13 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
[workspace]
2+
resolver = "2"
23
members = [
34
"multiboot2",
45
"multiboot2-header",
56
]
7+
8+
9+
# This way, the "multiboot2" dependency in the multiboot2-header crate can be
10+
# referenced by version, while still the repository version is used
11+
# transparently.
12+
[patch.crates-io]
13+
multiboot2 = { path = "multiboot2" }

multiboot2-header/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = """
44
Library with type definitions and parsing functions for Multiboot2 headers.
55
This library is `no_std` and can be used in bootloaders.
66
"""
7-
version = "0.2.0"
7+
version = "0.3.0"
88
authors = [
99
"Philipp Schuster <phip1611@gmail.com>"
1010
]
@@ -41,4 +41,4 @@ unstable = []
4141

4242
[dependencies]
4343
# used for MBI tags
44-
multiboot2 = "0.13.2"
44+
multiboot2 = "0.16.0"

multiboot2-header/Changelog.md

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

3-
## Unreleased
3+
## 0.3.0 (xxxx-xx-xx)
44
- MSRV is 1.68.0
55
- renamed the `std` feature to `alloc`
66
- added the optional `unstable` feature (requires nightly)
77
- implement `core::error::Error` for `LoadError`
88

9-
## v0.2.0 (2022-05-03)
9+
## 0.2.0 (2022-05-03)
1010
- **BREAKING** renamed `EntryHeaderTag` to `EntryAddressHeaderTag`
1111
- **BREAKING** some paths changed from `multiboot2_header::header` to `multiboot2_header::builder`
1212
-> thus, import paths are much more logically now
1313
- internal code improvements
1414

15-
## v0.1.1 (2022-05-02)
15+
## 0.1.1 (2022-05-02)
1616
- fixed a bug that prevented the usage of the crate in `no_std` environments
1717
- added a new default `builder`-feature to Cargo which requires the `alloc`-crate
1818
(this feature can be disabled which will also remove the dependency to the `alloc` crate)
1919

20-
## v0.1.0 (2021-10-08)
20+
## 0.1.0 (2021-10-08)
2121
- initial release
2222

23-
## v0.0.0
23+
## 0.0.0
2424
Empty release to save the name on crates.io

multiboot2-header/src/builder/information_request.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use super::traits::StructAsBytes;
2-
use crate::InformationRequestHeaderTag;
32
use crate::{HeaderTagFlag, MbiTagType};
3+
use crate::{InformationRequestHeaderTag, MbiTagTypeId};
44
use alloc::collections::BTreeSet;
55
use alloc::vec::Vec;
66
use core::fmt::Debug;
77
use core::mem::size_of;
8+
use multiboot2::TagTypeId;
89

910
/// Helper to build the dynamically sized [`InformationRequestHeaderTag`]
1011
/// at runtime. The information request tag has a dedicated builder because this way one
@@ -21,7 +22,6 @@ pub struct InformationRequestHeaderTagBuilder {
2122
#[cfg(feature = "builder")]
2223
impl InformationRequestHeaderTagBuilder {
2324
/// New builder.
24-
#[allow(clippy::missing_const_for_fn)] // TODO remove once MSRV is higher than 1.65.0
2525
pub fn new(flag: HeaderTagFlag) -> Self {
2626
Self {
2727
irs: BTreeSet::new(),
@@ -31,10 +31,9 @@ impl InformationRequestHeaderTagBuilder {
3131

3232
/// Returns the expected length of the information request tag,
3333
/// when the `build`-method gets called.
34-
#[allow(clippy::missing_const_for_fn)] // TODO remove once MSRV is higher than 1.65.0
3534
pub fn expected_len(&self) -> usize {
3635
let basic_header_size = size_of::<InformationRequestHeaderTag<0>>();
37-
let req_tags_size = self.irs.len() * size_of::<MbiTagType>();
36+
let req_tags_size = self.irs.len() * size_of::<MbiTagTypeId>();
3837
basic_header_size + req_tags_size
3938
}
4039

@@ -74,8 +73,13 @@ impl InformationRequestHeaderTagBuilder {
7473
);
7574
}
7675

77-
for tag in &self.irs {
78-
let bytes: [u8; 4] = (*tag as u32).to_ne_bytes();
76+
for tag_type in self
77+
.irs
78+
.into_iter()
79+
// Transform to the ABI-compatible type
80+
.map(TagTypeId::from)
81+
{
82+
let bytes: [u8; 4] = (u32::from(tag_type)).to_le_bytes();
7983
data.extend(&bytes);
8084
}
8185

@@ -91,7 +95,7 @@ impl InformationRequestHeaderTagBuilder {
9195
#[cfg(test)]
9296
mod tests {
9397
use crate::builder::information_request::InformationRequestHeaderTagBuilder;
94-
use crate::{HeaderTagFlag, InformationRequestHeaderTag, MbiTagType};
98+
use crate::{HeaderTagFlag, InformationRequestHeaderTag, MbiTagType, MbiTagTypeId};
9599

96100
#[test]
97101
fn test_builder() {
@@ -111,11 +115,19 @@ mod tests {
111115
// type(u16) + flags(u16) + size(u32) + 3 tags (u32)
112116
assert_eq!(tag.size(), 2 + 2 + 4 + 3 * 4);
113117
assert_eq!(tag.dynamic_requests_size(), 3);
114-
assert!(tag.requests().contains(&MbiTagType::EfiMmap));
115-
assert!(tag.requests().contains(&MbiTagType::BootLoaderName));
116-
assert!(tag.requests().contains(&MbiTagType::Cmdline));
118+
assert!(tag
119+
.requests()
120+
.contains(&MbiTagTypeId::from(MbiTagType::EfiMmap)));
121+
assert!(tag
122+
.requests()
123+
.contains(&MbiTagTypeId::from(MbiTagType::BootLoaderName)));
124+
assert!(tag
125+
.requests()
126+
.contains(&MbiTagTypeId::from(MbiTagType::Cmdline)));
117127
assert_eq!(tag.requests().len(), 3);
118-
assert!(!tag.requests().contains(&MbiTagType::AcpiV1));
128+
assert!(!tag
129+
.requests()
130+
.contains(&MbiTagTypeId::from(MbiTagType::AcpiV1)));
119131
println!("{:#?}", tag);
120132
}
121133
}

multiboot2-header/src/information_request.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use crate::HeaderTagType;
21
use crate::{HeaderTagFlag, MbiTagType};
2+
use crate::{HeaderTagType, MbiTagTypeId};
33
use core::fmt;
44
use core::fmt::{Debug, Formatter};
55
use core::marker::PhantomData;
66
use core::mem::size_of;
7+
use multiboot2::TagType;
78

89
/// Specifies what specific tag types the bootloader should provide
910
/// inside the mbi.
@@ -15,14 +16,14 @@ pub struct InformationRequestHeaderTag<const N: usize> {
1516
size: u32,
1617
// Length is determined by size.
1718
// Must be parsed during runtime with unsafe pointer magic and the size field.
18-
requests: [MbiTagType; N],
19+
requests: [MbiTagTypeId; N],
1920
}
2021

2122
impl<const N: usize> InformationRequestHeaderTag<N> {
2223
/// Creates a new object. The size parameter is the value of the size property.
2324
/// It doesn't have to match with `N` necessarily, because during compile time we
2425
/// can't know the size of the tag in all runtime situations.
25-
pub fn new(flags: HeaderTagFlag, requests: [MbiTagType; N], size: Option<u32>) -> Self {
26+
pub fn new(flags: HeaderTagFlag, requests: [MbiTagTypeId; N], size: Option<u32>) -> Self {
2627
InformationRequestHeaderTag {
2728
typ: HeaderTagType::InformationRequest,
2829
flags,
@@ -44,7 +45,7 @@ impl<const N: usize> InformationRequestHeaderTag<N> {
4445
/// Returns the requests as array. Only works if the number of requests
4546
/// is known at compile time. For safety and correctness during runtime,
4647
/// you should use `req_iter()`.
47-
pub const fn requests(&self) -> [MbiTagType; N] {
48+
pub const fn requests(&self) -> [MbiTagTypeId; N] {
4849
// cheap to copy, otherwise difficult with lifetime
4950
self.requests
5051
}
@@ -70,7 +71,7 @@ impl<const N: usize> InformationRequestHeaderTag<N> {
7071
let base_ptr = self as *const InformationRequestHeaderTag<N>;
7172
let base_ptr = base_ptr as *const u8;
7273
let base_ptr = unsafe { base_ptr.add(base_struct_size) };
73-
let base_ptr = base_ptr as *const MbiTagType;
74+
let base_ptr = base_ptr as *const MbiTagTypeId;
7475
InformationRequestHeaderTagIter::new(count, base_ptr)
7576
}
7677
}
@@ -90,14 +91,14 @@ impl<const N: usize> Debug for InformationRequestHeaderTag<N> {
9091
/// that are requested.
9192
#[derive(Copy, Clone)]
9293
pub struct InformationRequestHeaderTagIter<'a> {
93-
base_ptr: *const MbiTagType,
94+
base_ptr: *const MbiTagTypeId,
9495
i: u32,
9596
count: u32,
9697
_marker: PhantomData<&'a ()>,
9798
}
9899

99100
impl<'a> InformationRequestHeaderTagIter<'a> {
100-
fn new(count: u32, base_ptr: *const MbiTagType) -> Self {
101+
fn new(count: u32, base_ptr: *const MbiTagTypeId) -> Self {
101102
#[allow(clippy::default_constructed_unit_structs)]
102103
Self {
103104
i: 0,
@@ -109,13 +110,14 @@ impl<'a> InformationRequestHeaderTagIter<'a> {
109110
}
110111

111112
impl<'a> Iterator for InformationRequestHeaderTagIter<'a> {
112-
type Item = &'a MbiTagType;
113+
type Item = MbiTagType;
113114

114115
fn next(&mut self) -> Option<Self::Item> {
115116
if self.i < self.count {
116117
let ptr = unsafe { self.base_ptr.offset(self.i as isize) };
117118
self.i += 1;
118-
Some(unsafe { &*ptr })
119+
let tag_type_id = unsafe { *ptr };
120+
Some(TagType::from(tag_type_id))
119121
} else {
120122
None
121123
}
@@ -126,7 +128,7 @@ impl<'a> Debug for InformationRequestHeaderTagIter<'a> {
126128
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
127129
let mut debug = f.debug_list();
128130
(*self).for_each(|e| {
129-
debug.entry(e);
131+
debug.entry(&e);
130132
});
131133
debug.finish()
132134
}

multiboot2-header/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ pub use self::tags::*;
7979
pub use self::uefi_bs::*;
8080

8181
/// Re-export of [`multiboot2::TagType`] from `multiboot2`-crate.
82-
pub use multiboot2::TagType as MbiTagType;
82+
pub use multiboot2::{TagType as MbiTagType, TagTypeId as MbiTagTypeId};

multiboot2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the speci
66
including full support for the sections of ELF-64. This library is `no_std` and can be
77
used in a Multiboot2-kernel.
88
"""
9-
version = "0.15.1"
9+
version = "0.16.0"
1010
authors = [
1111
"Philipp Oppermann <dev@phil-opp.com>",
1212
"Calvin Lee <cyrus296@gmail.com>",

multiboot2/Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CHANGELOG for crate `multiboot2`
22

3-
## unreleased
3+
## 0.16.0 (xxxx-xx-xx)
44
- Add `TagTrait` trait which enables to use DSTs as multiboot2 tags. This is
55
mostly relevant for the command line tag, the modules tag, and the bootloader
66
name tag. However, this might also be relevant for users of custom multiboot2

0 commit comments

Comments
 (0)