1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Module for [`BootdevTag`].
use crate::{TagHeader, TagType};
use multiboot2_common::{MaybeDynSized, Tag};
/// The end tag ends the information struct.
#[derive(Debug)]
#[repr(C, align(8))]
pub struct BootdevTag {
header: TagHeader,
biosdev: u32,
slice: u32,
part: u32,
}
impl BootdevTag {
/// Creates a new tag.
#[must_use]
pub fn new(biosdev: u32, slice: u32, part: u32) -> Self {
Self {
header: TagHeader::new(Self::ID, size_of::<Self>() as u32),
biosdev,
slice,
part,
}
}
/// Returns the bios device from which the device was booted from.
/// `0x00` represents the first floppy disk.
/// `0x80` represents the first hard disk, 0x81 the second hard disk, and
/// so on.
#[must_use]
pub const fn biosdev(&self) -> u32 {
self.biosdev
}
/// The slice field identifies the partition (also known as a "slice" in BSD
/// terminology) on the BIOS device from which the operating system was
/// booted.
#[must_use]
pub const fn slice(&self) -> u32 {
self.slice
}
/// The part field denotes the subpartition or logical partition within the
/// primary partition (if applicable) from which the operating system was
/// booted.
#[must_use]
pub const fn part(&self) -> u32 {
self.part
}
}
impl MaybeDynSized for BootdevTag {
type Header = TagHeader;
const BASE_SIZE: usize = size_of::<Self>();
}
impl Tag for BootdevTag {
type IDType = TagType;
const ID: TagType = TagType::Bootdev;
}