X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=SecurityPkg%2FLibrary%2FTpm2DeviceLibDTpm%2FTpm2DeviceLibDTpm.c;h=3feb64df7edfde5f1c0ac987f7e69018980818e6;hb=f15cb995bb38;hp=7d10dbbe47dba64e6f42bd925bb169641bb0d2cc;hpb=c1d932429ef9700a2da64452546be14e92468b07;p=mirror_edk2.git diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c index 7d10dbbe47..3feb64df7e 100644 --- a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c +++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.c @@ -1,8 +1,8 @@ /** @file - Ihis library is TPM2 DTPM device lib. + This library is TPM2 DTPM device lib. Choosing this library means platform uses and only uses DTPM device as TPM2 engine. -Copyright (c) 2013, 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 @@ -17,6 +17,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #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 + ); /** This service enables the sending of commands to the TPM2. @@ -114,3 +127,26 @@ Tpm2RegisterTpm2DeviceLib ( { return EFI_UNSUPPORTED; } + +/** + The function caches current active TPM interface type. + + @retval EFI_SUCCESS DTPM2.0 instance is registered, or system dose not surpport registr DTPM2.0 instance +**/ +EFI_STATUS +EFIAPI +Tpm2DeviceLibConstructor ( + VOID + ) +{ + TPM2_PTP_INTERFACE_TYPE PtpInterface; + + // + // Cache current active TpmInterfaceType only when needed + // + if (PcdGet8(PcdActiveTpmInterfaceType) == 0xFF) { + PtpInterface = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress)); + PcdSet8S(PcdActiveTpmInterfaceType, PtpInterface); + } + return EFI_SUCCESS; +}