]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmStandaloneMm.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2DeviceLibDTpmStandaloneMm.c
1 /** @file
2 This file abstract internal interfaces of which implementation differs per library instance.
3
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
5 Copyright (c) Microsoft Corporation.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <Library/Tpm2DeviceLib.h>
11
12 #include "Tpm2DeviceLibDTpm.h"
13
14 TPM2_PTP_INTERFACE_TYPE mActiveTpmInterfaceType;
15 UINT8 mCRBIdleByPass;
16
17 /**
18 Return cached PTP CRB interface IdleByPass state.
19
20 @return Cached PTP CRB interface IdleByPass state.
21 **/
22 UINT8
23 GetCachedIdleByPass (
24 VOID
25 )
26 {
27 return mCRBIdleByPass;
28 }
29
30 /**
31 Return cached PTP interface type.
32
33 @return Cached PTP interface type.
34 **/
35 TPM2_PTP_INTERFACE_TYPE
36 GetCachedPtpInterface (
37 VOID
38 )
39 {
40 return mActiveTpmInterfaceType;
41 }
42
43 /**
44 The common function cache current active TpmInterfaceType when needed.
45
46 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance
47 **/
48 EFI_STATUS
49 InternalTpm2DeviceLibDTpmCommonConstructor (
50 VOID
51 )
52 {
53 mActiveTpmInterfaceType = 0xFF;
54 mCRBIdleByPass = 0xFF;
55
56 //
57 // Always cache current active TpmInterfaceType for StandaloneMm implementation
58 //
59 mActiveTpmInterfaceType = Tpm2GetPtpInterface ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));
60
61 if (mActiveTpmInterfaceType == Tpm2PtpInterfaceCrb) {
62 mCRBIdleByPass = Tpm2GetIdleByPass ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));
63 }
64
65 return EFI_SUCCESS;
66 }