]>
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 |
1affa1c0 LE |
11 | This program and the accompanying materials are licensed and made available\r |
12 | under the terms and conditions of the BSD License which accompanies this\r | |
13 | distribution. The full text of the license may be found at\r | |
14 | http://opensource.org/licenses/bsd-license.php\r | |
6cf1880f | 15 | \r |
1affa1c0 LE |
16 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r |
17 | WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
6cf1880f MAL |
18 | **/\r |
19 | \r | |
20 | \r | |
21 | #include <PiPei.h>\r | |
22 | \r | |
23 | #include <Guid/TpmInstance.h>\r | |
24 | #include <Library/DebugLib.h>\r | |
25 | #include <Library/PeiServicesLib.h>\r | |
26 | #include <Library/Tpm2DeviceLib.h>\r | |
27 | #include <Ppi/TpmInitialized.h>\r | |
28 | \r | |
29 | STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmSelectedPpi = {\r | |
30 | (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r | |
31 | &gEfiTpmDeviceSelectedGuid,\r | |
32 | NULL\r | |
33 | };\r | |
34 | \r | |
35 | STATIC CONST EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = {\r | |
36 | EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r | |
37 | &gPeiTpmInitializationDonePpiGuid,\r | |
38 | NULL\r | |
39 | };\r | |
40 | \r | |
41 | /**\r | |
42 | The entry point for Tcg2 configuration driver.\r | |
43 | \r | |
44 | @param FileHandle Handle of the file being invoked.\r | |
45 | @param PeiServices Describes the list of possible PEI Services.\r | |
46 | **/\r | |
47 | EFI_STATUS\r | |
48 | EFIAPI\r | |
49 | Tcg2ConfigPeimEntryPoint (\r | |
50 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
51 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
52 | )\r | |
53 | {\r | |
54 | UINTN Size;\r | |
55 | EFI_STATUS Status;\r | |
56 | \r | |
57 | DEBUG ((DEBUG_INFO, "%a\n", __FUNCTION__));\r | |
58 | \r | |
59 | Status = Tpm2RequestUseTpm ();\r | |
60 | if (!EFI_ERROR (Status)) {\r | |
1affa1c0 LE |
61 | DEBUG ((DEBUG_INFO, "%a: TPM2 detected\n", __FUNCTION__));\r |
62 | Size = sizeof (gEfiTpmDeviceInstanceTpm20DtpmGuid);\r | |
63 | Status = PcdSetPtrS (\r | |
64 | PcdTpmInstanceGuid,\r | |
65 | &Size,\r | |
66 | &gEfiTpmDeviceInstanceTpm20DtpmGuid\r | |
67 | );\r | |
68 | ASSERT_EFI_ERROR (Status);\r | |
6cf1880f | 69 | } else {\r |
1affa1c0 LE |
70 | DEBUG ((DEBUG_INFO, "%a: no TPM2 detected\n", __FUNCTION__));\r |
71 | //\r | |
72 | // If no TPM2 was detected, we still need to install\r | |
73 | // TpmInitializationDonePpi. Namely, Tcg2Pei will exit early upon seeing\r | |
74 | // the default (all-bits-zero) contents of PcdTpmInstanceGuid, thus we have\r | |
75 | // to install the PPI in its place, in order to unblock any dependent\r | |
76 | // PEIMs.\r | |
77 | //\r | |
78 | Status = PeiServicesInstallPpi (&mTpmInitializationDonePpiList);\r | |
79 | ASSERT_EFI_ERROR (Status);\r | |
6cf1880f MAL |
80 | }\r |
81 | \r | |
82 | //\r | |
83 | // Selection done\r | |
84 | //\r | |
85 | Status = PeiServicesInstallPpi (&mTpmSelectedPpi);\r | |
86 | ASSERT_EFI_ERROR (Status);\r | |
87 | \r | |
88 | return Status;\r | |
89 | }\r |