Skip to content

Add structs for TCPA and TPM2 tables #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions acpi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub mod mcfg;
pub mod rsdp;
pub mod sdt;
pub mod spcr;
pub mod tcpa;
pub mod tpm2;

#[cfg(feature = "allocator_api")]
mod managed_slice;
Expand Down
21 changes: 21 additions & 0 deletions acpi/src/tcpa.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use crate::{
sdt::{SdtHeader, Signature},
AcpiTable,
};

#[repr(C, packed)]
#[derive(Debug)]
pub struct Tcpa {
pub header: SdtHeader,
platform_class: u16,
pub log_area_minimum_len: u32,
pub log_area_start_addr: u64,
}

unsafe impl AcpiTable for Tcpa {
const SIGNATURE: Signature = Signature::TCPA;

fn header(&self) -> &crate::sdt::SdtHeader {
&self.header
}
}
69 changes: 69 additions & 0 deletions acpi/src/tpm2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
use crate::{
sdt::{SdtHeader, Signature},
AcpiTable,
};

#[repr(C, packed)]
#[derive(Debug)]
pub struct Tpm2 {
pub header: SdtHeader,
platform_class: u16,
_reserved: [u8; 2],
addr_of_crb_control_area_or_fifo_base_addr: u64,
start_method: u32,
start_method_parameters: [u8; 16],
log_area_minimum_len: u32,
log_area_start_addr: u64,
}

unsafe impl AcpiTable for Tpm2 {
const SIGNATURE: Signature = Signature::TPM2;

fn header(&self) -> &crate::sdt::SdtHeader {
&self.header
}
}

impl Tpm2 {
pub fn platform_class(&self) -> Option<PlatformClass> {
match self.platform_class {
0 => Some(PlatformClass::Client),
1 => Some(PlatformClass::Server),
_ => None,
}
}

pub fn start_method(&self) -> Option<StartMethod> {
match self.start_method {
2 => Some(StartMethod::AcpiStartMethod),
6 => Some(StartMethod::Mmio),
7 => Some(StartMethod::CommandResponseBufferInterface),
8 => Some(StartMethod::CommandResponseBufferInterfaceWithAcpiStartMethod),
11 => Some(StartMethod::CommandResponseBufferWithArmSecureMonitorOrHypervisorCall),
12 => Some(StartMethod::FifoOverI2c),
13 => Some(StartMethod::CommandResponseBufferInterfaceWithAmdMailboxSpecificNotification),
15 => Some(StartMethod::CommandResponseBufferInterfaceWithAmdFirmwareFrameworkA),
_ => None,
}
}
}

#[derive(Debug)]
#[repr(u16)]
pub enum PlatformClass {
Client,
Server,
}

#[derive(Debug)]
#[repr(u32)]
pub enum StartMethod {
AcpiStartMethod = 2,
Mmio = 6,
CommandResponseBufferInterface = 7,
CommandResponseBufferInterfaceWithAcpiStartMethod = 8,
CommandResponseBufferWithArmSecureMonitorOrHypervisorCall = 11,
FifoOverI2c = 12,
CommandResponseBufferInterfaceWithAmdMailboxSpecificNotification = 13,
CommandResponseBufferInterfaceWithAmdFirmwareFrameworkA = 15,
}