]>
Commit | Line | Data |
---|---|---|
6cf1880f | 1 | /** @file\r |
1affa1c0 | 2 | Set TPM device type\r |
6cf1880f | 3 | \r |
1affa1c0 LE |
4 | In SecurityPkg, this module initializes the TPM device type based on a UEFI\r |
5 | variable and/or hardware detection. In OvmfPkg, the module only performs TPM2\r | |
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 | |
14 | \r | |
15 | #include <PiPei.h>\r | |
16 | \r | |
17 | #include <Guid/TpmInstance.h>\r | |
18 | #include <Library/DebugLib.h>\r | |
19 | #include <Library/PeiServicesLib.h>\r | |
20 | #include <Library/Tpm2DeviceLib.h>\r | |
21 | #include <Ppi/TpmInitialized.h>\r | |
22 | \r | |
23 | STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi = {\r | |
24 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r | |
25 | &gEfiTpmDeviceSelectedGuid,\r | |
26 | NULL\r | |
27 | };\r | |
28 | \r | |
29 | STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {\r | |
30 | EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r | |
31 | &gPeiTpmInitializationDonePpiGuid,\r | |
32 | NULL\r | |
33 | };\r | |
34 | \r | |
35 | /**\r | |
36 | The entry point for Tcg2 configuration driver.\r | |
37 | \r | |
38 | @param FileHandle Handle of the file being invoked.\r | |
39 | @param PeiServices Describes the list of possible PEI Services.\r | |
40 | **/\r | |
41 | EFI_STATUS\r | |
42 | EFIAPI\r | |
43 | Tcg2ConfigPeimEntryPoint (\r | |
44 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
45 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
46 | )\r | |
47 | {\r | |
48 | UINTN Size;\r | |
49 | EFI_STATUS Status;\r | |
50 | \r | |
51 | DEBUG ((DEBUG_INFO, "%a\n", __FUNCTION__));\r | |
52 | \r | |
53 | Status = Tpm2RequestUseTpm ();\r | |
54 | if (!EFI_ERROR (Status)) {\r | |
1affa1c0 LE |
55 | DEBUG ((DEBUG_INFO, "%a: TPM2 detected\n", __FUNCTION__));\r |
56 | Size = sizeof (gEfiTpmDeviceInstanceTpm20DtpmGuid);\r | |
57 | Status = PcdSetPtrS (\r | |
58 | PcdTpmInstanceGuid,\r | |
59 | &Size,\r | |
60 | &gEfiTpmDeviceInstanceTpm20DtpmGuid\r | |
61 | );\r | |
62 | ASSERT_EFI_ERROR (Status);\r | |
6cf1880f | 63 | } else {\r |
1affa1c0 LE |
64 | DEBUG ((DEBUG_INFO, "%a: no TPM2 detected\n", __FUNCTION__));\r |
65 | //\r | |
66 | // If no TPM2 was detected, we still need to install\r | |
67 | // TpmInitializationDonePpi. Namely, Tcg2Pei will exit early upon seeing\r | |
68 | // the default (all-bits-zero) contents of PcdTpmInstanceGuid, thus we have\r | |
69 | // to install the PPI in its place, in order to unblock any dependent\r | |
70 | // PEIMs.\r | |
71 | //\r | |
72 | Status = PeiServicesInstallPpi (&mTpmInitializationDonePpiList);\r | |
73 | ASSERT_EFI_ERROR (Status);\r | |
6cf1880f MAL |
74 | }\r |
75 | \r | |
76 | //\r | |
77 | // Selection done\r | |
78 | //\r | |
79 | Status = PeiServicesInstallPpi (&mTpmSelectedPpi);\r | |
80 | ASSERT_EFI_ERROR (Status);\r | |
81 | \r | |
82 | return Status;\r | |
83 | }\r |