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