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