]>
Commit | Line | Data |
---|---|---|
0c18794e | 1 | /** @file\r |
2 | The header file for TPM PEI driver.\r | |
3 | \r | |
b558f8bc | 4 | Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r |
0c18794e | 5 | This program and the accompanying materials \r |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT 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 | |
b558f8bc MK |
20 | #include <Library/MemoryAllocationLib.h>\r |
21 | #include <Library/BaseCryptLib.h>\r | |
22 | #include <Library/Tpm12DeviceLib.h>\r | |
0c18794e | 23 | #include <Library/DebugLib.h>\r |
24 | #include <Library/BaseLib.h>\r | |
25 | #include <Library/BaseMemoryLib.h>\r | |
26 | \r | |
27 | #pragma pack(1)\r | |
28 | \r | |
29 | typedef struct {\r | |
30 | TPM_RQU_COMMAND_HDR Hdr;\r | |
31 | TPM_STARTUP_TYPE TpmSt;\r | |
32 | } TPM_CMD_START_UP;\r | |
33 | \r | |
34 | typedef struct {\r | |
35 | TPM_RQU_COMMAND_HDR Hdr;\r | |
36 | } TPM_CMD_SELF_TEST;\r | |
37 | \r | |
38 | typedef struct {\r | |
39 | TPM_RQU_COMMAND_HDR Hdr;\r | |
40 | UINT32 Capability;\r | |
41 | UINT32 CapabilityFlagSize;\r | |
42 | UINT32 CapabilityFlag;\r | |
43 | } TPM_CMD_GET_CAPABILITY;\r | |
44 | \r | |
45 | typedef struct {\r | |
46 | TPM_RQU_COMMAND_HDR Hdr;\r | |
47 | TPM_PCRINDEX PcrIndex;\r | |
48 | TPM_DIGEST TpmDigest;\r | |
49 | } TPM_CMD_EXTEND;\r | |
50 | \r | |
51 | typedef struct {\r | |
52 | TPM_RQU_COMMAND_HDR Hdr;\r | |
53 | TPM_PHYSICAL_PRESENCE PhysicalPresence;\r | |
54 | } TPM_CMD_PHYSICAL_PRESENCE;\r | |
55 | \r | |
56 | #pragma pack()\r | |
57 | \r | |
58 | /**\r | |
59 | Send TPM_Startup command to TPM.\r | |
60 | \r | |
61 | @param[in] PeiServices Describes the list of possible PEI Services.\r | |
0c18794e | 62 | @param[in] BootMode Boot mode. \r |
b558f8bc | 63 | \r |
0c18794e | 64 | @retval EFI_SUCCESS Operation completed successfully.\r |
65 | @retval EFI_TIMEOUT The register can't run into the expected status in time.\r | |
66 | @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.\r | |
67 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
68 | \r | |
69 | **/\r | |
70 | EFI_STATUS\r | |
71 | TpmCommStartup (\r | |
72 | IN EFI_PEI_SERVICES **PeiServices,\r | |
0c18794e | 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 | |
b558f8bc | 80 | \r |
0c18794e | 81 | @retval EFI_SUCCESS Operation completed successfully.\r |
82 | @retval EFI_TIMEOUT The register can't run into the expected status in time.\r | |
83 | @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.\r | |
84 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
85 | \r | |
86 | **/\r | |
87 | EFI_STATUS\r | |
88 | TpmCommContinueSelfTest (\r | |
b558f8bc | 89 | IN EFI_PEI_SERVICES **PeiServices\r |
0c18794e | 90 | );\r |
91 | \r | |
92 | /**\r | |
93 | Get TPM capability flags.\r | |
94 | \r | |
95 | @param[in] PeiServices Describes the list of possible PEI Services.\r | |
96 | @param[in] TpmHandle TPM handle. \r | |
97 | @param[out] Deactivated Returns deactivated flag.\r | |
98 | @param[out] LifetimeLock Returns physicalPresenceLifetimeLock permanent flag. \r | |
99 | @param[out] CmdEnable Returns physicalPresenceCMDEnable permanent flag.\r | |
100 | \r | |
101 | @retval EFI_SUCCESS Operation completed successfully.\r | |
102 | @retval EFI_TIMEOUT The register can't run into the expected status in time.\r | |
103 | @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.\r | |
104 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
105 | \r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | TpmCommGetCapability (\r | |
109 | IN EFI_PEI_SERVICES **PeiServices,\r | |
0c18794e | 110 | OUT BOOLEAN *Deactivated, OPTIONAL\r |
111 | OUT BOOLEAN *LifetimeLock, OPTIONAL\r | |
112 | OUT BOOLEAN *CmdEnable OPTIONAL\r | |
113 | );\r | |
114 | \r | |
115 | /**\r | |
116 | Extend a TPM PCR.\r | |
117 | \r | |
118 | @param[in] PeiServices Describes the list of possible PEI Services.\r | |
119 | @param[in] TpmHandle TPM handle. \r | |
120 | @param[in] DigestToExtend The 160 bit value representing the event to be recorded. \r | |
121 | @param[in] PcrIndex The PCR to be updated.\r | |
122 | @param[out] NewPcrValue New PCR value after extend. \r | |
123 | \r | |
124 | @retval EFI_SUCCESS Operation completed successfully.\r | |
125 | @retval EFI_TIMEOUT The register can't run into the expected status in time.\r | |
126 | @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.\r | |
127 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
128 | \r | |
129 | **/\r | |
130 | EFI_STATUS\r | |
131 | TpmCommExtend (\r | |
132 | IN EFI_PEI_SERVICES **PeiServices,\r | |
0c18794e | 133 | IN TPM_DIGEST *DigestToExtend,\r |
134 | IN TPM_PCRINDEX PcrIndex,\r | |
135 | OUT TPM_DIGEST *NewPcrValue\r | |
136 | );\r | |
137 | \r | |
138 | \r | |
139 | /**\r | |
140 | Send TSC_PhysicalPresence command to TPM.\r | |
141 | \r | |
142 | @param[in] PeiServices Describes the list of possible PEI Services.\r | |
143 | @param[in] TpmHandle TPM handle. \r | |
144 | @param[in] PhysicalPresence The state to set the TPMs Physical Presence flags. \r | |
145 | \r | |
146 | @retval EFI_SUCCESS Operation completed successfully.\r | |
147 | @retval EFI_TIMEOUT The register can't run into the expected status in time.\r | |
148 | @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.\r | |
149 | @retval EFI_DEVICE_ERROR Unexpected device behavior.\r | |
150 | \r | |
151 | **/\r | |
152 | EFI_STATUS\r | |
153 | TpmCommPhysicalPresence (\r | |
154 | IN EFI_PEI_SERVICES **PeiServices,\r | |
0c18794e | 155 | IN TPM_PHYSICAL_PRESENCE PhysicalPresence\r |
156 | );\r | |
157 | \r | |
b558f8bc MK |
158 | /**\r |
159 | Single function calculates SHA1 digest value for all raw data. It\r | |
160 | combines Sha1Init(), Sha1Update() and Sha1Final().\r | |
161 | \r | |
162 | @param[in] Data Raw data to be digested.\r | |
163 | @param[in] DataLen Size of the raw data.\r | |
164 | @param[out] Digest Pointer to a buffer that stores the final digest.\r | |
165 | \r | |
166 | @retval EFI_SUCCESS Always successfully calculate the final digest.\r | |
167 | **/\r | |
168 | EFI_STATUS\r | |
169 | EFIAPI\r | |
170 | TpmCommHashAll (\r | |
171 | IN CONST UINT8 *Data,\r | |
172 | IN UINTN DataLen,\r | |
173 | OUT TPM_DIGEST *Digest\r | |
174 | );\r | |
175 | \r | |
0c18794e | 176 | #endif // _TPM_COMM_H_\r |