+/**\r
+ Get HID string of TPM2 ACPI device object\r
+\r
+ @param[in] Hid Points to HID String Buffer.\r
+ @param[in] Size HID String size in bytes. Must >= TPM_HID_ACPI_SIZE\r
+\r
+ @return HID String get status.\r
+\r
+**/\r
+EFI_STATUS\r
+GetTpm2HID(\r
+ CHAR8 *Hid,\r
+ UINTN Size\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINT32 ManufacturerID;\r
+ UINT32 FirmwareVersion1;\r
+ UINT32 FirmwareVersion2;\r
+ BOOLEAN PnpHID;\r
+\r
+ PnpHID = TRUE;\r
+\r
+ ZeroMem(Hid, Size);\r
+\r
+ //\r
+ // Get Manufacturer ID\r
+ //\r
+ Status = Tpm2GetCapabilityManufactureID(&ManufacturerID);\r
+ if (!EFI_ERROR(Status)) {\r
+ DEBUG((DEBUG_INFO, "TPM_PT_MANUFACTURER 0x%08x\n", ManufacturerID));\r
+ //\r
+ // ManufacturerID defined in TCG Vendor ID Registry\r
+ // may tailed with 0x00 or 0x20\r
+ //\r
+ if ((ManufacturerID >> 24) == 0x00 || ((ManufacturerID >> 24) == 0x20)) {\r
+ //\r
+ // HID containing PNP ID "NNN####"\r
+ // NNN is uppercase letter for Vendor ID specified by manufacturer\r
+ //\r
+ CopyMem(Hid, &ManufacturerID, 3);\r
+ } else {\r
+ //\r
+ // HID containing ACP ID "NNNN####"\r
+ // NNNN is uppercase letter for Vendor ID specified by manufacturer\r
+ //\r
+ CopyMem(Hid, &ManufacturerID, 4);\r
+ PnpHID = FALSE;\r
+ }\r
+ } else {\r
+ DEBUG ((DEBUG_ERROR, "Get TPM_PT_MANUFACTURER failed %x!\n", Status));\r
+ ASSERT(FALSE);\r
+ return Status;\r
+ }\r
+\r
+ Status = Tpm2GetCapabilityFirmwareVersion(&FirmwareVersion1, &FirmwareVersion2);\r
+ if (!EFI_ERROR(Status)) {\r
+ DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_1 0x%x\n", FirmwareVersion1));\r
+ DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_2 0x%x\n", FirmwareVersion2));\r
+ //\r
+ // #### is Firmware Version 1\r
+ //\r
+ if (PnpHID) {\r
+ AsciiSPrint(Hid + 3, TPM_HID_PNP_SIZE - 3, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 & 0x0000FFFF));\r
+ } else {\r
+ AsciiSPrint(Hid + 4, TPM_HID_ACPI_SIZE - 4, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 & 0x0000FFFF));\r
+ }\r
+\r
+ } else {\r
+ DEBUG ((DEBUG_ERROR, "Get TPM_PT_FIRMWARE_VERSION_X failed %x!\n", Status));\r
+ ASSERT(FALSE);\r
+ return Status;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ This function processes the results of changes in configuration\r
+ for TCG2 version information.\r
+\r
+ @param[in] Action Specifies the type of action taken by the browser.\r
+ ASSERT if the Action is not EFI_BROWSER_ACTION_SUBMITTED.\r
+ @param[in] QuestionId A unique value which is sent to the original\r
+ exporting driver so that it can identify the type\r
+ of data to expect.\r
+ @param[in] Type The type of value for the question.\r
+ @param[in] Value A pointer to the data being sent to the original\r
+ exporting driver.\r
+\r
+ @retval EFI_SUCCESS The callback successfully handled the action.\r
+\r
+**/\r
+EFI_STATUS\r
+Tcg2VersionInfoCallback (\r
+ IN EFI_BROWSER_ACTION Action,\r
+ IN EFI_QUESTION_ID QuestionId,\r
+ IN UINT8 Type,\r
+ IN EFI_IFR_TYPE_VALUE *Value\r
+ )\r
+{\r
+ EFI_INPUT_KEY Key;\r
+ UINT64 PcdTcg2PpiVersion;\r
+ UINT8 PcdTpm2AcpiTableRev;\r
+\r
+ ASSERT (Action == EFI_BROWSER_ACTION_SUBMITTED);\r
+\r
+ if (QuestionId == KEY_TCG2_PPI_VERSION) {\r
+ //\r
+ // Get the PCD value after EFI_BROWSER_ACTION_SUBMITTED,\r
+ // the SetVariable to TCG2_VERSION_NAME should have been done.\r
+ // If the PCD value is not equal to the value set to variable,\r
+ // the PCD is not DynamicHii type and does not map to the setup option.\r
+ //\r
+ PcdTcg2PpiVersion = 0;\r
+ CopyMem (\r
+ &PcdTcg2PpiVersion,\r
+ PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer),\r
+ AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer))\r
+ );\r
+ if (PcdTcg2PpiVersion != Value->u64) {\r
+ CreatePopUp (\r
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+ &Key,\r
+ L"WARNING: PcdTcgPhysicalPresenceInterfaceVer is not DynamicHii type and does not map to this option!",\r
+ L"The version configuring by this setup option will not work!",\r
+ NULL\r
+ );\r
+ }\r
+ } else if (QuestionId == KEY_TPM2_ACPI_REVISION){\r
+ //\r
+ // Get the PCD value after EFI_BROWSER_ACTION_SUBMITTED,\r
+ // the SetVariable to TCG2_VERSION_NAME should have been done.\r
+ // If the PCD value is not equal to the value set to variable,\r
+ // the PCD is not DynamicHii type and does not map to the setup option.\r
+ //\r
+ PcdTpm2AcpiTableRev = PcdGet8 (PcdTpm2AcpiTableRev);\r
+\r
+ if (PcdTpm2AcpiTableRev != Value->u8) {\r
+ CreatePopUp (\r
+ EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+ &Key,\r
+ L"WARNING: PcdTpm2AcpiTableRev is not DynamicHii type and does not map to this option!",\r
+ L"The Revision configuring by this setup option will not work!",\r
+ NULL\r
+ );\r
+ }\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r