tss_esapi/context/tpm_commands/
startup.rs1use crate::{
4 constants::StartupType,
5 tss2_esys::{Esys_Shutdown, Esys_Startup},
6 Context, Result, ReturnCode,
7};
8use log::error;
9
10impl Context {
11 pub fn startup(&mut self, startup_type: StartupType) -> Result<()> {
13 ReturnCode::ensure_success(
14 unsafe { Esys_Startup(self.mut_context(), startup_type.into()) },
15 |ret| {
16 error!("Error while starting up TPM: {:#010X}", ret);
17 },
18 )
19 }
20
21 pub fn shutdown(&mut self, shutdown_type: StartupType) -> Result<()> {
23 ReturnCode::ensure_success(
24 unsafe {
25 Esys_Shutdown(
26 self.mut_context(),
27 self.optional_session_1(),
28 self.optional_session_2(),
29 self.optional_session_3(),
30 shutdown_type.into(),
31 )
32 },
33 |ret| {
34 error!("Error while shutting down TPM: {:#010X}", ret);
35 },
36 )
37 }
38}