]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Tcg/TcgPei/TpmComm.h
Handle TPM device error and avoid deadloop in BDS.
[mirror_edk2.git] / SecurityPkg / Tcg / TcgPei / TpmComm.h
1 /** @file
2 The header file for TPM PEI driver.
3
4 Copyright (c) 2005 - 2010, 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
9
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.
12
13 **/
14
15 #ifndef _TPM_COMM_H_
16 #define _TPM_COMM_H_
17
18 #include <IndustryStandard/Tpm12.h>
19 #include <IndustryStandard/UefiTcgPlatform.h>
20 #include <Library/TpmCommLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/BaseLib.h>
23 #include <Library/BaseMemoryLib.h>
24
25 #pragma pack(1)
26
27 typedef struct {
28 TPM_RQU_COMMAND_HDR Hdr;
29 TPM_STARTUP_TYPE TpmSt;
30 } TPM_CMD_START_UP;
31
32 typedef struct {
33 TPM_RQU_COMMAND_HDR Hdr;
34 } TPM_CMD_SELF_TEST;
35
36 typedef struct {
37 TPM_RQU_COMMAND_HDR Hdr;
38 UINT32 Capability;
39 UINT32 CapabilityFlagSize;
40 UINT32 CapabilityFlag;
41 } TPM_CMD_GET_CAPABILITY;
42
43 typedef struct {
44 TPM_RQU_COMMAND_HDR Hdr;
45 TPM_PCRINDEX PcrIndex;
46 TPM_DIGEST TpmDigest;
47 } TPM_CMD_EXTEND;
48
49 typedef struct {
50 TPM_RQU_COMMAND_HDR Hdr;
51 TPM_PHYSICAL_PRESENCE PhysicalPresence;
52 } TPM_CMD_PHYSICAL_PRESENCE;
53
54 #pragma pack()
55
56 /**
57 Send TPM_Startup command to TPM.
58
59 @param[in] PeiServices Describes the list of possible PEI Services.
60 @param[in] TpmHandle TPM handle.
61 @param[in] BootMode Boot mode.
62
63 @retval EFI_SUCCESS Operation completed successfully.
64 @retval EFI_TIMEOUT The register can't run into the expected status in time.
65 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
66 @retval EFI_DEVICE_ERROR Unexpected device behavior.
67
68 **/
69 EFI_STATUS
70 TpmCommStartup (
71 IN EFI_PEI_SERVICES **PeiServices,
72 IN TIS_TPM_HANDLE TpmHandle,
73 IN EFI_BOOT_MODE BootMode
74 );
75
76 /**
77 Send TPM_ContinueSelfTest command to TPM.
78
79 @param[in] PeiServices Describes the list of possible PEI Services.
80 @param[in] TpmHandle TPM handle.
81
82 @retval EFI_SUCCESS Operation completed successfully.
83 @retval EFI_TIMEOUT The register can't run into the expected status in time.
84 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
85 @retval EFI_DEVICE_ERROR Unexpected device behavior.
86
87 **/
88 EFI_STATUS
89 TpmCommContinueSelfTest (
90 IN EFI_PEI_SERVICES **PeiServices,
91 IN TIS_TPM_HANDLE TpmHandle
92 );
93
94 /**
95 Get TPM capability flags.
96
97 @param[in] PeiServices Describes the list of possible PEI Services.
98 @param[in] TpmHandle TPM handle.
99 @param[out] Deactivated Returns deactivated flag.
100 @param[out] LifetimeLock Returns physicalPresenceLifetimeLock permanent flag.
101 @param[out] CmdEnable Returns physicalPresenceCMDEnable permanent flag.
102
103 @retval EFI_SUCCESS Operation completed successfully.
104 @retval EFI_TIMEOUT The register can't run into the expected status in time.
105 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
106 @retval EFI_DEVICE_ERROR Unexpected device behavior.
107
108 **/
109 EFI_STATUS
110 TpmCommGetCapability (
111 IN EFI_PEI_SERVICES **PeiServices,
112 IN TIS_TPM_HANDLE TpmHandle,
113 OUT BOOLEAN *Deactivated, OPTIONAL
114 OUT BOOLEAN *LifetimeLock, OPTIONAL
115 OUT BOOLEAN *CmdEnable OPTIONAL
116 );
117
118 /**
119 Extend a TPM PCR.
120
121 @param[in] PeiServices Describes the list of possible PEI Services.
122 @param[in] TpmHandle TPM handle.
123 @param[in] DigestToExtend The 160 bit value representing the event to be recorded.
124 @param[in] PcrIndex The PCR to be updated.
125 @param[out] NewPcrValue New PCR value after extend.
126
127 @retval EFI_SUCCESS Operation completed successfully.
128 @retval EFI_TIMEOUT The register can't run into the expected status in time.
129 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
130 @retval EFI_DEVICE_ERROR Unexpected device behavior.
131
132 **/
133 EFI_STATUS
134 TpmCommExtend (
135 IN EFI_PEI_SERVICES **PeiServices,
136 IN TIS_TPM_HANDLE TpmHandle,
137 IN TPM_DIGEST *DigestToExtend,
138 IN TPM_PCRINDEX PcrIndex,
139 OUT TPM_DIGEST *NewPcrValue
140 );
141
142
143 /**
144 Send TSC_PhysicalPresence command to TPM.
145
146 @param[in] PeiServices Describes the list of possible PEI Services.
147 @param[in] TpmHandle TPM handle.
148 @param[in] PhysicalPresence The state to set the TPMs Physical Presence flags.
149
150 @retval EFI_SUCCESS Operation completed successfully.
151 @retval EFI_TIMEOUT The register can't run into the expected status in time.
152 @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
153 @retval EFI_DEVICE_ERROR Unexpected device behavior.
154
155 **/
156 EFI_STATUS
157 TpmCommPhysicalPresence (
158 IN EFI_PEI_SERVICES **PeiServices,
159 IN TIS_TPM_HANDLE TpmHandle,
160 IN TPM_PHYSICAL_PRESENCE PhysicalPresence
161 );
162
163 #endif // _TPM_COMM_H_