Skip to content

Commit eeebae0

Browse files
committed
multiboot2: cleanup
1 parent 6257635 commit eeebae0

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
# check that devs can also use this on Windows.
7676
build_nostd_stable_windows:
7777
name: build no_std (stable) [Windows]
78+
needs: build_stable
7879
uses: ./.github/workflows/_build-rust.yml
7980
with:
8081
runs-on: windows-latest

multiboot2/src/efi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ mod tests {
162162

163163
#[test]
164164
fn test_build_eftih64() {
165-
let tag = EFIImageHandle32::new(ADDR.try_into().unwrap());
165+
let tag = EFIImageHandle64::new(ADDR.try_into().unwrap());
166166
assert_eq!(tag.image_handle(), ADDR);
167167
}
168168
}

multiboot2/src/framebuffer.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Reader, Tag, TagTrait, TagTypeId};
1+
use crate::{Tag, TagTrait, TagTypeId};
22

33
use core::fmt::Debug;
44
use core::mem::size_of;
@@ -11,6 +11,39 @@ use {
1111
alloc::boxed::Box, alloc::vec::Vec,
1212
};
1313

14+
/// Helper struct to read bytes from a raw pointer and increase the pointer
15+
/// automatically.
16+
struct Reader {
17+
ptr: *const u8,
18+
off: usize,
19+
}
20+
21+
impl Reader {
22+
fn new<T>(ptr: *const T) -> Reader {
23+
Reader {
24+
ptr: ptr as *const u8,
25+
off: 0,
26+
}
27+
}
28+
29+
fn read_u8(&mut self) -> u8 {
30+
self.off += 1;
31+
unsafe { *self.ptr.add(self.off - 1) }
32+
}
33+
34+
fn read_u16(&mut self) -> u16 {
35+
self.read_u8() as u16 | (self.read_u8() as u16) << 8
36+
}
37+
38+
fn read_u32(&mut self) -> u32 {
39+
self.read_u16() as u32 | (self.read_u16() as u32) << 16
40+
}
41+
42+
fn current_address(&self) -> usize {
43+
unsafe { self.ptr.add(self.off) as usize }
44+
}
45+
}
46+
1447
const METADATA_SIZE: usize = size_of::<TagTypeId>()
1548
+ 4 * size_of::<u32>()
1649
+ size_of::<u64>()

multiboot2/src/lib.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -502,37 +502,6 @@ impl fmt::Debug for BootInformation {
502502
}
503503
}
504504

505-
pub(crate) struct Reader {
506-
pub(crate) ptr: *const u8,
507-
pub(crate) off: usize,
508-
}
509-
510-
impl Reader {
511-
pub(crate) fn new<T>(ptr: *const T) -> Reader {
512-
Reader {
513-
ptr: ptr as *const u8,
514-
off: 0,
515-
}
516-
}
517-
518-
pub(crate) fn read_u8(&mut self) -> u8 {
519-
self.off += 1;
520-
unsafe { *self.ptr.add(self.off - 1) }
521-
}
522-
523-
pub(crate) fn read_u16(&mut self) -> u16 {
524-
self.read_u8() as u16 | (self.read_u8() as u16) << 8
525-
}
526-
527-
pub(crate) fn read_u32(&mut self) -> u32 {
528-
self.read_u16() as u32 | (self.read_u16() as u32) << 16
529-
}
530-
531-
pub(crate) fn current_address(&self) -> usize {
532-
unsafe { self.ptr.add(self.off) as usize }
533-
}
534-
}
535-
536505
/// A trait to abstract over all sized and unsized tags (DSTs). For sized tags,
537506
/// this trait does not much. For DSTs, a `TagTrait::dst_size` implementation
538507
/// must me provided, which returns the right size hint for the dynamically

0 commit comments

Comments
 (0)