X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=SecurityPkg%2FLibrary%2FTpm2DeviceLibDTpm%2FTpm2InstanceLibDTpm.c;h=5f6e163c0f2ecddc4b4b81a2f2b35c03c7f81641;hp=3f28f21faa39f3bca68621043ebb173f3dd8d5d0;hb=975478f6bb22668efae311eb3f7406e1f18411c2;hpb=07309c3ddc2305b050989e26f6717e2392eedb3d diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c index 3f28f21faa..5f6e163c0f 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2InstanceLibDTpm.c @@ -3,7 +3,7 @@ It can be registered to Tpm2 Device router, to be active TPM2 engine, based on platform setting. -Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials 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 @@ -18,9 +18,34 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include #include +/** + Return PTP interface type. + + @param[in] Register Pointer to PTP register. + + @return PTP interface type. +**/ +TPM2_PTP_INTERFACE_TYPE +Tpm2GetPtpInterface ( + IN VOID *Register + ); + +/** + Return PTP CRB interface IdleByPass state. + + @param[in] Register Pointer to PTP register. + + @return PTP CRB interface IdleByPass state. +**/ +UINT8 +Tpm2GetIdleByPass ( + IN VOID *Register + ); + /** Dump PTP register information. @@ -72,7 +97,7 @@ TPM2_DEVICE_INTERFACE mDTpm2InternalTpm2Device = { }; /** - The function register DTPM2.0 instance. + The function register DTPM2.0 instance and caches current active TPM interface type. @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance **/ @@ -82,7 +107,9 @@ Tpm2InstanceLibDTpmConstructor ( VOID ) { - EFI_STATUS Status; + EFI_STATUS Status; + TPM2_PTP_INTERFACE_TYPE PtpInterface; + UINT8 IdleByPass; Status = Tpm2RegisterTpm2DeviceLib (&mDTpm2InternalTpm2Device); if ((Status == EFI_SUCCESS) || (Status == EFI_UNSUPPORTED)) { @@ -90,6 +117,19 @@ Tpm2InstanceLibDTpmConstructor ( // Unsupported means platform policy does not need this instance enabled. // if (Status == EFI_SUCCESS) { + // + // Cache current active TpmInterfaceType only when needed + // + if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) { + PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); + PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface); + } + + if (PcdGet8(PcdActiveTpmInterfaceType) == Tpm2PtpInterfaceCrb && PcdGet8(PcdCRBIdleByPass) == 0xFF) { + IdleByPass = Tpm2GetIdleByPass((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); + PcdSet8S(PcdCRBIdleByPass, IdleByPass); + } + DumpPtpInfo ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); } return EFI_SUCCESS;