TianoCore EDK2 master
Loading...
Searching...
No Matches
Tpm12Startup.c
Go to the documentation of this file.
1
10#include <PiPei.h>
12#include <Library/BaseLib.h>
14#include <Library/DebugLib.h>
15
16#pragma pack(1)
17
18typedef struct {
20 TPM_STARTUP_TYPE TpmSt;
22
23#pragma pack()
24
34EFIAPI
37 )
38{
39 EFI_STATUS Status;
40 TPM_CMD_START_UP Command;
41 TPM_RSP_COMMAND_HDR Response;
42 UINT32 Length;
43
44 //
45 // send Tpm command TPM_ORD_Startup
46 //
47 Command.Hdr.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
48 Command.Hdr.paramSize = SwapBytes32 (sizeof (Command));
49 Command.Hdr.ordinal = SwapBytes32 (TPM_ORD_Startup);
50 Command.TpmSt = SwapBytes16 (TpmSt);
51 Length = sizeof (Response);
52 Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);
53 if (EFI_ERROR (Status)) {
54 return Status;
55 }
56
57 switch (SwapBytes32 (Response.returnCode)) {
58 case TPM_SUCCESS:
59 DEBUG ((DEBUG_INFO, "TPM12Startup: TPM_SUCCESS\n"));
60 return EFI_SUCCESS;
61 case TPM_INVALID_POSTINIT:
62 // In warm reset, TPM may response TPM_INVALID_POSTINIT
63 DEBUG ((DEBUG_INFO, "TPM12Startup: TPM_INVALID_POSTINIT\n"));
64 return EFI_SUCCESS;
65 default:
66 return EFI_DEVICE_ERROR;
67 }
68}
69
77EFIAPI
79 VOID
80 )
81{
82 EFI_STATUS Status;
83 TPM_RQU_COMMAND_HDR Command;
84 TPM_RSP_COMMAND_HDR Response;
85 UINT32 Length;
86
87 //
88 // send Tpm command TPM_ORD_SaveState
89 //
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)) {
96 return Status;
97 }
98
99 switch (SwapBytes32 (Response.returnCode)) {
100 case TPM_SUCCESS:
101 return EFI_SUCCESS;
102 default:
103 return EFI_DEVICE_ERROR;
104 }
105}
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
Definition: SwapBytes16.c:25
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
Definition: SwapBytes32.c:25
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
UINT16 TPM_STARTUP_TYPE
Definition: Tpm12.h:53
EFI_STATUS EFIAPI Tpm12SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
Definition: Tpm12Tis.c:453
EFI_STATUS EFIAPI Tpm12SaveState(VOID)
Definition: Tpm12Startup.c:78
EFI_STATUS EFIAPI Tpm12Startup(IN TPM_STARTUP_TYPE TpmSt)
Definition: Tpm12Startup.c:35
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112