SecurityPkg: Tcg2ConfigDxe: Display TPM2 HID in Tcg2Config

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>
This commit is contained in:
Zhang, Chao B 2016-12-29 16:21:02 +08:00
parent 7cb63c870b
commit a6e0e994d0
5 changed files with 125 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
VFR file used by the TCG2 configuration component. VFR file used by the TCG2 configuration component.
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -52,6 +52,14 @@ formset
endoneof; endoneof;
suppressif ideqvallist TCG2_CONFIGURATION.TpmDevice == TPM_DEVICE_NULL TPM_DEVICE_1_2; suppressif ideqvallist TCG2_CONFIGURATION.TpmDevice == TPM_DEVICE_NULL TPM_DEVICE_1_2;
subtitle text = STRING_TOKEN(STR_NULL);
text
help = STRING_TOKEN(STR_TPM2_ACPI_HID_HELP),
text = STRING_TOKEN(STR_TPM2_ACPI_HID_PROMPT),
text = STRING_TOKEN(STR_TPM2_ACPI_HID_CONTENT);
text text
help = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_HELP), help = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_HELP),
text = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT), text = STRING_TOKEN(STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT),

View File

@ -2,7 +2,7 @@
HII Config Access protocol implementation of TCG2 configuration module. HII Config Access protocol implementation of TCG2 configuration module.
NOTE: This module is only for reference only, each platform should have its own setup page. NOTE: This module is only for reference only, each platform should have its own setup page.
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -378,6 +378,83 @@ Tcg2RouteConfig (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/**
Get HID string of TPM2 ACPI device object
@param[in] HID Points to HID String Buffer.
@param[in] Size HID String size in bytes. Must >= TPM_HID_ACPI_SIZE
@return HID String get status.
**/
EFI_STATUS
GetTpm2HID(
CHAR8 *HID,
UINTN Size
)
{
EFI_STATUS Status;
UINT32 ManufacturerID;
UINT32 FirmwareVersion1;
UINT32 FirmwareVersion2;
BOOLEAN PnpHID;
PnpHID = TRUE;
ZeroMem(HID, Size);
//
// Get Manufacturer ID
//
Status = Tpm2GetCapabilityManufactureID(&ManufacturerID);
if (!EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "TPM_PT_MANUFACTURER 0x%08x\n", ManufacturerID));
//
// ManufacturerID defined in TCG Vendor ID Registry
// may tailed with 0x00 or 0x20
//
if ((ManufacturerID >> 24) == 0x00 || ((ManufacturerID >> 24) == 0x20)) {
//
// HID containing PNP ID "NNN####"
// NNN is uppercase letter for Vendor ID specified by manufacturer
//
CopyMem(HID, &ManufacturerID, 3);
} else {
//
// HID containing ACP ID "NNNN####"
// NNNN is uppercase letter for Vendor ID specified by manufacturer
//
CopyMem(HID, &ManufacturerID, 4);
PnpHID = FALSE;
}
} else {
DEBUG ((DEBUG_ERROR, "Get TPM_PT_MANUFACTURER failed %x!\n", Status));
ASSERT(FALSE);
return Status;
}
Status = Tpm2GetCapabilityFirmwareVersion(&FirmwareVersion1, &FirmwareVersion2);
if (!EFI_ERROR(Status)) {
DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_1 0x%x\n", FirmwareVersion1));
DEBUG((DEBUG_INFO, "TPM_PT_FIRMWARE_VERSION_2 0x%x\n", FirmwareVersion2));
//
// #### is Firmware Version 1
//
if (PnpHID) {
AsciiSPrint(HID + 3, TPM_HID_PNP_SIZE - 3, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && 0x0000FFFF));
} else {
AsciiSPrint(HID + 4, TPM_HID_ACPI_SIZE - 4, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && 0x0000FFFF));
}
} else {
DEBUG ((DEBUG_ERROR, "Get TPM_PT_FIRMWARE_VERSION_X failed %x!\n", Status));
ASSERT(FALSE);
return Status;
}
return EFI_SUCCESS;
}
/** /**
This function processes the results of changes in configuration. This function processes the results of changes in configuration.
@ -411,12 +488,38 @@ Tcg2Callback (
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
) )
{ {
EFI_STATUS Status;
EFI_INPUT_KEY Key; EFI_INPUT_KEY Key;
CHAR8 HidStr[16];
CHAR16 UnHidStr[16];
TCG2_CONFIG_PRIVATE_DATA *Private;
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) { if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
Private = TCG2_CONFIG_PRIVATE_DATA_FROM_THIS (This);
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
//
// Update TPM2 HID info
//
if (QuestionId == KEY_TPM_DEVICE) {
Status = GetTpm2HID(HidStr, 16);
if (EFI_ERROR(Status)) {
//
// Fail to get TPM2 HID
//
HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), L"Unknown", NULL);
} else {
AsciiStrToUnicodeStrS(HidStr, UnHidStr, 16);
HiiSetString (Private->HiiHandle, STRING_TOKEN (STR_TPM2_ACPI_HID_CONTENT), UnHidStr, NULL);
}
}
return EFI_SUCCESS;
}
if (Action == EFI_BROWSER_ACTION_CHANGING) { if (Action == EFI_BROWSER_ACTION_CHANGING) {
if (QuestionId == KEY_TPM_DEVICE_INTERFACE) { if (QuestionId == KEY_TPM_DEVICE_INTERFACE) {
EFI_STATUS Status; EFI_STATUS Status;

View File

@ -2,7 +2,7 @@
The header file of HII Config Access protocol implementation of TCG2 The header file of HII Config Access protocol implementation of TCG2
configuration module. configuration module.
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -73,6 +73,8 @@ extern TCG2_CONFIG_PRIVATE_DATA *mTcg2ConfigPrivateDate;
#define TCG2_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', 'r', 'E', 'D') #define TCG2_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', 'r', 'E', 'D')
#define TCG2_CONFIG_PRIVATE_DATA_FROM_THIS(a) CR (a, TCG2_CONFIG_PRIVATE_DATA, ConfigAccess, TCG2_CONFIG_PRIVATE_DATA_SIGNATURE) #define TCG2_CONFIG_PRIVATE_DATA_FROM_THIS(a) CR (a, TCG2_CONFIG_PRIVATE_DATA, ConfigAccess, TCG2_CONFIG_PRIVATE_DATA_SIGNATURE)
#define TPM_HID_PNP_SIZE 8
#define TPM_HID_ACPI_SIZE 9
/** /**
This function publish the TCG2 configuration Form for TPM device. This function publish the TCG2 configuration Form for TPM device.

View File

@ -1,7 +1,7 @@
/** @file /** @file
String definitions for TCG2 configuration form. String definitions for TCG2 configuration form.
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at which accompanies this distribution. The full text of the license may be found at
@ -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" #string STR_TCG2_DEVICE_HELP #language en-US "Attempt TPM Device: TPM1.2, or TPM2.0"
#string STR_TCG2_DEVICE_CONTENT #language en-US "" #string STR_TCG2_DEVICE_CONTENT #language en-US ""
#string STR_TPM2_ACPI_HID_PROMPT #language en-US "HID from TPM2 ACPI Table"
#string STR_TPM2_ACPI_HID_HELP #language en-US "HID from TPM2 ACPI Table: ManufacturerID + FirmwareVersion_1"
#string STR_TPM2_ACPI_HID_CONTENT #language en-US ""
#string STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT #language en-US "Current TPM Device Interface" #string STR_TCG2_DEVICE_INTERFACE_STATE_PROMPT #language en-US "Current TPM Device Interface"
#string STR_TCG2_DEVICE_INTERFACE_STATE_HELP #language en-US "Current TPM Device Interface: TIS, PTP FIFO, PTP CRB" #string STR_TCG2_DEVICE_INTERFACE_STATE_HELP #language en-US "Current TPM Device Interface: TIS, PTP FIFO, PTP CRB"
#string STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT #language en-US "" #string STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT #language en-US ""

View File

@ -337,7 +337,7 @@ UpdateHID (
if (!EFI_ERROR(Status)) { if (!EFI_ERROR(Status)) {
DEBUG((EFI_D_INFO, "TPM_PT_MANUFACTURER 0x%08x\n", ManufacturerID)); DEBUG((EFI_D_INFO, "TPM_PT_MANUFACTURER 0x%08x\n", ManufacturerID));
// //
// ManfacturerID defined in TCG Vendor ID Registry // ManufacturerID defined in TCG Vendor ID Registry
// may tailed with 0x00 or 0x20 // may tailed with 0x00 or 0x20
// //
if ((ManufacturerID >> 24) == 0x00 || ((ManufacturerID >> 24) == 0x20)) { if ((ManufacturerID >> 24) == 0x00 || ((ManufacturerID >> 24) == 0x20)) {
@ -396,7 +396,8 @@ UpdateHID (
CopyMem(DataPtr, HID, TPM_HID_ACPI_SIZE); CopyMem(DataPtr, HID, TPM_HID_ACPI_SIZE);
} }
DEBUG((EFI_D_INFO, "TPM2 ACPI _HID updated to %a\n", HID)); DEBUG((DEBUG_INFO, "TPM2 ACPI _HID is patched to %a\n", DataPtr));
return Status; return Status;
} }
} }