use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};
use crate::{bitflags, consts};
consts! {
#[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
pub struct HobType(u16) {
HANDOFF = 0x0001;
RESOURCE_DESCRIPTOR = 0x0003;
END_OF_HOB_LIST = 0xffff;
}
}
#[repr(C)]
#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
pub struct HobGenericHeader {
pub r#type: HobType,
pub length: u16,
pub reserved: u32,
}
pub const HOB_HANDOFF_TABLE_VERSION: u32 = 0x9;
#[repr(C)]
#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
pub struct HobHandoffInfoTable {
pub hdr: HobGenericHeader,
pub version: u32,
pub boot_mode: u32,
pub memory_top: u64,
pub memory_bottom: u64,
pub free_memory_top: u64,
pub free_memory_bottom: u64,
pub end_of_hob_list: u64,
}
consts! {
#[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
pub struct HobResourceType(u32) {
SYSTEM_MEMORY = 0x00000000;
MEMORY_UNACCEPTED = 0x00000007;
}
}
bitflags! {
#[derive(Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
pub struct ResourceAttr(u32) {
PRESENT = 1 << 0;
INIT = 1 << 1;
TESTED = 1 << 2;
}
}
#[repr(C)]
#[derive(Debug, Clone, Default, KnownLayout, Immutable, FromBytes, IntoBytes)]
pub struct HobResourceDesc {
pub hdr: HobGenericHeader,
pub owner: [u8; 16],
pub r#type: HobResourceType,
pub attr: ResourceAttr,
pub address: u64,
pub len: u64,
}