]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | HII Config Access protocol implementation of TCG2 configuration module.\r | |
3 | NOTE: This module is only for reference only, each platform should have its own setup page.\r | |
4 | \r | |
5 | Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r | |
6 | This program and the accompanying materials \r | |
7 | are licensed and made available under the terms and conditions of the BSD License \r | |
8 | which accompanies this distribution. The full text of the license may be found at \r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "Tcg2ConfigImpl.h"\r | |
17 | #include <Library/PcdLib.h>\r | |
18 | #include <Library/Tpm2CommandLib.h>\r | |
19 | #include <Library/IoLib.h>\r | |
20 | #include <Guid/TpmInstance.h>\r | |
21 | \r | |
22 | #include <IndustryStandard/TpmPtp.h>\r | |
23 | \r | |
24 | #define EFI_TCG2_EVENT_LOG_FORMAT_ALL (EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 | EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)\r | |
25 | \r | |
26 | TPM_INSTANCE_ID mTpmInstanceId[TPM_DEVICE_MAX + 1] = TPM_INSTANCE_ID_LIST;\r | |
27 | \r | |
28 | TCG2_CONFIG_PRIVATE_DATA *mTcg2ConfigPrivateDate;\r | |
29 | TCG2_CONFIG_PRIVATE_DATA mTcg2ConfigPrivateDateTemplate = {\r | |
30 | TCG2_CONFIG_PRIVATE_DATA_SIGNATURE,\r | |
31 | {\r | |
32 | Tcg2ExtractConfig,\r | |
33 | Tcg2RouteConfig,\r | |
34 | Tcg2Callback\r | |
35 | }\r | |
36 | };\r | |
37 | \r | |
38 | HII_VENDOR_DEVICE_PATH mTcg2HiiVendorDevicePath = {\r | |
39 | {\r | |
40 | {\r | |
41 | HARDWARE_DEVICE_PATH,\r | |
42 | HW_VENDOR_DP,\r | |
43 | {\r | |
44 | (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r | |
45 | (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r | |
46 | }\r | |
47 | },\r | |
48 | TCG2_CONFIG_FORM_SET_GUID\r | |
49 | },\r | |
50 | {\r | |
51 | END_DEVICE_PATH_TYPE,\r | |
52 | END_ENTIRE_DEVICE_PATH_SUBTYPE,\r | |
53 | { \r | |
54 | (UINT8) (END_DEVICE_PATH_LENGTH),\r | |
55 | (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r | |
56 | }\r | |
57 | }\r | |
58 | };\r | |
59 | \r | |
60 | UINT8 mCurrentPpRequest;\r | |
61 | \r | |
62 | /**\r | |
63 | Return PTP interface type.\r | |
64 | \r | |
65 | @param[in] Register Pointer to PTP register.\r | |
66 | \r | |
67 | @return PTP interface type.\r | |
68 | **/\r | |
69 | UINT8\r | |
70 | GetPtpInterface (\r | |
71 | IN VOID *Register\r | |
72 | )\r | |
73 | {\r | |
74 | PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;\r | |
75 | PTP_FIFO_INTERFACE_CAPABILITY InterfaceCapability;\r | |
76 | \r | |
77 | //\r | |
78 | // Check interface id\r | |
79 | //\r | |
80 | InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);\r | |
81 | InterfaceCapability.Uint32 = MmioRead32 ((UINTN)&((PTP_FIFO_REGISTERS *)Register)->InterfaceCapability);\r | |
82 | \r | |
83 | if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_CRB) &&\r | |
84 | (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_CRB) &&\r | |
85 | (InterfaceId.Bits.CapCRB != 0)) {\r | |
86 | return TPM_DEVICE_INTERFACE_PTP_CRB;\r | |
87 | }\r | |
88 | if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO) &&\r | |
89 | (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_FIFO) &&\r | |
90 | (InterfaceId.Bits.CapFIFO != 0) &&\r | |
91 | (InterfaceCapability.Bits.InterfaceVersion == INTERFACE_CAPABILITY_INTERFACE_VERSION_PTP)) {\r | |
92 | return TPM_DEVICE_INTERFACE_PTP_FIFO;\r | |
93 | }\r | |
94 | return TPM_DEVICE_INTERFACE_TIS;\r | |
95 | }\r | |
96 | \r | |
97 | /**\r | |
98 | Return if PTP CRB is supported.\r | |
99 | \r | |
100 | @param[in] Register Pointer to PTP register.\r | |
101 | \r | |
102 | @retval TRUE PTP CRB is supported.\r | |
103 | @retval FALSE PTP CRB is unsupported.\r | |
104 | **/\r | |
105 | BOOLEAN\r | |
106 | IsPtpCrbSupported (\r | |
107 | IN VOID *Register\r | |
108 | )\r | |
109 | {\r | |
110 | PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;\r | |
111 | \r | |
112 | //\r | |
113 | // Check interface id\r | |
114 | //\r | |
115 | InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);\r | |
116 | \r | |
117 | if (((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_CRB) ||\r | |
118 | (InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO)) &&\r | |
119 | (InterfaceId.Bits.CapCRB != 0)) {\r | |
120 | return TRUE;\r | |
121 | }\r | |
122 | return FALSE;\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
126 | Return if PTP FIFO is supported.\r | |
127 | \r | |
128 | @param[in] Register Pointer to PTP register.\r | |
129 | \r | |
130 | @retval TRUE PTP FIFO is supported.\r | |
131 | @retval FALSE PTP FIFO is unsupported.\r | |
132 | **/\r | |
133 | BOOLEAN\r | |
134 | IsPtpFifoSupported (\r | |
135 | IN VOID *Register\r | |
136 | )\r | |
137 | {\r | |
138 | PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;\r | |
139 | \r | |
140 | //\r | |
141 | // Check interface id\r | |
142 | //\r | |
143 | InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);\r | |
144 | \r | |
145 | if (((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_CRB) ||\r | |
146 | (InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO)) &&\r | |
147 | (InterfaceId.Bits.CapFIFO != 0)) {\r | |
148 | return TRUE;\r | |
149 | }\r | |
150 | return FALSE;\r | |
151 | }\r | |
152 | \r | |
153 | /**\r | |
154 | Set PTP interface type.\r | |
155 | \r | |
156 | @param[in] Register Pointer to PTP register.\r | |
157 | @param[in] PtpInterface PTP interface type.\r | |
158 | \r | |
159 | @retval EFI_SUCCESS PTP interface type is set.\r | |
160 | @retval EFI_INVALID_PARAMETER PTP interface type is invalid.\r | |
161 | @retval EFI_UNSUPPORTED PTP interface type is unsupported.\r | |
162 | @retval EFI_WRITE_PROTECTED PTP interface is locked.\r | |
163 | **/\r | |
164 | EFI_STATUS\r | |
165 | SetPtpInterface (\r | |
166 | IN VOID *Register,\r | |
167 | IN UINT8 PtpInterface\r | |
168 | )\r | |
169 | {\r | |
170 | UINT8 PtpInterfaceCurrent;\r | |
171 | PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;\r | |
172 | \r | |
173 | PtpInterfaceCurrent = GetPtpInterface (Register);\r | |
174 | if ((PtpInterfaceCurrent != TPM_DEVICE_INTERFACE_PTP_FIFO) && \r | |
175 | (PtpInterfaceCurrent != TPM_DEVICE_INTERFACE_PTP_CRB)) {\r | |
176 | return EFI_UNSUPPORTED;\r | |
177 | }\r | |
178 | InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);\r | |
179 | if (InterfaceId.Bits.IntfSelLock != 0) {\r | |
180 | return EFI_WRITE_PROTECTED;\r | |
181 | }\r | |
182 | \r | |
183 | switch (PtpInterface) {\r | |
184 | case TPM_DEVICE_INTERFACE_PTP_FIFO:\r | |
185 | if (InterfaceId.Bits.CapFIFO == 0) {\r | |
186 | return EFI_UNSUPPORTED;\r | |
187 | }\r | |
188 | InterfaceId.Bits.InterfaceSelector = PTP_INTERFACE_IDENTIFIER_INTERFACE_SELECTOR_FIFO;\r | |
189 | MmioWrite32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId, InterfaceId.Uint32);\r | |
190 | return EFI_SUCCESS;\r | |
191 | case TPM_DEVICE_INTERFACE_PTP_CRB:\r | |
192 | if (InterfaceId.Bits.CapCRB == 0) {\r | |
193 | return EFI_UNSUPPORTED;\r | |
194 | }\r | |
195 | InterfaceId.Bits.InterfaceSelector = PTP_INTERFACE_IDENTIFIER_INTERFACE_SELECTOR_CRB;\r | |
196 | MmioWrite32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId, InterfaceId.Uint32);\r | |
197 | return EFI_SUCCESS;\r | |
198 | default:\r | |
199 | return EFI_INVALID_PARAMETER;\r | |
200 | }\r | |
201 | }\r | |
202 | \r | |
203 | /**\r | |
204 | This function allows a caller to extract the current configuration for one\r | |
205 | or more named elements from the target driver.\r | |
206 | \r | |
207 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
208 | @param[in] Request A null-terminated Unicode string in\r | |
209 | <ConfigRequest> format.\r | |
210 | @param[out] Progress On return, points to a character in the Request\r | |
211 | string. Points to the string's null terminator if\r | |
212 | request was successful. Points to the most recent\r | |
213 | '&' before the first failing name/value pair (or\r | |
214 | the beginning of the string if the failure is in\r | |
215 | the first name/value pair) if the request was not\r | |
216 | successful.\r | |
217 | @param[out] Results A null-terminated Unicode string in\r | |
218 | <ConfigAltResp> format which has all values filled\r | |
219 | in for the names in the Request string. String to\r | |
220 | be allocated by the called function.\r | |
221 | \r | |
222 | @retval EFI_SUCCESS The Results is filled with the requested values.\r | |
223 | @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r | |
224 | @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r | |
225 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
226 | driver.\r | |
227 | \r | |
228 | **/\r | |
229 | EFI_STATUS\r | |
230 | EFIAPI\r | |
231 | Tcg2ExtractConfig (\r | |
232 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
233 | IN CONST EFI_STRING Request,\r | |
234 | OUT EFI_STRING *Progress,\r | |
235 | OUT EFI_STRING *Results\r | |
236 | )\r | |
237 | {\r | |
238 | if (Progress == NULL || Results == NULL) {\r | |
239 | return EFI_INVALID_PARAMETER;\r | |
240 | }\r | |
241 | \r | |
242 | *Progress = Request;\r | |
243 | return EFI_NOT_FOUND;\r | |
244 | }\r | |
245 | \r | |
246 | /**\r | |
247 | Save TPM request to variable space.\r | |
248 | \r | |
249 | @param[in] PpRequest Physical Presence request command.\r | |
250 | \r | |
251 | @retval EFI_SUCCESS The operation is finished successfully.\r | |
252 | @retval Others Other errors as indicated.\r | |
253 | \r | |
254 | **/\r | |
255 | EFI_STATUS\r | |
256 | SaveTcg2PpRequest (\r | |
257 | IN UINT8 PpRequest\r | |
258 | )\r | |
259 | {\r | |
260 | UINT32 ReturnCode;\r | |
261 | EFI_STATUS Status;\r | |
262 | \r | |
263 | ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (PpRequest, 0);\r | |
264 | if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {\r | |
265 | mCurrentPpRequest = PpRequest;\r | |
266 | Status = EFI_SUCCESS;\r | |
267 | } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) {\r | |
268 | Status = EFI_OUT_OF_RESOURCES;\r | |
269 | } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) {\r | |
270 | Status = EFI_UNSUPPORTED;\r | |
271 | } else {\r | |
272 | Status = EFI_DEVICE_ERROR;\r | |
273 | }\r | |
274 | \r | |
275 | return Status;\r | |
276 | }\r | |
277 | \r | |
278 | /**\r | |
279 | Save TPM request to variable space.\r | |
280 | \r | |
281 | @param[in] PpRequestParameter Physical Presence request parameter.\r | |
282 | \r | |
283 | @retval EFI_SUCCESS The operation is finished successfully.\r | |
284 | @retval Others Other errors as indicated.\r | |
285 | \r | |
286 | **/\r | |
287 | EFI_STATUS\r | |
288 | SaveTcg2PpRequestParameter (\r | |
289 | IN UINT32 PpRequestParameter\r | |
290 | )\r | |
291 | {\r | |
292 | UINT32 ReturnCode;\r | |
293 | EFI_STATUS Status;\r | |
294 | \r | |
295 | ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (mCurrentPpRequest, PpRequestParameter);\r | |
296 | if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {\r | |
297 | Status = EFI_SUCCESS;\r | |
298 | } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) {\r | |
299 | Status = EFI_OUT_OF_RESOURCES;\r | |
300 | } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) {\r | |
301 | Status = EFI_UNSUPPORTED;\r | |
302 | } else {\r | |
303 | Status = EFI_DEVICE_ERROR;\r | |
304 | }\r | |
305 | \r | |
306 | return Status;\r | |
307 | }\r | |
308 | \r | |
309 | /**\r | |
310 | Save Tcg2 PCR Banks request request to variable space.\r | |
311 | \r | |
312 | @param[in] PCRBankIndex PCR Bank Index.\r | |
313 | @param[in] Enable Enable or disable this PCR Bank.\r | |
314 | \r | |
315 | @retval EFI_SUCCESS The operation is finished successfully.\r | |
316 | @retval Others Other errors as indicated.\r | |
317 | \r | |
318 | **/\r | |
319 | EFI_STATUS\r | |
320 | SaveTcg2PCRBanksRequest (\r | |
321 | IN UINTN PCRBankIndex,\r | |
322 | IN BOOLEAN Enable\r | |
323 | )\r | |
324 | {\r | |
325 | UINT32 ReturnCode;\r | |
326 | EFI_STATUS Status;\r | |
327 | \r | |
328 | if (Enable) {\r | |
329 | mTcg2ConfigPrivateDate->PCRBanksDesired |= (0x1 << PCRBankIndex);\r | |
330 | } else {\r | |
331 | mTcg2ConfigPrivateDate->PCRBanksDesired &= ~(0x1 << PCRBankIndex);\r | |
332 | }\r | |
333 | \r | |
334 | ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS, mTcg2ConfigPrivateDate->PCRBanksDesired);\r | |
335 | if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {\r | |
336 | Status = EFI_SUCCESS;\r | |
337 | } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) {\r | |
338 | Status = EFI_OUT_OF_RESOURCES;\r | |
339 | } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) {\r | |
340 | Status = EFI_UNSUPPORTED;\r | |
341 | } else {\r | |
342 | Status = EFI_DEVICE_ERROR;\r | |
343 | }\r | |
344 | \r | |
345 | return Status;\r | |
346 | }\r | |
347 | \r | |
348 | /**\r | |
349 | This function processes the results of changes in configuration.\r | |
350 | \r | |
351 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
352 | @param[in] Configuration A null-terminated Unicode string in <ConfigResp>\r | |
353 | format.\r | |
354 | @param[out] Progress A pointer to a string filled in with the offset of\r | |
355 | the most recent '&' before the first failing\r | |
356 | name/value pair (or the beginning of the string if\r | |
357 | the failure is in the first name/value pair) or\r | |
358 | the terminating NULL if all was successful.\r | |
359 | \r | |
360 | @retval EFI_SUCCESS The Results is processed successfully.\r | |
361 | @retval EFI_INVALID_PARAMETER Configuration is NULL.\r | |
362 | @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r | |
363 | driver.\r | |
364 | \r | |
365 | **/\r | |
366 | EFI_STATUS\r | |
367 | EFIAPI\r | |
368 | Tcg2RouteConfig (\r | |
369 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
370 | IN CONST EFI_STRING Configuration,\r | |
371 | OUT EFI_STRING *Progress\r | |
372 | )\r | |
373 | {\r | |
374 | if (Configuration == NULL || Progress == NULL) {\r | |
375 | return EFI_INVALID_PARAMETER;\r | |
376 | }\r | |
377 | \r | |
378 | return EFI_NOT_FOUND;\r | |
379 | }\r | |
380 | \r | |
381 | /**\r | |
382 | Get HID string of TPM2 ACPI device object\r | |
383 | \r | |
384 | @param[in] Hid Points to HID String Buffer.\r | |
385 | @param[in] Size HID String size in bytes. Must >= TPM_HID_ACPI_SIZE\r | |
386 | \r | |
387 | @return HID String get status.\r | |
388 | \r | |
389 | **/\r | |
390 | EFI_STATUS\r | |
391 | GetTpm2HID(\r | |
392 | CHAR8 *Hid,\r | |
393 | UINTN Size\r | |
394 | )\r | |
395 | {\r | |
396 | EFI_STATUS Status;\r | |
397 | UINT32 ManufacturerID;\r | |
398 | UINT32 FirmwareVersion1;\r | |
399 | UINT32 FirmwareVersion2;\r | |
400 | BOOLEAN PnpHID;\r | |
401 | \r | |
402 | PnpHID = TRUE;\r | |
403 | \r | |
404 | ZeroMem(Hid, Size);\r | |
405 | \r | |
406 | //\r | |
407 | // Get Manufacturer ID\r | |
408 | //\r | |
409 | Status = Tpm2GetCapabilityManufactureID(&ManufacturerID);\r | |
410 | if (!EFI_ERROR(Status)) {\r | |
411 | DEBUG((DEBUG_INFO, "TPM_PT_MANUFACTURER 0x%08x\n", ManufacturerID));\r | |
412 | //\r | |
413 | // ManufacturerID defined in TCG Vendor ID Registry\r | |
414 | // may tailed with 0x00 or 0x20\r | |
415 | //\r | |
416 | if ((ManufacturerID >> 24) == 0x00 || ((ManufacturerID >> 24) == 0x20)) {\r | |
417 | //\r | |
418 | // HID containing PNP ID "NNN####"\r | |
419 | // NNN is uppercase letter for Vendor ID specified by manufacturer\r | |
420 | //\r | |
421 | CopyMem(Hid, &ManufacturerID, 3);\r | |
422 | } else {\r | |
423 | //\r | |
424 | // HID containing ACP ID "NNNN####"\r | |
425 | // NNNN is uppercase letter for Vendor ID specified by manufacturer\r | |
426 | //\r | |
427 | CopyMem(Hid, &ManufacturerID, 4);\r | |
428 | PnpHID = FALSE;\r | |
429 | }\r | |
430 | } else {\r | |
431 | DEBUG ((DEBUG_ERROR, "Get TPM_PT_MANUFACTURER failed %x!\n", Status));\r | |
432 | ASSERT(FALSE);\r | |
433 | return Status;\r | |
434 | }\r | |
435 | \r | |
436 | Status = Tpm2GetCapabilityFirmwareVersion(&FirmwareVersion1, &FirmwareVersion2);\r | |
437 | if (!EFI_ERROR(Status)) {\r | |
438 | DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_1 0x%x\n", FirmwareVersion1));\r | |
439 | DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_2 0x%x\n", FirmwareVersion2));\r | |
440 | //\r | |
441 | // #### is Firmware Version 1\r | |
442 | //\r | |
443 | if (PnpHID) {\r | |
444 | AsciiSPrint(Hid + 3, TPM_HID_PNP_SIZE - 3, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && 0x0000FFFF));\r | |
445 | } else {\r | |
446 | AsciiSPrint(Hid + 4, TPM_HID_ACPI_SIZE - 4, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && 0x0000FFFF));\r | |
447 | }\r | |
448 | \r | |
449 | } else {\r | |
450 | DEBUG ((DEBUG_ERROR, "Get TPM_PT_FIRMWARE_VERSION_X failed %x!\n", Status));\r | |
451 | ASSERT(FALSE);\r | |
452 | return Status;\r | |
453 | }\r | |
454 | \r | |
455 | return EFI_SUCCESS;\r | |
456 | }\r | |
457 | \r | |
458 | /**\r | |
459 | This function processes the results of changes in configuration\r | |
460 | for TCG2 version information.\r | |
461 | \r | |
462 | @param[in] Action Specifies the type of action taken by the browser.\r | |
463 | ASSERT if the Action is not EFI_BROWSER_ACTION_SUBMITTED.\r | |
464 | @param[in] QuestionId A unique value which is sent to the original\r | |
465 | exporting driver so that it can identify the type\r | |
466 | of data to expect.\r | |
467 | @param[in] Type The type of value for the question.\r | |
468 | @param[in] Value A pointer to the data being sent to the original\r | |
469 | exporting driver.\r | |
470 | \r | |
471 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
472 | \r | |
473 | **/\r | |
474 | EFI_STATUS\r | |
475 | Tcg2VersionInfoCallback (\r | |
476 | IN EFI_BROWSER_ACTION Action,\r | |
477 | IN EFI_QUESTION_ID QuestionId,\r | |
478 | IN UINT8 Type,\r | |
479 | IN EFI_IFR_TYPE_VALUE *Value\r | |
480 | )\r | |
481 | {\r | |
482 | EFI_INPUT_KEY Key;\r | |
483 | UINT64 PcdTcg2PpiVersion;\r | |
484 | UINT8 PcdTpm2AcpiTableRev;\r | |
485 | \r | |
486 | ASSERT (Action == EFI_BROWSER_ACTION_SUBMITTED);\r | |
487 | \r | |
488 | if (QuestionId == KEY_TCG2_PPI_VERSION) {\r | |
489 | //\r | |
490 | // Get the PCD value after EFI_BROWSER_ACTION_SUBMITTED,\r | |
491 | // the SetVariable to TCG2_VERSION_NAME should have been done.\r | |
492 | // If the PCD value is not equal to the value set to variable,\r | |
493 | // the PCD is not DynamicHii type and does not map to the setup option.\r | |
494 | //\r | |
495 | PcdTcg2PpiVersion = 0;\r | |
496 | CopyMem (\r | |
497 | &PcdTcg2PpiVersion,\r | |
498 | PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer),\r | |
499 | AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer))\r | |
500 | );\r | |
501 | if (PcdTcg2PpiVersion != Value->u64) {\r | |
502 | CreatePopUp (\r | |
503 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
504 | &Key,\r | |
505 | L"WARNING: PcdTcgPhysicalPresenceInterfaceVer is not DynamicHii type and does not map to this option!",\r | |
506 | L"The version configuring by this setup option will not work!",\r | |
507 | NULL\r | |
508 | );\r | |
509 | }\r | |
510 | } else if (QuestionId == KEY_TPM2_ACPI_REVISION){\r | |
511 | //\r | |
512 | // Get the PCD value after EFI_BROWSER_ACTION_SUBMITTED,\r | |
513 | // the SetVariable to TCG2_VERSION_NAME should have been done.\r | |
514 | // If the PCD value is not equal to the value set to variable,\r | |
515 | // the PCD is not DynamicHii type and does not map to the setup option.\r | |
516 | //\r | |
517 | PcdTpm2AcpiTableRev = PcdGet8 (PcdTpm2AcpiTableRev);\r | |
518 | \r | |
519 | if (PcdTpm2AcpiTableRev != Value->u8) {\r | |
520 | CreatePopUp (\r | |
521 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
522 | &Key,\r | |
523 | L"WARNING: PcdTpm2AcpiTableRev is not DynamicHii type and does not map to this option!",\r | |
524 | L"The Revision configuring by this setup option will not work!",\r | |
525 | NULL\r | |
526 | );\r | |
527 | }\r | |
528 | }\r | |
529 | \r | |
530 | return EFI_SUCCESS;\r | |
531 | }\r | |
532 | \r | |
533 | /**\r | |
534 | This function processes the results of changes in configuration.\r | |
535 | \r | |
536 | @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r | |
537 | @param[in] Action Specifies the type of action taken by the browser.\r | |
538 | @param[in] QuestionId A unique value which is sent to the original\r | |
539 | exporting driver so that it can identify the type\r | |
540 | of data to expect.\r | |
541 | @param[in] Type The type of value for the question.\r | |
542 | @param[in] Value A pointer to the data being sent to the original\r | |
543 | exporting driver.\r | |
544 | @param[out] ActionRequest On return, points to the action requested by the\r | |
545 | callback function.\r | |
546 | \r | |
547 | @retval EFI_SUCCESS The callback successfully handled the action.\r | |
548 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r | |
549 | variable and its data.\r | |
550 | @retval EFI_DEVICE_ERROR The variable could not be saved.\r | |
551 | @retval EFI_UNSUPPORTED The specified Action is not supported by the\r | |
552 | callback.\r | |
553 | \r | |
554 | **/\r | |
555 | EFI_STATUS\r | |
556 | EFIAPI\r | |
557 | Tcg2Callback (\r | |
558 | IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r | |
559 | IN EFI_BROWSER_ACTION Action,\r | |
560 | IN EFI_QUESTION_ID QuestionId,\r | |
561 | IN UINT8 Type,\r | |
562 | IN EFI_IFR_TYPE_VALUE *Value,\r | |
563 | OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r | |
564 | )\r | |
565 | {\r | |
566 | EFI_STATUS Status;\r | |
567 | EFI_INPUT_KEY Key;\r | |
568 | CHAR8 HidStr[16];\r | |
569 | CHAR16 UnHidStr[16];\r | |
570 | TCG2_CONFIG_PRIVATE_DATA *Private;\r | |
571 | \r | |
572 | if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r | |
573 | return EFI_INVALID_PARAMETER;\r | |
574 | }\r | |
575 | \r | |
576 | Private = TCG2_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r | |
577 | \r | |
578 | if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r | |
579 | //\r | |
580 | // Update TPM2 HID info\r | |
581 | //\r | |
582 | if (QuestionId == KEY_TPM_DEVICE) {\r | |
583 | Status = GetTpm2HID(HidStr, 16);\r | |
584 | \r | |
585 | if (EFI_ERROR(Status)) {\r | |
586 | //\r | |
587 | // Fail to get TPM2 HID\r | |
588 | //\r | |
589 | HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), L"Unknown", NULL);\r | |
590 | } else {\r | |
591 | AsciiStrToUnicodeStrS(HidStr, UnHidStr, 16);\r | |
592 | HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), UnHidStr, NULL);\r | |
593 | }\r | |
594 | }\r | |
595 | return EFI_SUCCESS;\r | |
596 | }\r | |
597 | \r | |
598 | if (Action == EFI_BROWSER_ACTION_CHANGING) {\r | |
599 | if (QuestionId == KEY_TPM_DEVICE_INTERFACE) {\r | |
600 | Status = SetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress), Value->u8);\r | |
601 | if (EFI_ERROR (Status)) {\r | |
602 | CreatePopUp (\r | |
603 | EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r | |
604 | &Key,\r | |
605 | L"Error: Fail to set PTP interface!",\r | |
606 | NULL\r | |
607 | );\r | |
608 | return EFI_DEVICE_ERROR;\r | |
609 | }\r | |
610 | }\r | |
611 | }\r | |
612 | \r | |
613 | if (Action == EFI_BROWSER_ACTION_CHANGED) {\r | |
614 | if (QuestionId == KEY_TPM_DEVICE) {\r | |
615 | return EFI_SUCCESS;\r | |
616 | }\r | |
617 | if (QuestionId == KEY_TPM2_OPERATION) {\r | |
618 | return SaveTcg2PpRequest (Value->u8);\r | |
619 | }\r | |
620 | if (QuestionId == KEY_TPM2_OPERATION_PARAMETER) {\r | |
621 | return SaveTcg2PpRequestParameter (Value->u32);\r | |
622 | }\r | |
623 | if ((QuestionId >= KEY_TPM2_PCR_BANKS_REQUEST_0) && (QuestionId <= KEY_TPM2_PCR_BANKS_REQUEST_4)) {\r | |
624 | return SaveTcg2PCRBanksRequest (QuestionId - KEY_TPM2_PCR_BANKS_REQUEST_0, Value->b);\r | |
625 | }\r | |
626 | }\r | |
627 | \r | |
628 | if (Action == EFI_BROWSER_ACTION_SUBMITTED) {\r | |
629 | if (QuestionId == KEY_TCG2_PPI_VERSION || QuestionId == KEY_TPM2_ACPI_REVISION) {\r | |
630 | return Tcg2VersionInfoCallback (Action, QuestionId, Type, Value);\r | |
631 | }\r | |
632 | }\r | |
633 | \r | |
634 | return EFI_UNSUPPORTED;\r | |
635 | }\r | |
636 | \r | |
637 | /**\r | |
638 | Append Buffer With TpmAlgHash.\r | |
639 | \r | |
640 | @param[in] Buffer Buffer to be appended.\r | |
641 | @param[in] BufferSize Size of buffer.\r | |
642 | @param[in] TpmAlgHash TpmAlgHash.\r | |
643 | \r | |
644 | **/\r | |
645 | VOID\r | |
646 | AppendBufferWithTpmAlgHash (\r | |
647 | IN UINT16 *Buffer,\r | |
648 | IN UINTN BufferSize,\r | |
649 | IN UINT32 TpmAlgHash\r | |
650 | )\r | |
651 | {\r | |
652 | switch (TpmAlgHash) {\r | |
653 | case TPM_ALG_SHA1:\r | |
654 | if (Buffer[0] != 0) {\r | |
655 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
656 | }\r | |
657 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA1");\r | |
658 | break;\r | |
659 | case TPM_ALG_SHA256:\r | |
660 | if (Buffer[0] != 0) {\r | |
661 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
662 | }\r | |
663 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA256");\r | |
664 | break;\r | |
665 | case TPM_ALG_SHA384:\r | |
666 | if (Buffer[0] != 0) {\r | |
667 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
668 | }\r | |
669 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA384");\r | |
670 | break;\r | |
671 | case TPM_ALG_SHA512:\r | |
672 | if (Buffer[0] != 0) {\r | |
673 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
674 | }\r | |
675 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA512");\r | |
676 | break;\r | |
677 | case TPM_ALG_SM3_256:\r | |
678 | if (Buffer[0] != 0) {\r | |
679 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
680 | }\r | |
681 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SM3_256");\r | |
682 | break;\r | |
683 | }\r | |
684 | }\r | |
685 | \r | |
686 | /**\r | |
687 | Fill Buffer With BootHashAlg.\r | |
688 | \r | |
689 | @param[in] Buffer Buffer to be filled.\r | |
690 | @param[in] BufferSize Size of buffer.\r | |
691 | @param[in] BootHashAlg BootHashAlg.\r | |
692 | \r | |
693 | **/\r | |
694 | VOID\r | |
695 | FillBufferWithBootHashAlg (\r | |
696 | IN UINT16 *Buffer,\r | |
697 | IN UINTN BufferSize,\r | |
698 | IN UINT32 BootHashAlg\r | |
699 | )\r | |
700 | {\r | |
701 | Buffer[0] = 0;\r | |
702 | if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA1) != 0) {\r | |
703 | if (Buffer[0] != 0) {\r | |
704 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
705 | }\r | |
706 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA1");\r | |
707 | }\r | |
708 | if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA256) != 0) {\r | |
709 | if (Buffer[0] != 0) {\r | |
710 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
711 | }\r | |
712 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA256");\r | |
713 | }\r | |
714 | if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA384) != 0) {\r | |
715 | if (Buffer[0] != 0) {\r | |
716 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
717 | }\r | |
718 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA384");\r | |
719 | }\r | |
720 | if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA512) != 0) {\r | |
721 | if (Buffer[0] != 0) {\r | |
722 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
723 | }\r | |
724 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SHA512");\r | |
725 | }\r | |
726 | if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SM3_256) != 0) {\r | |
727 | if (Buffer[0] != 0) {\r | |
728 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
729 | }\r | |
730 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"SM3_256");\r | |
731 | }\r | |
732 | }\r | |
733 | \r | |
734 | /**\r | |
735 | Set ConfigInfo according to TpmAlgHash.\r | |
736 | \r | |
737 | @param[in,out] Tcg2ConfigInfo TCG2 config info.\r | |
738 | @param[in] TpmAlgHash TpmAlgHash.\r | |
739 | \r | |
740 | **/\r | |
741 | VOID\r | |
742 | SetConfigInfo (\r | |
743 | IN OUT TCG2_CONFIGURATION_INFO *Tcg2ConfigInfo,\r | |
744 | IN UINT32 TpmAlgHash\r | |
745 | )\r | |
746 | {\r | |
747 | switch (TpmAlgHash) {\r | |
748 | case TPM_ALG_SHA1:\r | |
749 | Tcg2ConfigInfo->Sha1Supported = TRUE;\r | |
750 | break;\r | |
751 | case TPM_ALG_SHA256:\r | |
752 | Tcg2ConfigInfo->Sha256Supported = TRUE;\r | |
753 | break;\r | |
754 | case TPM_ALG_SHA384:\r | |
755 | Tcg2ConfigInfo->Sha384Supported = TRUE;\r | |
756 | break;\r | |
757 | case TPM_ALG_SHA512:\r | |
758 | Tcg2ConfigInfo->Sha512Supported = TRUE;\r | |
759 | break;\r | |
760 | case TPM_ALG_SM3_256:\r | |
761 | Tcg2ConfigInfo->Sm3Supported = TRUE;\r | |
762 | break;\r | |
763 | }\r | |
764 | }\r | |
765 | \r | |
766 | /**\r | |
767 | Fill Buffer With TCG2EventLogFormat.\r | |
768 | \r | |
769 | @param[in] Buffer Buffer to be filled.\r | |
770 | @param[in] BufferSize Size of buffer.\r | |
771 | @param[in] TCG2EventLogFormat TCG2EventLogFormat.\r | |
772 | \r | |
773 | **/\r | |
774 | VOID\r | |
775 | FillBufferWithTCG2EventLogFormat (\r | |
776 | IN UINT16 *Buffer,\r | |
777 | IN UINTN BufferSize,\r | |
778 | IN UINT32 TCG2EventLogFormat\r | |
779 | )\r | |
780 | {\r | |
781 | Buffer[0] = 0;\r | |
782 | if ((TCG2EventLogFormat & EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2) != 0) {\r | |
783 | if (Buffer[0] != 0) {\r | |
784 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
785 | }\r | |
786 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"TCG_1_2");\r | |
787 | }\r | |
788 | if ((TCG2EventLogFormat & EFI_TCG2_EVENT_LOG_FORMAT_TCG_2) != 0) {\r | |
789 | if (Buffer[0] != 0) {\r | |
790 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
791 | }\r | |
792 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"TCG_2");\r | |
793 | }\r | |
794 | if ((TCG2EventLogFormat & (~EFI_TCG2_EVENT_LOG_FORMAT_ALL)) != 0) {\r | |
795 | if (Buffer[0] != 0) {\r | |
796 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L", ");\r | |
797 | }\r | |
798 | StrCatS (Buffer, BufferSize / sizeof (CHAR16), L"UNKNOWN");\r | |
799 | }\r | |
800 | }\r | |
801 | \r | |
802 | /**\r | |
803 | This function publish the TCG2 configuration Form for TPM device.\r | |
804 | \r | |
805 | @param[in, out] PrivateData Points to TCG2 configuration private data.\r | |
806 | \r | |
807 | @retval EFI_SUCCESS HII Form is installed for this network device.\r | |
808 | @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.\r | |
809 | @retval Others Other errors as indicated.\r | |
810 | \r | |
811 | **/\r | |
812 | EFI_STATUS\r | |
813 | InstallTcg2ConfigForm (\r | |
814 | IN OUT TCG2_CONFIG_PRIVATE_DATA *PrivateData\r | |
815 | )\r | |
816 | {\r | |
817 | EFI_STATUS Status;\r | |
818 | EFI_HII_HANDLE HiiHandle;\r | |
819 | EFI_HANDLE DriverHandle;\r | |
820 | EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r | |
821 | UINTN Index;\r | |
822 | TPML_PCR_SELECTION Pcrs;\r | |
823 | CHAR16 TempBuffer[1024];\r | |
824 | TCG2_CONFIGURATION_INFO Tcg2ConfigInfo;\r | |
825 | UINT8 TpmDeviceInterfaceDetected;\r | |
826 | \r | |
827 | DriverHandle = NULL;\r | |
828 | ConfigAccess = &PrivateData->ConfigAccess;\r | |
829 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
830 | &DriverHandle,\r | |
831 | &gEfiDevicePathProtocolGuid,\r | |
832 | &mTcg2HiiVendorDevicePath,\r | |
833 | &gEfiHiiConfigAccessProtocolGuid,\r | |
834 | ConfigAccess,\r | |
835 | NULL\r | |
836 | );\r | |
837 | if (EFI_ERROR (Status)) {\r | |
838 | return Status;\r | |
839 | }\r | |
840 | \r | |
841 | PrivateData->DriverHandle = DriverHandle;\r | |
842 | \r | |
843 | //\r | |
844 | // Publish the HII package list\r | |
845 | //\r | |
846 | HiiHandle = HiiAddPackages (\r | |
847 | &gTcg2ConfigFormSetGuid,\r | |
848 | DriverHandle,\r | |
849 | Tcg2ConfigDxeStrings,\r | |
850 | Tcg2ConfigBin,\r | |
851 | NULL\r | |
852 | );\r | |
853 | if (HiiHandle == NULL) {\r | |
854 | gBS->UninstallMultipleProtocolInterfaces (\r | |
855 | DriverHandle,\r | |
856 | &gEfiDevicePathProtocolGuid,\r | |
857 | &mTcg2HiiVendorDevicePath,\r | |
858 | &gEfiHiiConfigAccessProtocolGuid,\r | |
859 | ConfigAccess,\r | |
860 | NULL\r | |
861 | ); \r | |
862 | \r | |
863 | return EFI_OUT_OF_RESOURCES;\r | |
864 | }\r | |
865 | \r | |
866 | PrivateData->HiiHandle = HiiHandle;\r | |
867 | \r | |
868 | //\r | |
869 | // Update static data\r | |
870 | //\r | |
871 | switch (PrivateData->TpmDeviceDetected) {\r | |
872 | case TPM_DEVICE_NULL:\r | |
873 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"Not Found", NULL);\r | |
874 | break;\r | |
875 | case TPM_DEVICE_1_2:\r | |
876 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"TPM 1.2", NULL);\r | |
877 | break;\r | |
878 | case TPM_DEVICE_2_0_DTPM:\r | |
879 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"TPM 2.0", NULL);\r | |
880 | break;\r | |
881 | default:\r | |
882 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"Unknown", NULL);\r | |
883 | break;\r | |
884 | }\r | |
885 | \r | |
886 | ZeroMem (&Tcg2ConfigInfo, sizeof(Tcg2ConfigInfo));\r | |
887 | Status = Tpm2GetCapabilityPcrs (&Pcrs);\r | |
888 | if (EFI_ERROR (Status)) {\r | |
889 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_ACTIVE_HASH_ALGO_CONTENT), L"[Unknown]", NULL);\r | |
890 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_SUPPORTED_HASH_ALGO_CONTENT), L"[Unknown]", NULL);\r | |
891 | } else {\r | |
892 | TempBuffer[0] = 0;\r | |
893 | for (Index = 0; Index < Pcrs.count; Index++) {\r | |
894 | if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSelections[Index].sizeofSelect)) {\r | |
895 | AppendBufferWithTpmAlgHash (TempBuffer, sizeof(TempBuffer), Pcrs.pcrSelections[Index].hash);\r | |
896 | }\r | |
897 | }\r | |
898 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_ACTIVE_HASH_ALGO_CONTENT), TempBuffer, NULL);\r | |
899 | \r | |
900 | TempBuffer[0] = 0;\r | |
901 | for (Index = 0; Index < Pcrs.count; Index++) {\r | |
902 | AppendBufferWithTpmAlgHash (TempBuffer, sizeof(TempBuffer), Pcrs.pcrSelections[Index].hash);\r | |
903 | SetConfigInfo (&Tcg2ConfigInfo, Pcrs.pcrSelections[Index].hash);\r | |
904 | }\r | |
905 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_SUPPORTED_HASH_ALGO_CONTENT), TempBuffer, NULL);\r | |
906 | }\r | |
907 | \r | |
908 | FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), PcdGet32 (PcdTcg2HashAlgorithmBitmap));\r | |
909 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_BIOS_HASH_ALGO_CONTENT), TempBuffer, NULL);\r | |
910 | \r | |
911 | //\r | |
912 | // Tcg2 Capability\r | |
913 | //\r | |
914 | FillBufferWithTCG2EventLogFormat (TempBuffer, sizeof(TempBuffer), PrivateData->ProtocolCapability.SupportedEventLogs);\r | |
915 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_SUPPORTED_EVENT_LOG_FORMAT_CONTENT), TempBuffer, NULL);\r | |
916 | \r | |
917 | FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), PrivateData->ProtocolCapability.HashAlgorithmBitmap);\r | |
918 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_HASH_ALGO_BITMAP_CONTENT), TempBuffer, NULL);\r | |
919 | \r | |
920 | UnicodeSPrint (TempBuffer, sizeof (TempBuffer), L"%d", PrivateData->ProtocolCapability.NumberOfPCRBanks);\r | |
921 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_NUMBER_OF_PCR_BANKS_CONTENT), TempBuffer, NULL);\r | |
922 | \r | |
923 | FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), PrivateData->ProtocolCapability.ActivePcrBanks);\r | |
924 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_ACTIVE_PCR_BANKS_CONTENT), TempBuffer, NULL);\r | |
925 | \r | |
926 | //\r | |
927 | // Update TPM device interface type\r | |
928 | //\r | |
929 | if (PrivateData->TpmDeviceDetected == TPM_DEVICE_2_0_DTPM) {\r | |
930 | TpmDeviceInterfaceDetected = GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r | |
931 | switch (TpmDeviceInterfaceDetected) {\r | |
932 | case TPM_DEVICE_INTERFACE_TIS:\r | |
933 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT), L"TIS", NULL);\r | |
934 | break;\r | |
935 | case TPM_DEVICE_INTERFACE_PTP_FIFO:\r | |
936 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT), L"PTP FIFO", NULL);\r | |
937 | break;\r | |
938 | case TPM_DEVICE_INTERFACE_PTP_CRB:\r | |
939 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT), L"PTP CRB", NULL);\r | |
940 | break;\r | |
941 | default:\r | |
942 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT), L"Unknown", NULL);\r | |
943 | break;\r | |
944 | }\r | |
945 | \r | |
946 | Tcg2ConfigInfo.TpmDeviceInterfaceAttempt = TpmDeviceInterfaceDetected;\r | |
947 | switch (TpmDeviceInterfaceDetected) {\r | |
948 | case TPM_DEVICE_INTERFACE_TIS:\r | |
949 | Tcg2ConfigInfo.TpmDeviceInterfacePtpFifoSupported = FALSE;\r | |
950 | Tcg2ConfigInfo.TpmDeviceInterfacePtpCrbSupported = FALSE;\r | |
951 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_CAPABILITY_CONTENT), L"TIS", NULL);\r | |
952 | break;\r | |
953 | case TPM_DEVICE_INTERFACE_PTP_FIFO:\r | |
954 | case TPM_DEVICE_INTERFACE_PTP_CRB:\r | |
955 | Tcg2ConfigInfo.TpmDeviceInterfacePtpFifoSupported = IsPtpFifoSupported((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r | |
956 | Tcg2ConfigInfo.TpmDeviceInterfacePtpCrbSupported = IsPtpCrbSupported((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));\r | |
957 | TempBuffer[0] = 0;\r | |
958 | if (Tcg2ConfigInfo.TpmDeviceInterfacePtpFifoSupported) {\r | |
959 | if (TempBuffer[0] != 0) {\r | |
960 | StrCatS (TempBuffer, sizeof(TempBuffer) / sizeof (CHAR16), L", ");\r | |
961 | }\r | |
962 | StrCatS (TempBuffer, sizeof(TempBuffer) / sizeof (CHAR16), L"PTP FIFO");\r | |
963 | }\r | |
964 | if (Tcg2ConfigInfo.TpmDeviceInterfacePtpCrbSupported) {\r | |
965 | if (TempBuffer[0] != 0) {\r | |
966 | StrCatS (TempBuffer, sizeof(TempBuffer) / sizeof (CHAR16), L", ");\r | |
967 | }\r | |
968 | StrCatS (TempBuffer, sizeof(TempBuffer) / sizeof (CHAR16), L"PTP CRB");\r | |
969 | }\r | |
970 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_CAPABILITY_CONTENT), TempBuffer, NULL);\r | |
971 | break;\r | |
972 | default:\r | |
973 | Tcg2ConfigInfo.TpmDeviceInterfacePtpFifoSupported = FALSE;\r | |
974 | Tcg2ConfigInfo.TpmDeviceInterfacePtpCrbSupported = FALSE;\r | |
975 | HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_CAPABILITY_CONTENT), L"Unknown", NULL);\r | |
976 | break;\r | |
977 | }\r | |
978 | }\r | |
979 | \r | |
980 | //\r | |
981 | // Set ConfigInfo, to control the check box.\r | |
982 | //\r | |
983 | Status = gRT->SetVariable (\r | |
984 | TCG2_STORAGE_INFO_NAME,\r | |
985 | &gTcg2ConfigFormSetGuid,\r | |
986 | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
987 | sizeof(Tcg2ConfigInfo),\r | |
988 | &Tcg2ConfigInfo\r | |
989 | );\r | |
990 | if (EFI_ERROR (Status)) {\r | |
991 | DEBUG ((EFI_D_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_STORAGE_INFO_NAME\n"));\r | |
992 | }\r | |
993 | \r | |
994 | return EFI_SUCCESS; \r | |
995 | }\r | |
996 | \r | |
997 | /**\r | |
998 | This function removes TCG2 configuration Form.\r | |
999 | \r | |
1000 | @param[in, out] PrivateData Points to TCG2 configuration private data.\r | |
1001 | \r | |
1002 | **/\r | |
1003 | VOID\r | |
1004 | UninstallTcg2ConfigForm (\r | |
1005 | IN OUT TCG2_CONFIG_PRIVATE_DATA *PrivateData\r | |
1006 | )\r | |
1007 | {\r | |
1008 | //\r | |
1009 | // Uninstall HII package list\r | |
1010 | //\r | |
1011 | if (PrivateData->HiiHandle != NULL) {\r | |
1012 | HiiRemovePackages (PrivateData->HiiHandle);\r | |
1013 | PrivateData->HiiHandle = NULL;\r | |
1014 | }\r | |
1015 | \r | |
1016 | //\r | |
1017 | // Uninstall HII Config Access Protocol\r | |
1018 | //\r | |
1019 | if (PrivateData->DriverHandle != NULL) {\r | |
1020 | gBS->UninstallMultipleProtocolInterfaces (\r | |
1021 | PrivateData->DriverHandle,\r | |
1022 | &gEfiDevicePathProtocolGuid,\r | |
1023 | &mTcg2HiiVendorDevicePath,\r | |
1024 | &gEfiHiiConfigAccessProtocolGuid,\r | |
1025 | &PrivateData->ConfigAccess,\r | |
1026 | NULL\r | |
1027 | );\r | |
1028 | PrivateData->DriverHandle = NULL;\r | |
1029 | }\r | |
1030 | \r | |
1031 | FreePool (PrivateData);\r | |
1032 | }\r |