Trait opentitanlib::tpm::Driver

source ·
pub trait Driver {
    // Required methods
    fn read_register(&self, register: Register, data: &mut [u8]) -> Result<()>;
    fn write_register(&self, register: Register, data: &[u8]) -> Result<()>;

    // Provided methods
    fn init(&self) -> Result<()> { ... }
    fn execute_command(&self, cmd: &[u8]) -> Result<Vec<u8>> { ... }
    fn read_status(&self) -> Result<TpmStatus> { ... }
    fn poll_for_data_available(&self) -> Result<TpmStatus> { ... }
    fn poll_for_ready(&self) -> Result<TpmStatus> { ... }
}
Expand description

Low level interface for accessing TPM. Separate implementations exist for SPI and I2C.

Required Methods§

source

fn read_register(&self, register: Register, data: &mut [u8]) -> Result<()>

Read from the given TPM register, number of bytes to read given by length of data slice.

source

fn write_register(&self, register: Register, data: &[u8]) -> Result<()>

Write to the given TPM register.

Provided Methods§

source

fn init(&self) -> Result<()>

Initialize the TPM by claiming the access register.

source

fn execute_command(&self, cmd: &[u8]) -> Result<Vec<u8>>

Execute a TPM command and return the result as a Vec<u8> or time out.

source

fn read_status(&self) -> Result<TpmStatus>

Fetches the current status.

source

fn poll_for_data_available(&self) -> Result<TpmStatus>

Poll the status register until the status is valid and data is available or time out.

source

fn poll_for_ready(&self) -> Result<TpmStatus>

Poll the status register until the status is valid and the tpm is ready or time out.

Implementors§