]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SecurityPkg: Tcg2ConfigDxe: Display TPM2 HID in Tcg2Config
authorZhang, Chao B <chao.b.zhang@intel.com>
Thu, 29 Dec 2016 08:21:02 +0000 (16:21 +0800)
committerZhang, Chao B <chao.b.zhang@intel.com>
Thu, 5 Jan 2017 01:30:15 +0000 (09:30 +0800)
Display TPM2 HID from TPM2 ACPI device object in Tcg2Config UI

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
SecurityPkg/Tcg/Tcg2Config/Tcg2Config.vfr
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.h
SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigStrings.uni
SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c

index 57f37be4f88efc55acb135d3bbcd468c6dac1f26..f56d0f32857d6452203ee59857e4b18e7959140a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   VFR file used by the TCG2 configuration component.\r
 \r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
 which accompanies this distribution.  The full text of the license may be found at \r
@@ -52,6 +52,14 @@ formset
     endoneof;\r
 \r
     suppressif ideqvallist TCG2_CONFIGURATION.TpmDevice == TPM_DEVICE_NULL TPM_DEVICE_1_2;\r
+\r
+    subtitle text = STRING_TOKEN(STR_NULL);\r
+\r
+    text\r
+      help   = STRING_TOKEN(STR_TPM2_ACPI_HID_HELP),\r
+      text   = STRING_TOKEN(STR_TPM2_ACPI_HID_PROMPT),\r
+        text   = STRING_TOKEN(STR_TPM2_ACPI_HID_CONTENT);\r
+\r
     text\r
       help   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_HELP),\r
       text   = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT),\r
index 5f4420ca86296866acb39e6aa3e8e8e88e1a23f0..3e341559b46b0de14feff36078dc0fe1df21be41 100644 (file)
@@ -2,7 +2,7 @@
   HII Config Access protocol implementation of TCG2 configuration module.\r
   NOTE: This module is only for reference only, each platform should have its own setup page.\r
 \r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
 which accompanies this distribution.  The full text of the license may be found at \r
@@ -378,6 +378,83 @@ Tcg2RouteConfig (
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\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
 \r
@@ -411,12 +488,38 @@ Tcg2Callback (
      OUT EFI_BROWSER_ACTION_REQUEST            *ActionRequest\r
   )\r
 {\r
-  EFI_INPUT_KEY               Key;\r
+  EFI_STATUS                 Status;\r
+  EFI_INPUT_KEY              Key;\r
+  CHAR8                      HidStr[16];\r
+  CHAR16                     UnHidStr[16];\r
+  TCG2_CONFIG_PRIVATE_DATA   *Private;\r
 \r
   if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  Private = TCG2_CONFIG_PRIVATE_DATA_FROM_THIS (This);\r
+\r
+  if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {\r
+    //\r
+    // Update TPM2 HID info\r
+    //\r
+    if (QuestionId == KEY_TPM_DEVICE) {\r
+      Status = GetTpm2HID(HidStr, 16);\r
+\r
+      if (EFI_ERROR(Status)) {\r
+        //\r
+        //  Fail to get TPM2 HID\r
+        //\r
+        HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), L"Unknown", NULL);\r
+      } else {\r
+        AsciiStrToUnicodeStrS(HidStr, UnHidStr, 16);\r
+        HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), UnHidStr, NULL);\r
+      }\r
+    }\r
+    return EFI_SUCCESS;\r
+  }\r
+\r
   if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
     if (QuestionId == KEY_TPM_DEVICE_INTERFACE) {\r
       EFI_STATUS  Status;\r
index 1b9a8452e03574c8074a8e0a22f6835c7bf0f620..91d0c275b1c8c6873c8a4b3e9bcb06ad20748278 100644 (file)
@@ -2,7 +2,7 @@
   The header file of HII Config Access protocol implementation of TCG2\r
   configuration module.\r
 \r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
 which accompanies this distribution.  The full text of the license may be found at \r
@@ -73,6 +73,8 @@ extern TCG2_CONFIG_PRIVATE_DATA      *mTcg2ConfigPrivateDate;
 #define TCG2_CONFIG_PRIVATE_DATA_SIGNATURE     SIGNATURE_32 ('T', 'r', 'E', 'D')\r
 #define TCG2_CONFIG_PRIVATE_DATA_FROM_THIS(a)  CR (a, TCG2_CONFIG_PRIVATE_DATA, ConfigAccess, TCG2_CONFIG_PRIVATE_DATA_SIGNATURE)\r
 \r
+#define TPM_HID_PNP_SIZE                                           8\r
+#define TPM_HID_ACPI_SIZE                                          9\r
 \r
 /**\r
   This function publish the TCG2 configuration Form for TPM device.\r
index f55efb471f6446cfe92f78ca73ad2c1df9bee9ad..3a0a14224df06f769cc9f888a6cf1a97faaa542a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   String definitions for TCG2 configuration form.\r
 \r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials \r
 are licensed and made available under the terms and conditions of the BSD License \r
 which accompanies this distribution.  The full text of the license may be found at \r
@@ -25,6 +25,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #string STR_TCG2_DEVICE_HELP                #language en-US "Attempt TPM Device: TPM1.2, or TPM2.0"\r
 #string STR_TCG2_DEVICE_CONTENT             #language en-US ""\r
 \r
+#string STR_TPM2_ACPI_HID_PROMPT                  #language en-US "HID from TPM2 ACPI Table"\r
+#string STR_TPM2_ACPI_HID_HELP                    #language en-US "HID from TPM2 ACPI Table: ManufacturerID + FirmwareVersion_1"\r
+#string STR_TPM2_ACPI_HID_CONTENT                 #language en-US ""\r
+\r
 #string STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT         #language en-US "Current TPM Device Interface"\r
 #string STR_TCG2_DEVICE_INTERFACE_STATE_HELP           #language en-US "Current TPM Device Interface: TIS, PTP FIFO, PTP CRB"\r
 #string STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT        #language en-US ""\r
index e8880585449278b5e775d9ea2c6daca163af841e..968f32710d146b736686b501c4989995bdf4bad5 100644 (file)
@@ -337,7 +337,7 @@ UpdateHID (
   if (!EFI_ERROR(Status)) {\r
     DEBUG((EFI_D_INFO, "TPM_PT_MANUFACTURER 0x%08x\n", ManufacturerID));\r
     //\r
-    // ManfacturerID defined in TCG Vendor ID Registry \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
@@ -396,7 +396,8 @@ UpdateHID (
 \r
         CopyMem(DataPtr, HID, TPM_HID_ACPI_SIZE);\r
       }\r
-      DEBUG((EFI_D_INFO, "TPM2 ACPI _HID updated to %a\n", HID));\r
+      DEBUG((DEBUG_INFO, "TPM2 ACPI _HID is patched to %a\n", DataPtr));\r
+\r
       return Status;\r
     }\r
   }\r