2 Implement TPM1.2 Startup related command.
4 Copyright (c) 2013, Intel Corporation. All rights reserved. <BR>
5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Library/BaseMemoryLib.h>
18 #include <Library/BaseLib.h>
19 #include <Library/Tpm12DeviceLib.h>
20 #include <Library/DebugLib.h>
25 TPM_RQU_COMMAND_HDR Hdr
;
26 TPM_STARTUP_TYPE TpmSt
;
32 Send Startup command to TPM1.2.
34 @param TpmSt Startup Type.
36 @retval EFI_SUCCESS Operation completed successfully.
37 @retval EFI_DEVICE_ERROR Unexpected device behavior.
42 IN TPM_STARTUP_TYPE TpmSt
46 TPM_CMD_START_UP Command
;
47 TPM_RSP_COMMAND_HDR Response
;
51 // send Tpm command TPM_ORD_Startup
53 Command
.Hdr
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
54 Command
.Hdr
.paramSize
= SwapBytes32 (sizeof (Command
));
55 Command
.Hdr
.ordinal
= SwapBytes32 (TPM_ORD_Startup
);
56 Command
.TpmSt
= SwapBytes16 (TpmSt
);
57 Length
= sizeof (Response
);
58 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
59 if (EFI_ERROR (Status
)) {
62 switch (SwapBytes32(Response
.returnCode
)) {
64 DEBUG ((DEBUG_INFO
, "TPM12Startup: TPM_SUCCESS\n"));
66 case TPM_INVALID_POSTINIT
:
67 // In warm reset, TPM may response TPM_INVALID_POSTINIT
68 DEBUG ((DEBUG_INFO
, "TPM12Startup: TPM_INVALID_POSTINIT\n"));
71 return EFI_DEVICE_ERROR
;
76 Send SaveState command to TPM1.2.
78 @retval EFI_SUCCESS Operation completed successfully.
79 @retval EFI_DEVICE_ERROR Unexpected device behavior.
88 TPM_RQU_COMMAND_HDR Command
;
89 TPM_RSP_COMMAND_HDR Response
;
93 // send Tpm command TPM_ORD_SaveState
95 Command
.tag
= SwapBytes16 (TPM_TAG_RQU_COMMAND
);
96 Command
.paramSize
= SwapBytes32 (sizeof (Command
));
97 Command
.ordinal
= SwapBytes32 (TPM_ORD_SaveState
);
98 Length
= sizeof (Response
);
99 Status
= Tpm12SubmitCommand (sizeof (Command
), (UINT8
*)&Command
, &Length
, (UINT8
*)&Response
);
100 if (EFI_ERROR (Status
)) {
103 switch (SwapBytes32 (Response
.returnCode
)) {
107 return EFI_DEVICE_ERROR
;