Add TPM2 support defined in trusted computing group.
[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
5Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
6This program and the accompanying materials \r
7are licensed and made available under the terms and conditions of the BSD License \r
8which accompanies this distribution. The full text of the license may be found at \r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12WITHOUT 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 <Guid/TpmInstance.h>\r
20\r
21#define EFI_TCG2_EVENT_LOG_FORMAT_ALL (EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 | EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)\r
22\r
23TPM_INSTANCE_ID mTpmInstanceId[TPM_DEVICE_MAX + 1] = TPM_INSTANCE_ID_LIST;\r
24\r
25TCG2_CONFIG_PRIVATE_DATA *mTcg2ConfigPrivateDate;\r
26TCG2_CONFIG_PRIVATE_DATA mTcg2ConfigPrivateDateTemplate = {\r
27 TCG2_CONFIG_PRIVATE_DATA_SIGNATURE,\r
28 {\r
29 Tcg2ExtractConfig,\r
30 Tcg2RouteConfig,\r
31 Tcg2Callback\r
32 }\r
33};\r
34\r
35HII_VENDOR_DEVICE_PATH mTcg2HiiVendorDevicePath = {\r
36 {\r
37 {\r
38 HARDWARE_DEVICE_PATH,\r
39 HW_VENDOR_DP,\r
40 {\r
41 (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
42 (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
43 }\r
44 },\r
45 TCG2_CONFIG_FORM_SET_GUID\r
46 },\r
47 {\r
48 END_DEVICE_PATH_TYPE,\r
49 END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
50 { \r
51 (UINT8) (END_DEVICE_PATH_LENGTH),\r
52 (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
53 }\r
54 }\r
55};\r
56\r
57UINT8 mCurrentPpRequest;\r
58\r
59/**\r
60 This function allows a caller to extract the current configuration for one\r
61 or more named elements from the target driver.\r
62\r
63 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
64 @param[in] Request A null-terminated Unicode string in\r
65 <ConfigRequest> format.\r
66 @param[out] Progress On return, points to a character in the Request\r
67 string. Points to the string's null terminator if\r
68 request was successful. Points to the most recent\r
69 '&' before the first failing name/value pair (or\r
70 the beginning of the string if the failure is in\r
71 the first name/value pair) if the request was not\r
72 successful.\r
73 @param[out] Results A null-terminated Unicode string in\r
74 <ConfigAltResp> format which has all values filled\r
75 in for the names in the Request string. String to\r
76 be allocated by the called function.\r
77\r
78 @retval EFI_SUCCESS The Results is filled with the requested values.\r
79 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
80 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
81 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r
82 driver.\r
83\r
84**/\r
85EFI_STATUS\r
86EFIAPI\r
87Tcg2ExtractConfig (\r
88 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
89 IN CONST EFI_STRING Request,\r
90 OUT EFI_STRING *Progress,\r
91 OUT EFI_STRING *Results\r
92 )\r
93{\r
94 if (Progress == NULL || Results == NULL) {\r
95 return EFI_INVALID_PARAMETER;\r
96 }\r
97\r
98 *Progress = Request;\r
99 return EFI_NOT_FOUND;\r
100}\r
101\r
102/**\r
103 Save TPM request to variable space.\r
104\r
105 @param[in] PpRequest Physical Presence request command.\r
106\r
107 @retval EFI_SUCCESS The operation is finished successfully.\r
108 @retval Others Other errors as indicated.\r
109\r
110**/\r
111EFI_STATUS\r
112SaveTcg2PpRequest (\r
113 IN UINT8 PpRequest\r
114 )\r
115{\r
116 UINT32 ReturnCode;\r
117 EFI_STATUS Status;\r
118\r
119 ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (PpRequest, 0);\r
120 if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {\r
121 mCurrentPpRequest = PpRequest;\r
122 Status = EFI_SUCCESS;\r
123 } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) {\r
124 Status = EFI_OUT_OF_RESOURCES;\r
125 } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) {\r
126 Status = EFI_UNSUPPORTED;\r
127 } else {\r
128 Status = EFI_DEVICE_ERROR;\r
129 }\r
130\r
131 return Status;\r
132}\r
133\r
134/**\r
135 Save TPM request to variable space.\r
136\r
137 @param[in] PpRequestParameter Physical Presence request parameter.\r
138\r
139 @retval EFI_SUCCESS The operation is finished successfully.\r
140 @retval Others Other errors as indicated.\r
141\r
142**/\r
143EFI_STATUS\r
144SaveTcg2PpRequestParameter (\r
145 IN UINT32 PpRequestParameter\r
146 )\r
147{\r
148 UINT32 ReturnCode;\r
149 EFI_STATUS Status;\r
150\r
151 ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (mCurrentPpRequest, PpRequestParameter);\r
152 if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {\r
153 Status = EFI_SUCCESS;\r
154 } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) {\r
155 Status = EFI_OUT_OF_RESOURCES;\r
156 } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) {\r
157 Status = EFI_UNSUPPORTED;\r
158 } else {\r
159 Status = EFI_DEVICE_ERROR;\r
160 }\r
161\r
162 return Status;\r
163}\r
164\r
165/**\r
166 Save Tcg2 PCR Banks request request to variable space.\r
167\r
168 @param[in] PCRBankIndex PCR Bank Index.\r
169 @param[in] Enable Enable or disable this PCR Bank.\r
170\r
171 @retval EFI_SUCCESS The operation is finished successfully.\r
172 @retval Others Other errors as indicated.\r
173\r
174**/\r
175EFI_STATUS\r
176SaveTcg2PCRBanksRequest (\r
177 IN UINTN PCRBankIndex,\r
178 IN BOOLEAN Enable\r
179 )\r
180{\r
181 UINT32 ReturnCode;\r
182 EFI_STATUS Status;\r
183\r
184 if (Enable) {\r
185 mTcg2ConfigPrivateDate->PCRBanksDesired |= (0x1 << PCRBankIndex);\r
186 } else {\r
187 mTcg2ConfigPrivateDate->PCRBanksDesired &= ~(0x1 << PCRBankIndex);\r
188 }\r
189 \r
190 ReturnCode = Tcg2PhysicalPresenceLibSubmitRequestToPreOSFunction (TCG2_PHYSICAL_PRESENCE_SET_PCR_BANKS, mTcg2ConfigPrivateDate->PCRBanksDesired);\r
191 if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {\r
192 Status = EFI_SUCCESS;\r
193 } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) {\r
194 Status = EFI_OUT_OF_RESOURCES;\r
195 } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) {\r
196 Status = EFI_UNSUPPORTED;\r
197 } else {\r
198 Status = EFI_DEVICE_ERROR;\r
199 }\r
200\r
201 return Status;\r
202}\r
203\r
204/**\r
205 This function processes the results of changes in configuration.\r
206\r
207 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
208 @param[in] Configuration A null-terminated Unicode string in <ConfigResp>\r
209 format.\r
210 @param[out] Progress A pointer to a string filled in with the offset of\r
211 the most recent '&' before the first failing\r
212 name/value pair (or the beginning of the string if\r
213 the failure is in the first name/value pair) or\r
214 the terminating NULL if all was successful.\r
215\r
216 @retval EFI_SUCCESS The Results is processed successfully.\r
217 @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
218 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this\r
219 driver.\r
220\r
221**/\r
222EFI_STATUS\r
223EFIAPI\r
224Tcg2RouteConfig (\r
225 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
226 IN CONST EFI_STRING Configuration,\r
227 OUT EFI_STRING *Progress\r
228 )\r
229{\r
230 if (Configuration == NULL || Progress == NULL) {\r
231 return EFI_INVALID_PARAMETER;\r
232 }\r
233\r
234 return EFI_NOT_FOUND;\r
235}\r
236\r
237/**\r
238 This function processes the results of changes in configuration.\r
239\r
240 @param[in] This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
241 @param[in] Action Specifies the type of action taken by the browser.\r
242 @param[in] QuestionId A unique value which is sent to the original\r
243 exporting driver so that it can identify the type\r
244 of data to expect.\r
245 @param[in] Type The type of value for the question.\r
246 @param[in] Value A pointer to the data being sent to the original\r
247 exporting driver.\r
248 @param[out] ActionRequest On return, points to the action requested by the\r
249 callback function.\r
250\r
251 @retval EFI_SUCCESS The callback successfully handled the action.\r
252 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r
253 variable and its data.\r
254 @retval EFI_DEVICE_ERROR The variable could not be saved.\r
255 @retval EFI_UNSUPPORTED The specified Action is not supported by the\r
256 callback.\r
257\r
258**/\r
259EFI_STATUS\r
260EFIAPI\r
261Tcg2Callback (\r
262 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
263 IN EFI_BROWSER_ACTION Action,\r
264 IN EFI_QUESTION_ID QuestionId,\r
265 IN UINT8 Type,\r
266 IN EFI_IFR_TYPE_VALUE *Value,\r
267 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
268 )\r
269{\r
270 if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
271 return EFI_INVALID_PARAMETER;\r
272 }\r
273 \r
274 if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
275 if (QuestionId == KEY_TPM_DEVICE) {\r
276 return EFI_SUCCESS;\r
277 }\r
278 if (QuestionId == KEY_TPM2_OPERATION) {\r
279 return SaveTcg2PpRequest (Value->u8);\r
280 }\r
281 if (QuestionId == KEY_TPM2_OPERATION_PARAMETER) {\r
282 return SaveTcg2PpRequestParameter (Value->u32);\r
283 }\r
284 if ((QuestionId >= KEY_TPM2_PCR_BANKS_REQUEST_0) && (QuestionId <= KEY_TPM2_PCR_BANKS_REQUEST_4)) {\r
285 SaveTcg2PCRBanksRequest (QuestionId - KEY_TPM2_PCR_BANKS_REQUEST_0, Value->b);\r
286 }\r
287 }\r
288\r
289 return EFI_UNSUPPORTED;\r
290}\r
291\r
292/**\r
293 Append Buffer With TpmAlgHash.\r
294\r
295 @param[in] Buffer Buffer to be appended.\r
296 @param[in] BufferSize Size of buffer.\r
297 @param[in] TpmAlgHash TpmAlgHash.\r
298\r
299**/\r
300VOID\r
301AppendBufferWithTpmAlgHash (\r
302 IN UINT16 *Buffer,\r
303 IN UINTN BufferSize,\r
304 IN UINT32 TpmAlgHash\r
305 )\r
306{\r
307 switch (TpmAlgHash) {\r
308 case TPM_ALG_SHA1:\r
309 if (Buffer[0] != 0) {\r
310 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
311 }\r
312 StrnCat (Buffer, L"SHA1", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
313 break;\r
314 case TPM_ALG_SHA256:\r
315 if (Buffer[0] != 0) {\r
316 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
317 }\r
318 StrnCat (Buffer, L"SHA256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
319 break;\r
320 case TPM_ALG_SHA384:\r
321 if (Buffer[0] != 0) {\r
322 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
323 }\r
324 StrnCat (Buffer, L"SHA384", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
325 break;\r
326 case TPM_ALG_SHA512:\r
327 if (Buffer[0] != 0) {\r
328 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
329 }\r
330 StrnCat (Buffer, L"SHA512", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
331 break;\r
332 case TPM_ALG_SM3_256:\r
333 if (Buffer[0] != 0) {\r
334 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
335 }\r
336 StrnCat (Buffer, L"SM3_256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
337 break;\r
338 }\r
339}\r
340\r
341/**\r
342 Fill Buffer With BootHashAlg.\r
343\r
344 @param[in] Buffer Buffer to be filled.\r
345 @param[in] BufferSize Size of buffer.\r
346 @param[in] BootHashAlg BootHashAlg.\r
347\r
348**/\r
349VOID\r
350FillBufferWithBootHashAlg (\r
351 IN UINT16 *Buffer,\r
352 IN UINTN BufferSize,\r
353 IN UINT32 BootHashAlg\r
354 )\r
355{\r
356 Buffer[0] = 0;\r
357 if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA1) != 0) {\r
358 if (Buffer[0] != 0) {\r
359 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
360 }\r
361 StrnCat (Buffer, L"SHA1", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
362 }\r
363 if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA256) != 0) {\r
364 if (Buffer[0] != 0) {\r
365 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
366 }\r
367 StrnCat (Buffer, L"SHA256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
368 }\r
369 if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA384) != 0) {\r
370 if (Buffer[0] != 0) {\r
371 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
372 }\r
373 StrnCat (Buffer, L"SHA384", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
374 }\r
375 if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SHA512) != 0) {\r
376 if (Buffer[0] != 0) {\r
377 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
378 }\r
379 StrnCat (Buffer, L"SHA512", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
380 }\r
381 if ((BootHashAlg & EFI_TCG2_BOOT_HASH_ALG_SM3_256) != 0) {\r
382 if (Buffer[0] != 0) {\r
383 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
384 }\r
385 StrnCat (Buffer, L"SM3_256", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
386 }\r
387}\r
388\r
389/**\r
390 Fill Buffer With TCG2EventLogFormat.\r
391\r
392 @param[in] Buffer Buffer to be filled.\r
393 @param[in] BufferSize Size of buffer.\r
394 @param[in] TCG2EventLogFormat TCG2EventLogFormat.\r
395\r
396**/\r
397VOID\r
398FillBufferWithTCG2EventLogFormat (\r
399 IN UINT16 *Buffer,\r
400 IN UINTN BufferSize,\r
401 IN UINT32 TCG2EventLogFormat\r
402 )\r
403{\r
404 Buffer[0] = 0;\r
405 if ((TCG2EventLogFormat & EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2) != 0) {\r
406 if (Buffer[0] != 0) {\r
407 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
408 }\r
409 StrnCat (Buffer, L"TCG_1_2", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
410 }\r
411 if ((TCG2EventLogFormat & EFI_TCG2_EVENT_LOG_FORMAT_TCG_2) != 0) {\r
412 if (Buffer[0] != 0) {\r
413 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
414 }\r
415 StrnCat (Buffer, L"TCG_2", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
416 }\r
417 if ((TCG2EventLogFormat & (~EFI_TCG2_EVENT_LOG_FORMAT_ALL)) != 0) {\r
418 if (Buffer[0] != 0) {\r
419 StrnCat (Buffer, L", ", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
420 }\r
421 StrnCat (Buffer, L"UNKNOWN", (BufferSize / sizeof (CHAR16)) - StrLen (Buffer) - 1);\r
422 }\r
423}\r
424\r
425/**\r
426 Check if buffer is all zero.\r
427\r
428 @param[in] Buffer Buffer to be checked.\r
429 @param[in] BufferSize Size of buffer to be checked.\r
430\r
431 @retval TRUE Buffer is all zero.\r
432 @retval FALSE Buffer is not all zero.\r
433**/\r
434BOOLEAN\r
435IsZeroBuffer (\r
436 IN VOID *Buffer,\r
437 IN UINTN BufferSize\r
438 )\r
439{\r
440 UINT8 *BufferData;\r
441 UINTN Index;\r
442\r
443 BufferData = Buffer;\r
444 for (Index = 0; Index < BufferSize; Index++) {\r
445 if (BufferData[Index] != 0) {\r
446 return FALSE;\r
447 }\r
448 }\r
449 return TRUE;\r
450}\r
451\r
452/**\r
453 This function publish the TCG2 configuration Form for TPM device.\r
454\r
455 @param[in, out] PrivateData Points to TCG2 configuration private data.\r
456\r
457 @retval EFI_SUCCESS HII Form is installed for this network device.\r
458 @retval EFI_OUT_OF_RESOURCES Not enough resource for HII Form installation.\r
459 @retval Others Other errors as indicated.\r
460\r
461**/\r
462EFI_STATUS\r
463InstallTcg2ConfigForm (\r
464 IN OUT TCG2_CONFIG_PRIVATE_DATA *PrivateData\r
465 )\r
466{\r
467 EFI_STATUS Status;\r
468 EFI_HII_HANDLE HiiHandle;\r
469 EFI_HANDLE DriverHandle;\r
470 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
471 UINTN Index;\r
472 TPML_PCR_SELECTION Pcrs;\r
473 CHAR16 TempBuffer[1024];\r
474\r
475 DriverHandle = NULL;\r
476 ConfigAccess = &PrivateData->ConfigAccess;\r
477 Status = gBS->InstallMultipleProtocolInterfaces (\r
478 &DriverHandle,\r
479 &gEfiDevicePathProtocolGuid,\r
480 &mTcg2HiiVendorDevicePath,\r
481 &gEfiHiiConfigAccessProtocolGuid,\r
482 ConfigAccess,\r
483 NULL\r
484 );\r
485 if (EFI_ERROR (Status)) {\r
486 return Status;\r
487 }\r
488\r
489 PrivateData->DriverHandle = DriverHandle;\r
490\r
491 //\r
492 // Publish the HII package list\r
493 //\r
494 HiiHandle = HiiAddPackages (\r
495 &gTcg2ConfigFormSetGuid,\r
496 DriverHandle,\r
497 Tcg2ConfigDxeStrings,\r
498 Tcg2ConfigBin,\r
499 NULL\r
500 );\r
501 if (HiiHandle == NULL) {\r
502 gBS->UninstallMultipleProtocolInterfaces (\r
503 DriverHandle,\r
504 &gEfiDevicePathProtocolGuid,\r
505 &mTcg2HiiVendorDevicePath,\r
506 &gEfiHiiConfigAccessProtocolGuid,\r
507 ConfigAccess,\r
508 NULL\r
509 ); \r
510\r
511 return EFI_OUT_OF_RESOURCES;\r
512 }\r
513 \r
514 PrivateData->HiiHandle = HiiHandle;\r
515\r
516 //\r
517 // Update static data\r
518 //\r
519 switch (PrivateData->TpmDeviceDetected) {\r
520 case TPM_DEVICE_NULL:\r
521 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"Not Found", NULL);\r
522 break;\r
523 case TPM_DEVICE_1_2:\r
524 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"TPM 1.2", NULL);\r
525 break;\r
526 case TPM_DEVICE_2_0_DTPM:\r
527 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"TPM 2.0 (DTPM)", NULL);\r
528 break;\r
529 default:\r
530 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_STATE_CONTENT), L"Unknown", NULL);\r
531 break;\r
532 }\r
533\r
534 Status = Tpm2GetCapabilityPcrs (&Pcrs);\r
535 if (EFI_ERROR (Status)) {\r
536 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_ACTIVE_HASH_ALGO_CONTENT), L"[Unknown]", NULL);\r
537 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_SUPPORTED_HASH_ALGO_CONTENT), L"[Unknown]", NULL);\r
538 } else {\r
539 TempBuffer[0] = 0;\r
540 for (Index = 0; Index < Pcrs.count; Index++) {\r
541 if (!IsZeroBuffer (Pcrs.pcrSelections[Index].pcrSelect, Pcrs.pcrSelections[Index].sizeofSelect)) {\r
542 AppendBufferWithTpmAlgHash (TempBuffer, sizeof(TempBuffer), Pcrs.pcrSelections[Index].hash);\r
543 }\r
544 }\r
545 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_ACTIVE_HASH_ALGO_CONTENT), TempBuffer, NULL);\r
546\r
547 TempBuffer[0] = 0;\r
548 for (Index = 0; Index < Pcrs.count; Index++) {\r
549 AppendBufferWithTpmAlgHash (TempBuffer, sizeof(TempBuffer), Pcrs.pcrSelections[Index].hash);\r
550 }\r
551 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TPM2_SUPPORTED_HASH_ALGO_CONTENT), TempBuffer, NULL);\r
552 }\r
553\r
554 FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), PcdGet32 (PcdTcg2HashAlgorithmBitmap));\r
555 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_BIOS_HASH_ALGO_CONTENT), TempBuffer, NULL);\r
556\r
557 //\r
558 // Tcg2 Capability\r
559 //\r
560 FillBufferWithTCG2EventLogFormat (TempBuffer, sizeof(TempBuffer), PrivateData->ProtocolCapability.SupportedEventLogs);\r
561 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_SUPPORTED_EVENT_LOG_FORMAT_CONTENT), TempBuffer, NULL);\r
562\r
563 FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), PrivateData->ProtocolCapability.HashAlgorithmBitmap);\r
564 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_HASH_ALGO_BITMAP_CONTENT), TempBuffer, NULL);\r
565\r
566 UnicodeSPrint (TempBuffer, sizeof (TempBuffer), L"%d", PrivateData->ProtocolCapability.NumberOfPCRBanks);\r
567 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_NUMBER_OF_PCR_BANKS_CONTENT), TempBuffer, NULL);\r
568\r
569 FillBufferWithBootHashAlg (TempBuffer, sizeof(TempBuffer), PrivateData->ProtocolCapability.ActivePcrBanks);\r
570 HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_ACTIVE_PCR_BANKS_CONTENT), TempBuffer, NULL);\r
571\r
572 return EFI_SUCCESS; \r
573}\r
574\r
575/**\r
576 This function removes TCG2 configuration Form.\r
577\r
578 @param[in, out] PrivateData Points to TCG2 configuration private data.\r
579\r
580**/\r
581VOID\r
582UninstallTcg2ConfigForm (\r
583 IN OUT TCG2_CONFIG_PRIVATE_DATA *PrivateData\r
584 )\r
585{\r
586 //\r
587 // Uninstall HII package list\r
588 //\r
589 if (PrivateData->HiiHandle != NULL) {\r
590 HiiRemovePackages (PrivateData->HiiHandle);\r
591 PrivateData->HiiHandle = NULL;\r
592 }\r
593\r
594 //\r
595 // Uninstall HII Config Access Protocol\r
596 //\r
597 if (PrivateData->DriverHandle != NULL) {\r
598 gBS->UninstallMultipleProtocolInterfaces (\r
599 PrivateData->DriverHandle,\r
600 &gEfiDevicePathProtocolGuid,\r
601 &mTcg2HiiVendorDevicePath,\r
602 &gEfiHiiConfigAccessProtocolGuid,\r
603 &PrivateData->ConfigAccess,\r
604 NULL\r
605 );\r
606 PrivateData->DriverHandle = NULL;\r
607 }\r
608 \r
609 FreePool (PrivateData);\r
610}\r