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 <Library/BaseMemoryLib.h>
17 #include <Library/BaseLib.h>
18 #include <Library/Tpm12DeviceLib.h>
23 TPM_RQU_COMMAND_HDR Hdr
;
24 TPM_STARTUP_TYPE TpmSt
;
30 Send Startup command to TPM1.2.
32 @param TpmSt Startup Type.
34 @retval EFI_SUCCESS Operation completed successfully.
35 @retval EFI_DEVICE_ERROR Unexpected device behavior.
40 IN TPM_STARTUP_TYPE TpmSt
44 TPM_CMD_START_UP Command
;
45 TPM_RSP_COMMAND_HDR Response
;
49 // send Tpm command TPM_ORD_Startup
51 Command
.Hdr
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
52 Command
.Hdr
.paramSize
= SwapBytes32 (sizeof (Command
));
53 Command
.Hdr
.ordinal
= SwapBytes32 (TPM_ORD_Startup
);
54 Command
.TpmSt
= SwapBytes16 (TpmSt
);
55 Length
= sizeof (Response
);
56 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
57 if (EFI_ERROR (Status
)) {
60 switch (SwapBytes32(Response
.returnCode
)) {
62 case TPM_INVALID_POSTINIT
:
63 // In warm reset, TPM may response TPM_INVALID_POSTINIT
66 return EFI_DEVICE_ERROR
;
71 Send SaveState command to TPM1.2.
73 @retval EFI_SUCCESS Operation completed successfully.
74 @retval EFI_DEVICE_ERROR Unexpected device behavior.
83 TPM_RQU_COMMAND_HDR Command
;
84 TPM_RSP_COMMAND_HDR Response
;
88 // send Tpm command TPM_ORD_SaveState
90 Command
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
91 Command
.paramSize
= SwapBytes32 (sizeof (Command
));
92 Command
.ordinal
= SwapBytes32 (TPM_ORD_SaveState
);
93 Length
= sizeof (Response
);
94 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
95 if (EFI_ERROR (Status
)) {
98 switch (SwapBytes32 (Response
.returnCode
)) {
102 return EFI_DEVICE_ERROR
;