]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Tcg / Tcg2Config / Tcg2ConfigPeim.c
CommitLineData
6cf1880f 1/** @file\r
1affa1c0 2 Set TPM device type\r
6cf1880f 3\r
1affa1c0 4 In SecurityPkg, this module initializes the TPM device type based on a UEFI\r
8cb89036 5 variable and/or hardware detection. In OvmfPkg, the module only performs TPM\r
1affa1c0 6 hardware detection.\r
6cf1880f 7\r
1affa1c0
LE
8 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
9 Copyright (C) 2018, Red Hat, Inc.\r
6cf1880f 10\r
b26f0cf9 11 SPDX-License-Identifier: BSD-2-Clause-Patent\r
6cf1880f
MAL
12**/\r
13\r
6cf1880f
MAL
14#include <PiPei.h>\r
15\r
16#include <Guid/TpmInstance.h>\r
17#include <Library/DebugLib.h>\r
18#include <Library/PeiServicesLib.h>\r
19#include <Library/Tpm2DeviceLib.h>\r
20#include <Ppi/TpmInitialized.h>\r
21\r
fc72a6ce
LE
22#include "Tpm12Support.h"\r
23\r
ac0a286f 24STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi = {\r
6cf1880f
MAL
25 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
26 &gEfiTpmDeviceSelectedGuid,\r
27 NULL\r
28};\r
29\r
30STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {\r
31 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
32 &gPeiTpmInitializationDonePpiGuid,\r
33 NULL\r
34};\r
35\r
36/**\r
37 The entry point for Tcg2 configuration driver.\r
38\r
39 @param FileHandle Handle of the file being invoked.\r
40 @param PeiServices Describes the list of possible PEI Services.\r
41**/\r
42EFI_STATUS\r
43EFIAPI\r
44Tcg2ConfigPeimEntryPoint (\r
45 IN EFI_PEI_FILE_HANDLE FileHandle,\r
46 IN CONST EFI_PEI_SERVICES **PeiServices\r
47 )\r
48{\r
ac0a286f
MK
49 UINTN Size;\r
50 EFI_STATUS Status;\r
6cf1880f
MAL
51\r
52 DEBUG ((DEBUG_INFO, "%a\n", __FUNCTION__));\r
53\r
fc72a6ce
LE
54 Status = InternalTpm12Detect ();\r
55 if (!EFI_ERROR (Status)) {\r
89236992 56 DEBUG ((DEBUG_INFO, "%a: TPM1.2 detected\n", __FUNCTION__));\r
ac0a286f 57 Size = sizeof (gEfiTpmDeviceInstanceTpm12Guid);\r
1affa1c0
LE
58 Status = PcdSetPtrS (\r
59 PcdTpmInstanceGuid,\r
60 &Size,\r
89236992 61 &gEfiTpmDeviceInstanceTpm12Guid\r
1affa1c0
LE
62 );\r
63 ASSERT_EFI_ERROR (Status);\r
6cf1880f 64 } else {\r
89236992
MAL
65 Status = Tpm2RequestUseTpm ();\r
66 if (!EFI_ERROR (Status)) {\r
67 DEBUG ((DEBUG_INFO, "%a: TPM2 detected\n", __FUNCTION__));\r
ac0a286f 68 Size = sizeof (gEfiTpmDeviceInstanceTpm20DtpmGuid);\r
89236992
MAL
69 Status = PcdSetPtrS (\r
70 PcdTpmInstanceGuid,\r
71 &Size,\r
72 &gEfiTpmDeviceInstanceTpm20DtpmGuid\r
73 );\r
74 ASSERT_EFI_ERROR (Status);\r
75 } else {\r
76 DEBUG ((DEBUG_INFO, "%a: no TPM detected\n", __FUNCTION__));\r
77 //\r
78 // If no TPM2 was detected, we still need to install\r
79 // TpmInitializationDonePpi. Namely, Tcg2Pei will exit early upon seeing\r
80 // the default (all-bits-zero) contents of PcdTpmInstanceGuid, thus we have\r
81 // to install the PPI in its place, in order to unblock any dependent\r
82 // PEIMs.\r
83 //\r
84 Status = PeiServicesInstallPpi (&mTpmInitializationDonePpiList);\r
85 ASSERT_EFI_ERROR (Status);\r
86 }\r
6cf1880f
MAL
87 }\r
88\r
89 //\r
90 // Selection done\r
91 //\r
92 Status = PeiServicesInstallPpi (&mTpmSelectedPpi);\r
93 ASSERT_EFI_ERROR (Status);\r
94\r
95 return Status;\r
96}\r