use multiboot2_common::Header;
multiboot2_common::raw_type! {
pub struct HeaderTagISARaw(u32);
pub enum HeaderTagISA {
I386 = 0,
MIPS32 = 4,
}
}
multiboot2_common::raw_type! {
pub struct HeaderTagTypeRaw(u16);
pub enum HeaderTagType {
End = 0,
InformationRequest = 1,
Address = 2,
EntryAddress = 3,
ConsoleFlags = 4,
Framebuffer = 5,
ModuleAlign = 6,
EfiBS = 7,
EntryAddressEFI32 = 8,
EntryAddressEFI64 = 9,
Relocatable = 10,
}
}
multiboot2_common::raw_type! {
pub struct HeaderTagFlagRaw(u16);
pub enum HeaderTagFlag {
Required = 0,
Optional = 1,
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C, align(8))]
pub struct HeaderTagHeader {
typ: HeaderTagTypeRaw,
flags: HeaderTagFlagRaw,
size: u32,
}
const _: () = assert!(size_of::<HeaderTagHeader>() == 2 + 2 + 4);
impl HeaderTagHeader {
#[must_use]
pub const fn new(typ: HeaderTagType, flags: HeaderTagFlag, size: u32) -> Self {
Self {
typ: HeaderTagTypeRaw::new(typ.val()),
flags: HeaderTagFlagRaw::new(flags.val()),
size,
}
}
#[must_use]
pub const fn typ(&self) -> HeaderTagType {
HeaderTagType::from_val(self.typ.get())
}
#[must_use]
pub const fn flags(&self) -> HeaderTagFlag {
HeaderTagFlag::from_val(self.flags.get())
}
#[must_use]
pub const fn size(&self) -> u32 {
self.size
}
}
unsafe impl Header for HeaderTagHeader {
fn total_size(&self) -> usize {
self.size as usize
}
fn set_size(&mut self, total_size: usize) {
self.size = total_size as u32;
}
}