2 Implement TPM1.2 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.
16 #include <IndustryStandard/Tpm12.h>
17 #include <Library/BaseMemoryLib.h>
18 #include <Library/BaseLib.h>
19 #include <Library/Tpm12DeviceLib.h>
24 TPM_RQU_COMMAND_HDR Hdr
;
25 TPM_STARTUP_TYPE TpmSt
;
29 TPM_RSP_COMMAND_HDR Hdr
;
35 Send Startup command to TPM1.2.
37 @param TpmSt Startup Type.
39 @retval EFI_SUCCESS Operation completed successfully.
40 @retval EFI_DEVICE_ERROR Unexpected device behavior.
45 IN TPM_STARTUP_TYPE TpmSt
51 TPM_CMD_START_UP SendBuffer
;
52 TPM_RSP_START_UP RecvBuffer
;
56 // send Tpm command TPM_ORD_Startup
58 TpmRecvSize
= sizeof (TPM_RSP_START_UP
);
59 TpmSendSize
= sizeof (TPM_CMD_START_UP
);
60 SendBuffer
.Hdr
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
61 SendBuffer
.Hdr
.paramSize
= SwapBytes32 (TpmSendSize
);
62 SendBuffer
.Hdr
.ordinal
= SwapBytes32 (TPM_ORD_Startup
);
63 SendBuffer
.TpmSt
= SwapBytes16 (TpmSt
);
65 Status
= Tpm12SubmitCommand (TpmSendSize
, (UINT8
*)&SendBuffer
, &TpmRecvSize
, (UINT8
*)&RecvBuffer
);
66 if (EFI_ERROR (Status
)) {
69 ReturnCode
= SwapBytes32(RecvBuffer
.Hdr
.returnCode
);
72 case TPM_INVALID_POSTINIT
:
73 // In warm reset, TPM may response TPM_INVALID_POSTINIT
76 return EFI_DEVICE_ERROR
;