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