]>
Commit | Line | Data |
---|---|---|
7a56650e KQ |
1 | /** @file\r |
2 | This file abstract internal interfaces of which implementation differs per library instance.\r | |
3 | \r | |
4 | Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>\r | |
5 | Copyright (c) Microsoft Corporation.\r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | **/\r | |
9 | \r | |
10 | #include <Library/Tpm2DeviceLib.h>\r | |
11 | #include <Library/PcdLib.h>\r | |
12 | \r | |
13 | #include "Tpm2DeviceLibDTpm.h"\r | |
14 | \r | |
15 | /**\r | |
16 | Return cached PTP CRB interface IdleByPass state.\r | |
17 | \r | |
18 | @return Cached PTP CRB interface IdleByPass state.\r | |
19 | **/\r | |
20 | UINT8\r | |
21 | GetCachedIdleByPass (\r | |
22 | VOID\r | |
23 | )\r | |
24 | {\r | |
c411b485 | 25 | return PcdGet8 (PcdCRBIdleByPass);\r |
7a56650e KQ |
26 | }\r |
27 | \r | |
28 | /**\r | |
29 | Return cached PTP interface type.\r | |
30 | \r | |
31 | @return Cached PTP interface type.\r | |
32 | **/\r | |
33 | TPM2_PTP_INTERFACE_TYPE\r | |
34 | GetCachedPtpInterface (\r | |
35 | VOID\r | |
36 | )\r | |
37 | {\r | |
c411b485 | 38 | return PcdGet8 (PcdActiveTpmInterfaceType);\r |
7a56650e KQ |
39 | }\r |
40 | \r | |
41 | /**\r | |
42 | The common function cache current active TpmInterfaceType when needed.\r | |
43 | \r | |
44 | @retval EFI_SUCCESS DTPM2.0 instance is registered, or system does not support register DTPM2.0 instance\r | |
45 | **/\r | |
46 | EFI_STATUS\r | |
47 | InternalTpm2DeviceLibDTpmCommonConstructor (\r | |
48 | VOID\r | |
49 | )\r | |
50 | {\r | |
51 | TPM2_PTP_INTERFACE_TYPE PtpInterface;\r | |
52 | UINT8 IdleByPass;\r | |
53 | \r | |
54 | //\r | |
55 | // Cache current active TpmInterfaceType only when needed\r | |
56 | //\r | |
c411b485 MK |
57 | if (PcdGet8 (PcdActiveTpmInterfaceType) == 0xFF) {\r |
58 | PtpInterface = Tpm2GetPtpInterface ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));\r | |
59 | PcdSet8S (PcdActiveTpmInterfaceType, PtpInterface);\r | |
7a56650e KQ |
60 | }\r |
61 | \r | |
c411b485 MK |
62 | if ((PcdGet8 (PcdActiveTpmInterfaceType) == Tpm2PtpInterfaceCrb) && (PcdGet8 (PcdCRBIdleByPass) == 0xFF)) {\r |
63 | IdleByPass = Tpm2GetIdleByPass ((VOID *)(UINTN)PcdGet64 (PcdTpmBaseAddress));\r | |
64 | PcdSet8S (PcdCRBIdleByPass, IdleByPass);\r | |
7a56650e KQ |
65 | }\r |
66 | \r | |
67 | return EFI_SUCCESS;\r | |
68 | }\r |