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