2 Implement TPM2 Startup related command.
4 Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <IndustryStandard/UefiTcgPlatform.h>
16 #include <Library/Tpm2CommandLib.h>
17 #include <Library/Tpm2DeviceLib.h>
18 #include <Library/BaseMemoryLib.h>
19 #include <Library/BaseLib.h>
20 #include <Library/DebugLib.h>
25 TPM2_COMMAND_HEADER Header
;
27 } TPM2_STARTUP_COMMAND
;
30 TPM2_RESPONSE_HEADER Header
;
31 } TPM2_STARTUP_RESPONSE
;
34 TPM2_COMMAND_HEADER Header
;
36 } TPM2_SHUTDOWN_COMMAND
;
39 TPM2_RESPONSE_HEADER Header
;
40 } TPM2_SHUTDOWN_RESPONSE
;
45 Send Startup command to TPM2.
47 @param[in] StartupType TPM_SU_CLEAR or TPM_SU_STATE
49 @retval EFI_SUCCESS Operation completed successfully.
50 @retval EFI_DEVICE_ERROR Unexpected device behavior.
59 TPM2_STARTUP_COMMAND Cmd
;
60 TPM2_STARTUP_RESPONSE Res
;
63 Cmd
.Header
.tag
= SwapBytes16(TPM_ST_NO_SESSIONS
);
64 Cmd
.Header
.paramSize
= SwapBytes32(sizeof(Cmd
));
65 Cmd
.Header
.commandCode
= SwapBytes32(TPM_CC_Startup
);
66 Cmd
.StartupType
= SwapBytes16(StartupType
);
68 ResultBufSize
= sizeof(Res
);
69 Status
= Tpm2SubmitCommand (sizeof(Cmd
), (UINT8
*)&Cmd
, &ResultBufSize
, (UINT8
*)&Res
);
75 Send Shutdown command to TPM2.
77 @param[in] ShutdownType TPM_SU_CLEAR or TPM_SU_STATE.
79 @retval EFI_SUCCESS Operation completed successfully.
80 @retval EFI_DEVICE_ERROR Unexpected device behavior.
85 IN TPM_SU ShutdownType
89 TPM2_SHUTDOWN_COMMAND Cmd
;
90 TPM2_SHUTDOWN_RESPONSE Res
;
93 Cmd
.Header
.tag
= SwapBytes16(TPM_ST_NO_SESSIONS
);
94 Cmd
.Header
.paramSize
= SwapBytes32(sizeof(Cmd
));
95 Cmd
.Header
.commandCode
= SwapBytes32(TPM_CC_Shutdown
);
96 Cmd
.ShutdownType
= SwapBytes16(ShutdownType
);
98 ResultBufSize
= sizeof(Res
);
99 Status
= Tpm2SubmitCommand (sizeof(Cmd
), (UINT8
*)&Cmd
, &ResultBufSize
, (UINT8
*)&Res
);