]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Sample to provide FSP wrapper platform sec related function.\r | |
3 | \r | |
4 | Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <PiPei.h>\r | |
16 | \r | |
17 | #include <Ppi/SecPlatformInformation.h>\r | |
18 | #include <Ppi/SecPerformance.h>\r | |
19 | \r | |
20 | #include <Library/LocalApicLib.h>\r | |
21 | \r | |
22 | /**\r | |
23 | This interface conveys state information out of the Security (SEC) phase into PEI.\r | |
24 | \r | |
25 | @param[in] PeiServices Pointer to the PEI Services Table.\r | |
26 | @param[in,out] StructureSize Pointer to the variable describing size of the input buffer.\r | |
27 | @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.\r | |
28 | \r | |
29 | @retval EFI_SUCCESS The data was successfully returned.\r | |
30 | @retval EFI_BUFFER_TOO_SMALL The buffer was too small.\r | |
31 | \r | |
32 | **/\r | |
33 | EFI_STATUS\r | |
34 | EFIAPI\r | |
35 | SecPlatformInformation (\r | |
36 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
37 | IN OUT UINT64 *StructureSize,\r | |
38 | OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord\r | |
39 | );\r | |
40 | \r | |
41 | /**\r | |
42 | This interface conveys performance information out of the Security (SEC) phase into PEI.\r | |
43 | \r | |
44 | This service is published by the SEC phase. The SEC phase handoff has an optional\r | |
45 | EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the\r | |
46 | PEI Foundation. As such, if the platform supports collecting performance data in SEC,\r | |
47 | this information is encapsulated into the data structure abstracted by this service.\r | |
48 | This information is collected for the boot-strap processor (BSP) on IA-32.\r | |
49 | \r | |
50 | @param[in] PeiServices The pointer to the PEI Services Table.\r | |
51 | @param[in] This The pointer to this instance of the PEI_SEC_PERFORMANCE_PPI.\r | |
52 | @param[out] Performance The pointer to performance data collected in SEC phase.\r | |
53 | \r | |
54 | @retval EFI_SUCCESS The data was successfully returned.\r | |
55 | \r | |
56 | **/\r | |
57 | EFI_STATUS\r | |
58 | EFIAPI\r | |
59 | SecGetPerformance (\r | |
60 | IN CONST EFI_PEI_SERVICES **PeiServices,\r | |
61 | IN PEI_SEC_PERFORMANCE_PPI *This,\r | |
62 | OUT FIRMWARE_SEC_PERFORMANCE *Performance\r | |
63 | );\r | |
64 | \r | |
65 | PEI_SEC_PERFORMANCE_PPI mSecPerformancePpi = {\r | |
66 | SecGetPerformance\r | |
67 | };\r | |
68 | \r | |
69 | EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformPpi[] = {\r | |
70 | {\r | |
71 | EFI_PEI_PPI_DESCRIPTOR_PPI,\r | |
72 | &gTopOfTemporaryRamPpiGuid,\r | |
73 | NULL // To be patched later.\r | |
74 | },\r | |
75 | {\r | |
76 | EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r | |
77 | &gPeiSecPerformancePpiGuid,\r | |
78 | &mSecPerformancePpi\r | |
79 | },\r | |
80 | };\r | |
81 | \r | |
82 | /**\r | |
83 | A developer supplied function to perform platform specific operations.\r | |
84 | \r | |
85 | It's a developer supplied function to perform any operations appropriate to a\r | |
86 | given platform. It's invoked just before passing control to PEI core by SEC\r | |
87 | core. Platform developer may modify the SecCoreData passed to PEI Core.\r | |
88 | It returns a platform specific PPI list that platform wishes to pass to PEI core.\r | |
89 | The Generic SEC core module will merge this list to join the final list passed to\r | |
90 | PEI core.\r | |
91 | \r | |
92 | @param[in,out] SecCoreData The same parameter as passing to PEI core. It\r | |
93 | could be overridden by this function.\r | |
94 | \r | |
95 | @return The platform specific PPI list to be passed to PEI core or\r | |
96 | NULL if there is no need of such platform specific PPI list.\r | |
97 | \r | |
98 | **/\r | |
99 | EFI_PEI_PPI_DESCRIPTOR *\r | |
100 | EFIAPI\r | |
101 | SecPlatformMain (\r | |
102 | IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData\r | |
103 | )\r | |
104 | {\r | |
105 | EFI_PEI_PPI_DESCRIPTOR *PpiList;\r | |
106 | \r | |
107 | DEBUG((DEBUG_INFO, "SecPlatformMain\n"));\r | |
108 | \r | |
109 | DEBUG((DEBUG_INFO, "BootFirmwareVolumeBase - 0x%x\n", SecCoreData->BootFirmwareVolumeBase));\r | |
110 | DEBUG((DEBUG_INFO, "BootFirmwareVolumeSize - 0x%x\n", SecCoreData->BootFirmwareVolumeSize));\r | |
111 | DEBUG((DEBUG_INFO, "TemporaryRamBase - 0x%x\n", SecCoreData->TemporaryRamBase));\r | |
112 | DEBUG((DEBUG_INFO, "TemporaryRamSize - 0x%x\n", SecCoreData->TemporaryRamSize));\r | |
113 | DEBUG((DEBUG_INFO, "PeiTemporaryRamBase - 0x%x\n", SecCoreData->PeiTemporaryRamBase));\r | |
114 | DEBUG((DEBUG_INFO, "PeiTemporaryRamSize - 0x%x\n", SecCoreData->PeiTemporaryRamSize));\r | |
115 | DEBUG((DEBUG_INFO, "StackBase - 0x%x\n", SecCoreData->StackBase));\r | |
116 | DEBUG((DEBUG_INFO, "StackSize - 0x%x\n", SecCoreData->StackSize));\r | |
117 | \r | |
118 | InitializeApicTimer (0, (UINT32) -1, TRUE, 5);\r | |
119 | \r | |
120 | //\r | |
121 | // Use middle of Heap as temp buffer, it will be copied by caller.\r | |
122 | // Do not use Stack, because it will cause wrong calculation on stack by PeiCore\r | |
123 | //\r | |
124 | PpiList = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + (UINTN)SecCoreData->PeiTemporaryRamSize/2);\r | |
125 | CopyMem (PpiList, mPeiSecPlatformPpi, sizeof(mPeiSecPlatformPpi));\r | |
126 | \r | |
127 | //\r | |
128 | // Patch TopOfTemporaryRamPpi\r | |
129 | //\r | |
130 | PpiList[0].Ppi = (VOID *)((UINTN)SecCoreData->TemporaryRamBase + SecCoreData->TemporaryRamSize);\r | |
131 | \r | |
132 | return PpiList;\r | |
133 | }\r |