35 switch (HiiPackageHeader->Type) {
36 case EFI_HII_PACKAGE_FORMS:
38 while ((
UINTN)IfrOpCodeHeader < (
UINTN)HiiPackageHeader + HiiPackageHeader->Length) {
39 switch (IfrOpCodeHeader->OpCode) {
40 case EFI_IFR_CHECKBOX_OP:
42 if ((IfrCheckBox->Question.QuestionId >= KEY_TPM2_PCR_BANKS_REQUEST_0) && (IfrCheckBox->Question.QuestionId <= KEY_TPM2_PCR_BANKS_REQUEST_4)) {
44 ASSERT (IfrDefault->Header.OpCode == EFI_IFR_DEFAULT_OP);
45 ASSERT (IfrDefault->Type == EFI_IFR_TYPE_BOOLEAN);
46 IfrDefault->Value.b = (BOOLEAN)((PCRBanks >> (IfrCheckBox->Question.QuestionId - KEY_TPM2_PCR_BANKS_REQUEST_0)) & 0x1);
78 EFI_STRING ConfigRequestHdr;
82 UINT64 PcdTcg2PpiVersion;
83 UINT8 PcdTpm2AcpiTableRev;
88 PcdTcg2PpiVersion = 0;
91 PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer),
95 PcdTpm2AcpiTableRev =
PcdGet8 (PcdTpm2AcpiTableRev);
100 ZeroMem (&Tcg2Version,
sizeof (Tcg2Version));
102 &gTcg2ConfigFormSetGuid,
104 PrivateData->DriverHandle
106 ASSERT (ConfigRequestHdr !=
NULL);
107 DataSize =
sizeof (Tcg2Version);
108 Status =
gRT->GetVariable (
110 &gTcg2ConfigFormSetGuid,
115 if (!EFI_ERROR (Status)) {
124 ActionFlag =
HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD);
129 DataSize =
sizeof (Tcg2Version);
130 Status =
gRT->GetVariable (
132 &gTcg2ConfigFormSetGuid,
147 Status =
gRT->SetVariable (
149 &gTcg2ConfigFormSetGuid,
151 sizeof (Tcg2Version),
154 if (EFI_ERROR (Status)) {
155 DEBUG ((DEBUG_ERROR,
"Tcg2ConfigDriver: Fail to set TCG2_VERSION_NAME\n"));
161 ActionFlag =
HiiSetToDefaults (ConfigRequestHdr, EFI_HII_DEFAULT_CLASS_STANDARD);
166 DataSize =
sizeof (Tcg2Version);
167 Status =
gRT->GetVariable (
169 &gTcg2ConfigFormSetGuid,
175 if (PcdTcg2PpiVersion != Tcg2Version.PpiVersion) {
176 DEBUG ((DEBUG_WARN,
"WARNING: PcdTcgPhysicalPresenceInterfaceVer default value is not same with the default value in VFR\n"));
177 DEBUG ((DEBUG_WARN,
"WARNING: The default value in VFR has be chosen\n"));
180 if (PcdTpm2AcpiTableRev != Tcg2Version.Tpm2AcpiTableRev) {
181 DEBUG ((DEBUG_WARN,
"WARNING: PcdTpm2AcpiTableRev default value is not same with the default value in VFR\n"));
182 DEBUG ((DEBUG_WARN,
"WARNING: The default value in VFR has be chosen\n"));
194 PcdTcg2PpiVersion = 0;
197 PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer),
200 if (PcdTcg2PpiVersion != Tcg2Version.PpiVersion) {
201 DEBUG ((DEBUG_WARN,
"WARNING: PcdTcgPhysicalPresenceInterfaceVer is not DynamicHii type and does not map to TCG2_VERSION.PpiVersion\n"));
202 DEBUG ((DEBUG_WARN,
"WARNING: The TCG2 PPI version configuring from setup page will not work\n"));
205 switch (PcdTcg2PpiVersion) {
206 case TCG2_PPI_VERSION_1_2:
209 case TCG2_PPI_VERSION_1_3:
222 PcdTpm2AcpiTableRev =
PcdGet8 (PcdTpm2AcpiTableRev);
223 if (PcdTpm2AcpiTableRev != Tcg2Version.Tpm2AcpiTableRev) {
224 DEBUG ((DEBUG_WARN,
"WARNING: PcdTpm2AcpiTableRev is not DynamicHii type and does not map to TCG2_VERSION.Tpm2AcpiTableRev\n"));
225 DEBUG ((DEBUG_WARN,
"WARNING: The Tpm2 ACPI Revision configuring from setup page will not work\n"));
228 switch (PcdTpm2AcpiTableRev) {
229 case EFI_TPM2_ACPI_TABLE_REVISION_3:
232 case EFI_TPM2_ACPI_TABLE_REVISION_4:
267 UINT32 CurrentActivePCRBanks;
269 Status =
gBS->OpenProtocol (
275 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
277 if (!EFI_ERROR (Status)) {
278 return EFI_ALREADY_STARTED;
285 ASSERT (PrivateData !=
NULL);
286 mTcg2ConfigPrivateDate = PrivateData;
290 Status =
gBS->InstallMultipleProtocolInterfaces (
298 Status =
gBS->LocateProtocol (&gEfiTcg2ProtocolGuid,
NULL, (VOID **)&PrivateData->Tcg2Protocol);
301 PrivateData->ProtocolCapability.Size =
sizeof (PrivateData->ProtocolCapability);
302 Status = PrivateData->Tcg2Protocol->GetCapability (
303 PrivateData->Tcg2Protocol,
304 &PrivateData->ProtocolCapability
308 DataSize =
sizeof (Tcg2Configuration);
309 Status =
gRT->GetVariable (
311 &gTcg2ConfigFormSetGuid,
316 if (EFI_ERROR (Status)) {
320 Tcg2Configuration.TpmDevice = TPM_DEVICE_DEFAULT;
326 if ((Tcg2Configuration.TpmDevice > TPM_DEVICE_MAX) || (Tcg2Configuration.TpmDevice < TPM_DEVICE_MIN)) {
327 Tcg2Configuration.TpmDevice = TPM_DEVICE_DEFAULT;
334 Status = PrivateData->Tcg2Protocol->GetActivePcrBanks (PrivateData->Tcg2Protocol, &CurrentActivePCRBanks);
336 PrivateData->PCRBanksDesired = CurrentActivePCRBanks;
342 Tcg2DeviceDetection.TpmDeviceDetected = TPM_DEVICE_NULL;
343 for (Index = 0; Index <
sizeof (mTpmInstanceId)/
sizeof (mTpmInstanceId[0]); Index++) {
345 Tcg2DeviceDetection.TpmDeviceDetected = mTpmInstanceId[Index].TpmDevice;
350 PrivateData->TpmDeviceDetected = Tcg2DeviceDetection.TpmDeviceDetected;
351 Tcg2Configuration.TpmDevice = Tcg2DeviceDetection.TpmDeviceDetected;
356 Status =
gRT->SetVariable (
357 TCG2_DEVICE_DETECTION_NAME,
358 &gTcg2ConfigFormSetGuid,
360 sizeof (Tcg2DeviceDetection),
363 if (EFI_ERROR (Status)) {
364 DEBUG ((DEBUG_ERROR,
"Tcg2ConfigDriver: Fail to set TCG2_DEVICE_DETECTION_NAME\n"));
365 Status =
gRT->SetVariable (
366 TCG2_DEVICE_DETECTION_NAME,
367 &gTcg2ConfigFormSetGuid,
378 Status =
gRT->SetVariable (
380 &gTcg2ConfigFormSetGuid,
382 sizeof (Tcg2Configuration),
385 if (EFI_ERROR (Status)) {
386 DEBUG ((DEBUG_ERROR,
"Tcg2ConfigDriver: Fail to set TCG2_STORAGE_NAME\n"));
392 Status =
gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid,
NULL, (VOID **)&VariableLockProtocol);
393 if (!EFI_ERROR (Status)) {
394 Status = VariableLockProtocol->RequestToLock (
395 VariableLockProtocol,
396 TCG2_DEVICE_DETECTION_NAME,
397 &gTcg2ConfigFormSetGuid
406 if (EFI_ERROR (Status)) {
415 if (PrivateData !=
NULL) {
440 Status =
gBS->HandleProtocol (
443 (VOID **)&PrivateData
445 if (EFI_ERROR (Status)) {
449 ASSERT (PrivateData->Signature == TCG2_CONFIG_PRIVATE_DATA_SIGNATURE);
451 gBS->UninstallMultipleProtocolInterfaces (
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
UINT32 EFIAPI ReadUnaligned32(IN CONST UINT32 *Buffer)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STRING EFIAPI HiiConstructConfigHdr(IN CONST EFI_GUID *Guid OPTIONAL, IN CONST CHAR16 *Name OPTIONAL, IN EFI_HANDLE DriverHandle)
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
BOOLEAN EFIAPI HiiValidateSettings(IN CONST EFI_STRING Request OPTIONAL)
BOOLEAN EFIAPI HiiSetToDefaults(IN CONST EFI_STRING Request OPTIONAL, IN UINT16 DefaultId)
EFI_RUNTIME_SERVICES * gRT
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet8(TokenName)
#define PcdGetPtr(TokenName)
VOID UpdateDefaultPCRBanks(IN VOID *HiiPackage, IN UINTN HiiPackageSize, IN UINT32 PCRBanks)
EFI_STATUS EFIAPI Tcg2ConfigDriverUnload(IN EFI_HANDLE ImageHandle)
VOID InitializeTcg2VersionInfo(IN TCG2_CONFIG_PRIVATE_DATA *PrivateData)
EFI_STATUS EFIAPI Tcg2ConfigDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID UninstallTcg2ConfigForm(IN OUT TCG2_CONFIG_PRIVATE_DATA *PrivateData)
EFI_STATUS InstallTcg2ConfigForm(IN OUT TCG2_CONFIG_PRIVATE_DATA *PrivateData)
#define EFI_VARIABLE_NON_VOLATILE