Skip to content

Commit 2ed3d73

Browse files
Add structs for TCPA and TPM2 tables
Not complete
1 parent 0a850f7 commit 2ed3d73

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

acpi/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ pub mod mcfg;
7373
pub mod rsdp;
7474
pub mod sdt;
7575
pub mod spcr;
76+
pub mod tcpa;
77+
pub mod tpm2;
7678

7779
#[cfg(feature = "allocator_api")]
7880
mod managed_slice;

acpi/src/tcpa.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use crate::{
2+
sdt::{SdtHeader, Signature},
3+
AcpiTable,
4+
};
5+
6+
#[repr(C, packed)]
7+
#[derive(Debug)]
8+
pub struct Tcpa {
9+
pub header: SdtHeader,
10+
platform_class: u16,
11+
pub log_area_minimum_len: u32,
12+
pub log_area_start_addr: u64,
13+
}
14+
15+
unsafe impl AcpiTable for Tcpa {
16+
const SIGNATURE: Signature = Signature::TCPA;
17+
18+
fn header(&self) -> &crate::sdt::SdtHeader {
19+
&self.header
20+
}
21+
}

acpi/src/tpm2.rs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
use crate::{
2+
sdt::{SdtHeader, Signature},
3+
AcpiTable,
4+
};
5+
6+
#[repr(C, packed)]
7+
#[derive(Debug)]
8+
pub struct Tpm2 {
9+
pub header: SdtHeader,
10+
platform_class: u16,
11+
_reserved: [u8; 2],
12+
addr_of_crb_control_area_or_fifo_base_addr: u64,
13+
start_method: u32,
14+
start_method_parameters: [u8; 16],
15+
log_area_minimum_len: u32,
16+
log_area_start_addr: u64,
17+
}
18+
19+
unsafe impl AcpiTable for Tpm2 {
20+
const SIGNATURE: Signature = Signature::TPM2;
21+
22+
fn header(&self) -> &crate::sdt::SdtHeader {
23+
&self.header
24+
}
25+
}
26+
27+
impl Tpm2 {
28+
pub fn platform_class(&self) -> Option<PlatformClass> {
29+
match self.platform_class {
30+
0 => Some(PlatformClass::Client),
31+
1 => Some(PlatformClass::Server),
32+
_ => None,
33+
}
34+
}
35+
36+
pub fn start_method(&self) -> Option<StartMethod> {
37+
match self.start_method {
38+
2 => Some(StartMethod::AcpiStartMethod),
39+
6 => Some(StartMethod::Mmio),
40+
7 => Some(StartMethod::CommandResponseBufferInterface),
41+
8 => Some(StartMethod::CommandResponseBufferInterfaceWithAcpiStartMethod),
42+
11 => Some(StartMethod::CommandResponseBufferWithArmSecureMonitorOrHypervisorCall),
43+
12 => Some(StartMethod::FifoOverI2c),
44+
13 => Some(StartMethod::CommandResponseBufferInterfaceWithAmdMailboxSpecificNotification),
45+
15 => Some(StartMethod::CommandResponseBufferInterfaceWithAmdFirmwareFrameworkA),
46+
_ => None,
47+
}
48+
}
49+
}
50+
51+
#[derive(Debug)]
52+
#[repr(u16)]
53+
pub enum PlatformClass {
54+
Client,
55+
Server,
56+
}
57+
58+
#[derive(Debug)]
59+
#[repr(u32)]
60+
pub enum StartMethod {
61+
AcpiStartMethod = 2,
62+
Mmio = 6,
63+
CommandResponseBufferInterface = 7,
64+
CommandResponseBufferInterfaceWithAcpiStartMethod = 8,
65+
CommandResponseBufferWithArmSecureMonitorOrHypervisorCall = 11,
66+
FifoOverI2c = 12,
67+
CommandResponseBufferInterfaceWithAmdMailboxSpecificNotification = 13,
68+
CommandResponseBufferInterfaceWithAmdFirmwareFrameworkA = 15,
69+
}

0 commit comments

Comments
 (0)