]>
Commit | Line | Data |
---|---|---|
a4867dea | 1 | /** @file\r |
2fa89c8e | 2 | Configure TPM 2 platform hierarchy on TPM state resume failure on S3 resume\r |
a4867dea SB |
3 | \r |
4 | Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r | |
5 | Copyright (c) Microsoft Corporation.<BR>\r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | **/\r | |
9 | \r | |
10 | #include <PiPei.h>\r | |
11 | #include <Library/PeiServicesLib.h>\r | |
12 | #include <Library/DebugLib.h>\r | |
13 | #include <Library/BaseMemoryLib.h>\r | |
14 | #include <Library/MemoryAllocationLib.h>\r | |
15 | #include <Library/HobLib.h>\r | |
16 | #include <Library/Tpm2CommandLib.h>\r | |
17 | #include <Library/Tpm2DeviceLib.h>\r | |
18 | #include <Library/TpmPlatformHierarchyLib.h>\r | |
19 | #include <Library/RngLib.h>\r | |
20 | \r | |
21 | #include <Ppi/EndOfPeiPhase.h>\r | |
22 | \r | |
c411b485 | 23 | #define MAX_NEW_AUTHORIZATION_SIZE SHA512_DIGEST_SIZE\r |
a4867dea SB |
24 | \r |
25 | /**\r | |
26 | This function handles PlatformInit task at the end of PEI\r | |
27 | \r | |
2fa89c8e SB |
28 | @param[in] PeiServices Pointer to PEI Services Table.\r |
29 | @param[in] NotifyDescriptor Pointer to the descriptor for the Notification event that\r | |
30 | caused this function to execute.\r | |
31 | @param[in] Ppi Pointer to the PPI data associated with this function.\r | |
a4867dea | 32 | \r |
2fa89c8e | 33 | @retval EFI_SUCCESS The function completes successfully\r |
a4867dea SB |
34 | @retval others\r |
35 | **/\r | |
36 | EFI_STATUS\r | |
37 | EFIAPI\r | |
38 | PlatformInitEndOfPei (\r | |
39 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
40 | IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r | |
41 | IN VOID *Ppi\r | |
42 | )\r | |
43 | {\r | |
c411b485 | 44 | VOID *TcgEventLog;\r |
a4867dea SB |
45 | \r |
46 | //\r | |
47 | // Try to get TcgEventLog in S3 to see if S3 error is reported.\r | |
48 | //\r | |
c411b485 | 49 | TcgEventLog = GetFirstGuidHob (&gTcgEventEntryHobGuid);\r |
a4867dea | 50 | if (TcgEventLog == NULL) {\r |
c411b485 | 51 | TcgEventLog = GetFirstGuidHob (&gTcgEvent2EntryHobGuid);\r |
a4867dea SB |
52 | }\r |
53 | \r | |
54 | if (TcgEventLog == NULL) {\r | |
55 | //\r | |
56 | // no S3 error reported\r | |
57 | //\r | |
58 | return EFI_SUCCESS;\r | |
59 | }\r | |
60 | \r | |
61 | //\r | |
62 | // If there is S3 error on TPM_SU_STATE and success on TPM_SU_CLEAR,\r | |
63 | // configure the TPM Platform Hierarchy.\r | |
64 | //\r | |
65 | ConfigureTpmPlatformHierarchy ();\r | |
66 | \r | |
67 | return EFI_SUCCESS;\r | |
68 | }\r | |
69 | \r | |
70 | static EFI_PEI_NOTIFY_DESCRIPTOR mEndOfPeiNotifyList = {\r | |
71 | (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r | |
72 | &gEfiEndOfPeiSignalPpiGuid,\r | |
73 | (EFI_PEIM_NOTIFY_ENTRY_POINT)PlatformInitEndOfPei\r | |
74 | };\r | |
75 | \r | |
76 | /**\r | |
77 | Main entry\r | |
78 | \r | |
79 | @param[in] FileHandle Handle of the file being invoked.\r | |
80 | @param[in] PeiServices Pointer to PEI Services table.\r | |
81 | \r | |
82 | @retval EFI_SUCCESS Install function successfully.\r | |
83 | \r | |
84 | **/\r | |
85 | EFI_STATUS\r | |
86 | EFIAPI\r | |
87 | Tcg2PlatformPeiEntryPoint (\r | |
88 | IN EFI_PEI_FILE_HANDLE FileHandle,\r | |
89 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
90 | )\r | |
91 | {\r | |
c411b485 MK |
92 | EFI_STATUS Status;\r |
93 | EFI_BOOT_MODE BootMode;\r | |
a4867dea SB |
94 | \r |
95 | Status = PeiServicesGetBootMode (&BootMode);\r | |
c411b485 | 96 | ASSERT_EFI_ERROR (Status);\r |
a4867dea SB |
97 | \r |
98 | if (BootMode != BOOT_ON_S3_RESUME) {\r | |
99 | return EFI_SUCCESS;\r | |
100 | }\r | |
101 | \r | |
102 | //\r | |
103 | // Performing PlatformInitEndOfPei after EndOfPei PPI produced\r | |
104 | //\r | |
105 | Status = PeiServicesNotifyPpi (&mEndOfPeiNotifyList);\r | |
106 | \r | |
107 | return Status;\r | |
108 | }\r |