acpi_spec/
aspt.rs
1use super::Table;
10use zerocopy::Immutable;
11use zerocopy::IntoBytes;
12use zerocopy::KnownLayout;
13use zerocopy::Unaligned;
14
15#[repr(C, packed)]
16#[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout, Unaligned)]
17pub struct Aspt {
18 pub num_structs: usize,
19 }
21
22impl Table for Aspt {
23 const SIGNATURE: [u8; 4] = *b"ASPT";
24}
25
26#[repr(C, packed)]
27#[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout)]
28pub struct AsptStructHeader {
29 pub type_: structs::AsptStructType,
30 pub len: u16,
32}
33
34impl AsptStructHeader {
35 pub fn new<S: structs::AsptStruct>() -> AsptStructHeader {
36 AsptStructHeader {
37 type_: S::TYPE,
38 len: size_of::<S>() as u16,
39 }
40 }
41}
42
43pub mod structs {
45 use open_enum::open_enum;
46 use zerocopy::FromBytes;
47 use zerocopy::Immutable;
48 use zerocopy::IntoBytes;
49 use zerocopy::KnownLayout;
50
51 open_enum! {
52 #[derive(IntoBytes, Immutable, KnownLayout, FromBytes)]
53 pub enum AsptStructType: u16 {
54 ASP_GLOBAL_REGISTERS = 0,
55 SEV_MAILBOX_REGISTERS = 1,
56 ACPI_MAILBOX_REGISTERS = 2,
57 }
58 }
59
60 pub trait AsptStruct: IntoBytes + Immutable + KnownLayout {
61 const TYPE: AsptStructType;
62 }
63
64 #[repr(C, packed)]
65 #[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout)]
66 pub struct AspGlobalRegisters {
67 pub _reserved: u32,
68 pub feature_register_address: u64,
69 pub interrupt_enable_register_address: u64,
70 pub interrupt_status_register_address: u64,
71 }
72
73 impl AsptStruct for AspGlobalRegisters {
74 const TYPE: AsptStructType = AsptStructType::ASP_GLOBAL_REGISTERS;
75 }
76
77 #[repr(C, packed)]
78 #[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout)]
79 pub struct SevMailboxRegisters {
80 pub mailbox_interrupt_id: u8,
81 pub _reserved: [u8; 3],
82 pub cmd_resp_register_address: u64,
83 pub cmd_buf_addr_lo_register_address: u64,
84 pub cmd_buf_addr_hi_register_address: u64,
85 }
86
87 impl AsptStruct for SevMailboxRegisters {
88 const TYPE: AsptStructType = AsptStructType::SEV_MAILBOX_REGISTERS;
89 }
90
91 #[repr(C, packed)]
92 #[derive(Copy, Clone, Debug, IntoBytes, Immutable, KnownLayout)]
93 pub struct AcpiMailboxRegisters {
94 pub _reserved1: u32,
95 pub cmd_resp_register_address: u64,
96 pub _reserved2: [u64; 2],
97 }
98
99 impl AsptStruct for AcpiMailboxRegisters {
100 const TYPE: AsptStructType = AsptStructType::ACPI_MAILBOX_REGISTERS;
101 }
102}