summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
diff options
context:
space:
mode:
authorZhang, Chao B <chao.b.zhang@intel.com>2018-05-08 14:51:57 +0800
committerZhang, Chao B <chao.b.zhang@intel.com>2018-06-25 10:55:08 +0800
commitf15cb995bb3880b77e15afe6facd3da05e599a17 (patch)
tree8a160b4c8324921198c45c6adac6e1f43933de61 /SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
parent796ef9da06bf1ab81b0b55f091630aa50cf9dfe0 (diff)
downloadedk2-f15cb995bb3880b77e15afe6facd3da05e599a17.tar.gz
edk2-f15cb995bb3880b77e15afe6facd3da05e599a17.tar.bz2
edk2-f15cb995bb3880b77e15afe6facd3da05e599a17.zip
SecurityPkg: Cache TPM interface type info
Cache TPM interface type info to avoid excessive interface ID register read Cc: Long Qin <qin.long@intel.com> Cc: Yao Jiewen <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chao Zhang <chao.b.zhang@intel.com> Reviewed-by: Long Qin <qin.long@intel.com>
Diffstat (limited to 'SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c')
-rw-r--r--SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c68
1 files changed, 18 insertions, 50 deletions
diff --git a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
index 4195b6c68f..af97628e2c 100644
--- a/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
+++ b/SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
@@ -2,7 +2,7 @@
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.
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -17,7 +17,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "Tcg2ConfigImpl.h"
#include <Library/PcdLib.h>
#include <Library/Tpm2CommandLib.h>
+#include <Library/Tpm2DeviceLib.h>
#include <Library/IoLib.h>
+
#include <Guid/TpmInstance.h>
#include <IndustryStandard/TpmPtp.h>
@@ -61,41 +63,6 @@ HII_VENDOR_DEVICE_PATH mTcg2HiiVendorDevicePath = {
UINT8 mCurrentPpRequest;
/**
- Return PTP interface type.
-
- @param[in] Register Pointer to PTP register.
-
- @return PTP interface type.
-**/
-UINT8
-GetPtpInterface (
- IN VOID *Register
- )
-{
- PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;
- PTP_FIFO_INTERFACE_CAPABILITY InterfaceCapability;
-
- //
- // Check interface id
- //
- InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);
- InterfaceCapability.Uint32 = MmioRead32 ((UINTN)&((PTP_FIFO_REGISTERS *)Register)->InterfaceCapability);
-
- if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_CRB) &&
- (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_CRB) &&
- (InterfaceId.Bits.CapCRB != 0)) {
- return TPM_DEVICE_INTERFACE_PTP_CRB;
- }
- if ((InterfaceId.Bits.InterfaceType == PTP_INTERFACE_IDENTIFIER_INTERFACE_TYPE_FIFO) &&
- (InterfaceId.Bits.InterfaceVersion == PTP_INTERFACE_IDENTIFIER_INTERFACE_VERSION_FIFO) &&
- (InterfaceId.Bits.CapFIFO != 0) &&
- (InterfaceCapability.Bits.InterfaceVersion == INTERFACE_CAPABILITY_INTERFACE_VERSION_PTP)) {
- return TPM_DEVICE_INTERFACE_PTP_FIFO;
- }
- return TPM_DEVICE_INTERFACE_TIS;
-}
-
-/**
Return if PTP CRB is supported.
@param[in] Register Pointer to PTP register.
@@ -153,6 +120,7 @@ IsPtpFifoSupported (
/**
Set PTP interface type.
+ Do not update PcdActiveTpmInterfaceType here because interface change only happens on next _TPM_INIT
@param[in] Register Pointer to PTP register.
@param[in] PtpInterface PTP interface type.
@@ -168,12 +136,12 @@ SetPtpInterface (
IN UINT8 PtpInterface
)
{
- UINT8 PtpInterfaceCurrent;
+ TPM2_PTP_INTERFACE_TYPE PtpInterfaceCurrent;
PTP_CRB_INTERFACE_IDENTIFIER InterfaceId;
- PtpInterfaceCurrent = GetPtpInterface (Register);
- if ((PtpInterfaceCurrent != TPM_DEVICE_INTERFACE_PTP_FIFO) &&
- (PtpInterfaceCurrent != TPM_DEVICE_INTERFACE_PTP_CRB)) {
+ PtpInterfaceCurrent = PcdGet8(PcdActiveTpmInterfaceType);
+ if ((PtpInterfaceCurrent != Tpm2PtpInterfaceFifo) &&
+ (PtpInterfaceCurrent != Tpm2PtpInterfaceCrb)) {
return EFI_UNSUPPORTED;
}
InterfaceId.Uint32 = MmioRead32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId);
@@ -182,14 +150,14 @@ SetPtpInterface (
}
switch (PtpInterface) {
- case TPM_DEVICE_INTERFACE_PTP_FIFO:
+ case Tpm2PtpInterfaceFifo:
if (InterfaceId.Bits.CapFIFO == 0) {
return EFI_UNSUPPORTED;
}
InterfaceId.Bits.InterfaceSelector = PTP_INTERFACE_IDENTIFIER_INTERFACE_SELECTOR_FIFO;
MmioWrite32 ((UINTN)&((PTP_CRB_REGISTERS *)Register)->InterfaceId, InterfaceId.Uint32);
return EFI_SUCCESS;
- case TPM_DEVICE_INTERFACE_PTP_CRB:
+ case Tpm2PtpInterfaceCrb:
if (InterfaceId.Bits.CapCRB == 0) {
return EFI_UNSUPPORTED;
}
@@ -825,7 +793,7 @@ InstallTcg2ConfigForm (
TPML_PCR_SELECTION Pcrs;
CHAR16 TempBuffer[1024];
TCG2_CONFIGURATION_INFO Tcg2ConfigInfo;
- UINT8 TpmDeviceInterfaceDetected;
+ TPM2_PTP_INTERFACE_TYPE TpmDeviceInterfaceDetected;
DriverHandle = NULL;
ConfigAccess = &PrivateData->ConfigAccess;
@@ -930,15 +898,15 @@ InstallTcg2ConfigForm (
// Update TPM device interface type
//
if (PrivateData->TpmDeviceDetected == TPM_DEVICE_2_0_DTPM) {
- TpmDeviceInterfaceDetected = GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));
+ TpmDeviceInterfaceDetected = PcdGet8(PcdActiveTpmInterfaceType);
switch (TpmDeviceInterfaceDetected) {
- case TPM_DEVICE_INTERFACE_TIS:
+ case Tpm2PtpInterfaceTis:
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT), L"TIS", NULL);
break;
- case TPM_DEVICE_INTERFACE_PTP_FIFO:
+ case Tpm2PtpInterfaceFifo:
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT), L"PTP FIFO", NULL);
break;
- case TPM_DEVICE_INTERFACE_PTP_CRB:
+ case Tpm2PtpInterfaceCrb:
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_STATE_CONTENT), L"PTP CRB", NULL);
break;
default:
@@ -948,13 +916,13 @@ InstallTcg2ConfigForm (
Tcg2ConfigInfo.TpmDeviceInterfaceAttempt = TpmDeviceInterfaceDetected;
switch (TpmDeviceInterfaceDetected) {
- case TPM_DEVICE_INTERFACE_TIS:
+ case Tpm2PtpInterfaceTis:
Tcg2ConfigInfo.TpmDeviceInterfacePtpFifoSupported = FALSE;
Tcg2ConfigInfo.TpmDeviceInterfacePtpCrbSupported = FALSE;
HiiSetString (PrivateData->HiiHandle, STRING_TOKEN (STR_TCG2_DEVICE_INTERFACE_CAPABILITY_CONTENT), L"TIS", NULL);
break;
- case TPM_DEVICE_INTERFACE_PTP_FIFO:
- case TPM_DEVICE_INTERFACE_PTP_CRB:
+ case Tpm2PtpInterfaceFifo:
+ case Tpm2PtpInterfaceCrb:
Tcg2ConfigInfo.TpmDeviceInterfacePtpFifoSupported = IsPtpFifoSupported((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));
Tcg2ConfigInfo.TpmDeviceInterfacePtpCrbSupported = IsPtpCrbSupported((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));
TempBuffer[0] = 0;