|
| 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