(path: impl AsRef<Path>)
| 229 | |
| 230 | impl Tpm { |
| 231 | pub fn new(path: impl AsRef<Path>) -> Result<Self> { |
| 232 | let emulator = Emulator::new(path) |
| 233 | .map_err(|e| Error::Init(anyhow!("Failed while initializing tpm Emulator: {e:?}")))?; |
| 234 | let mut tpm = Tpm { |
| 235 | emulator, |
| 236 | regs: [0; TPM_CRB_R_MAX], |
| 237 | backend_buff_size: TPM_CRB_BUFFER_MAX, |
| 238 | data_buff: [0; TPM_CRB_BUFFER_MAX], |
| 239 | data_buff_len: 0, |
| 240 | }; |
| 241 | tpm.reset()?; |
| 242 | Ok(tpm) |
| 243 | } |
| 244 | |
| 245 | fn get_active_locality(&mut self) -> u32 { |
| 246 | if get_reg_field( |