]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/FspWrapperPlatformSecLibSample.c
IntelFsp2Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelFsp2WrapperPkg / Library / SecFspWrapperPlatformSecLibSample / FspWrapperPlatformSecLibSample.c
CommitLineData
cf1d4549
JY
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
f86b9293
LG
21#include <Library/DebugLib.h>\r
22#include <Library/BaseMemoryLib.h>\r
cf1d4549
JY
23\r
24/**\r
25 This interface conveys state information out of the Security (SEC) phase into PEI.\r
26\r
27 @param[in] PeiServices Pointer to the PEI Services Table.\r
28 @param[in,out] StructureSize Pointer to the variable describing size of the input buffer.\r
29 @param[out] PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.\r
30\r
31 @retval EFI_SUCCESS The data was successfully returned.\r
32 @retval EFI_BUFFER_TOO_SMALL The buffer was too small.\r
33\r
34**/\r
35EFI_STATUS\r
36EFIAPI\r
37SecPlatformInformation (\r
38 IN CONST EFI_PEI_SERVICES **PeiServices,\r
39 IN OUT UINT64 *StructureSize,\r
40 OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord\r
41 );\r
42\r
43/**\r
44 This interface conveys performance information out of the Security (SEC) phase into PEI.\r
45\r
46 This service is published by the SEC phase. The SEC phase handoff has an optional\r
47 EFI_PEI_PPI_DESCRIPTOR list as its final argument when control is passed from SEC into the\r
48 PEI Foundation. As such, if the platform supports collecting performance data in SEC,\r
49 this information is encapsulated into the data structure abstracted by this service.\r
50 This information is collected for the boot-strap processor (BSP) on IA-32.\r
51\r
52 @param[in] PeiServices The pointer to the PEI Services Table.\r
53 @param[in] This The pointer to this instance of the PEI_SEC_PERFORMANCE_PPI.\r
54 @param[out] Performance The pointer to performance data collected in SEC phase.\r
55\r
56 @retval EFI_SUCCESS The data was successfully returned.\r
57\r
58**/\r
59EFI_STATUS\r
60EFIAPI\r
61SecGetPerformance (\r
62 IN CONST EFI_PEI_SERVICES **PeiServices,\r
63 IN PEI_SEC_PERFORMANCE_PPI *This,\r
64 OUT FIRMWARE_SEC_PERFORMANCE *Performance\r
65 );\r
66\r
67PEI_SEC_PERFORMANCE_PPI mSecPerformancePpi = {\r
68 SecGetPerformance\r
69};\r
70\r
71EFI_PEI_PPI_DESCRIPTOR mPeiSecPlatformPpi[] = {\r
72 {\r
73 EFI_PEI_PPI_DESCRIPTOR_PPI,\r
74 &gTopOfTemporaryRamPpiGuid,\r
75 NULL // To be patched later.\r
76 },\r
77 {\r
78 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
79 &gPeiSecPerformancePpiGuid,\r
80 &mSecPerformancePpi\r
81 },\r
82};\r
83\r
84/**\r
85 A developer supplied function to perform platform specific operations.\r
86\r
87 It's a developer supplied function to perform any operations appropriate to a\r
88 given platform. It's invoked just before passing control to PEI core by SEC\r
89 core. Platform developer may modify the SecCoreData passed to PEI Core.\r
90 It returns a platform specific PPI list that platform wishes to pass to PEI core.\r
91 The Generic SEC core module will merge this list to join the final list passed to\r
92 PEI core.\r
93\r
94 @param[in,out] SecCoreData The same parameter as passing to PEI core. It\r
95 could be overridden by this function.\r
96\r
97 @return The platform specific PPI list to be passed to PEI core or\r
98 NULL if there is no need of such platform specific PPI list.\r
99\r
100**/\r
101EFI_PEI_PPI_DESCRIPTOR *\r
102EFIAPI\r
103SecPlatformMain (\r
104 IN OUT EFI_SEC_PEI_HAND_OFF *SecCoreData\r
105 )\r
106{\r
107 EFI_PEI_PPI_DESCRIPTOR *PpiList;\r
108\r
109 DEBUG((DEBUG_INFO, "SecPlatformMain\n"));\r
110\r
111 DEBUG((DEBUG_INFO, "BootFirmwareVolumeBase - 0x%x\n", SecCoreData->BootFirmwareVolumeBase));\r
112 DEBUG((DEBUG_INFO, "BootFirmwareVolumeSize - 0x%x\n", SecCoreData->BootFirmwareVolumeSize));\r
113 DEBUG((DEBUG_INFO, "TemporaryRamBase - 0x%x\n", SecCoreData->TemporaryRamBase));\r
114 DEBUG((DEBUG_INFO, "TemporaryRamSize - 0x%x\n", SecCoreData->TemporaryRamSize));\r
115 DEBUG((DEBUG_INFO, "PeiTemporaryRamBase - 0x%x\n", SecCoreData->PeiTemporaryRamBase));\r
116 DEBUG((DEBUG_INFO, "PeiTemporaryRamSize - 0x%x\n", SecCoreData->PeiTemporaryRamSize));\r
117 DEBUG((DEBUG_INFO, "StackBase - 0x%x\n", SecCoreData->StackBase));\r
118 DEBUG((DEBUG_INFO, "StackSize - 0x%x\n", SecCoreData->StackSize));\r
119\r
120 InitializeApicTimer (0, (UINT32) -1, TRUE, 5);\r
121\r
122 //\r
123 // Use middle of Heap as temp buffer, it will be copied by caller.\r
124 // Do not use Stack, because it will cause wrong calculation on stack by PeiCore\r
125 //\r
126 PpiList = (VOID *)((UINTN)SecCoreData->PeiTemporaryRamBase + (UINTN)SecCoreData->PeiTemporaryRamSize/2);\r
127 CopyMem (PpiList, mPeiSecPlatformPpi, sizeof(mPeiSecPlatformPpi));\r
128\r
129 //\r
130 // Patch TopOfTemporaryRamPpi\r
131 //\r
132 PpiList[0].Ppi = (VOID *)((UINTN)SecCoreData->TemporaryRamBase + SecCoreData->TemporaryRamSize);\r
133\r
134 return PpiList;\r
135}\r