]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpmBase.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Library / Tpm2DeviceLibDTpm / Tpm2DeviceLibDTpmBase.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 #include <Library/PcdLib.h>
12
13 #include "Tpm2DeviceLibDTpm.h"
14
15 /**
16 Return cached PTP CRB interface IdleByPass state.
17
18 @return Cached PTP CRB interface IdleByPass state.
19 **/
20 UINT8
21 GetCachedIdleByPass (
22 VOID
23 )
24 {
25 return PcdGet8 (PcdCRBIdleByPass);
26 }
27
28 /**
29 Return cached PTP interface type.
30
31 @return Cached PTP interface type.
32 **/
33 TPM2_PTP_INTERFACE_TYPE
34 GetCachedPtpInterface (
35 VOID
36 )
37 {
38 return PcdGet8 (PcdActiveTpmInterfaceType);
39 }
40
41 /**
42 The common function cache current active TpmInterfaceType when needed.
43
44 @retval EFI_SUCCESS DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance
45 **/
46 EFI_STATUS
47 InternalTpm2DeviceLibDTpmCommonConstructor (
48 VOID
49 )
50 {
51 TPM2_PTP_INTERFACE_TYPE PtpInterface;
52 UINT8 IdleByPass;
53
54 //
55 // Cache current active TpmInterfaceType only when needed
56 //
57 if (PcdGet8 (PcdActiveTpmInterfaceType) == 0xFF) {
58 PtpInterface = Tpm2GetPtpInterface ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));
59 PcdSet8S (PcdActiveTpmInterfaceType, PtpInterface);
60 }
61
62 if ((PcdGet8 (PcdActiveTpmInterfaceType) == Tpm2PtpInterfaceCrb) && (PcdGet8 (PcdCRBIdleByPass) == 0xFF)) {
63 IdleByPass = Tpm2GetIdleByPass ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));
64 PcdSet8S (PcdCRBIdleByPass, IdleByPass);
65 }
66
67 return EFI_SUCCESS;
68 }