summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmStandaloneMm.c
diff options
context:
space:
mode:
Diffstat (limited to 'SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmStandaloneMm.c')
-rw-r--r--SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmStandaloneMm.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmStandaloneMm.c b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmStandaloneMm.c
new file mode 100644
index 0000000000..eac866d2a7
--- /dev/null
+++ b/SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmStandaloneMm.c
@@ -0,0 +1,66 @@
+/** @file
+ This file abstract internal interfaces of which implementation differs per library instance.
+
+Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/Tpm2DeviceLib.h>
+
+#include "Tpm2DeviceLibDTpm.h"
+
+TPM2_PTP_INTERFACE_TYPE mActiveTpmInterfaceType;
+UINT8 mCRBIdleByPass;
+
+/**
+ Return cached PTP CRB interface IdleByPass state.
+
+ @return Cached PTP CRB interface IdleByPass state.
+**/
+UINT8
+GetCachedIdleByPass (
+ VOID
+ )
+{
+ return mCRBIdleByPass;
+}
+
+/**
+ Return cached PTP interface type.
+
+ @return Cached PTP interface type.
+**/
+TPM2_PTP_INTERFACE_TYPE
+GetCachedPtpInterface (
+ VOID
+ )
+{
+ return mActiveTpmInterfaceType;
+}
+
+/**
+ The common function cache current active TpmInterfaceType when needed.
+
+ @retval EFI_SUCCESS DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance
+**/
+EFI_STATUS
+InternalTpm2DeviceLibDTpmCommonConstructor (
+ VOID
+ )
+{
+ mActiveTpmInterfaceType = 0xFF;
+ mCRBIdleByPass = 0xFF;
+
+ //
+ // Always cache current active TpmInterfaceType for StandaloneMm implementation
+ //
+ mActiveTpmInterfaceType = Tpm2GetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));
+
+ if (mActiveTpmInterfaceType == Tpm2PtpInterfaceCrb) {
+ mCRBIdleByPass = Tpm2GetIdleByPass((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress));
+ }
+
+ return EFI_SUCCESS;
+}