IntelFsp2WrapperPkg: Remove unused header files from Fspm and Fsps WrapperPeim
[mirror_edk2.git] / IntelFsp2WrapperPkg / FspmWrapperPeim / FspmWrapperPeim.c
CommitLineData
cf1d4549
JY
1/** @file\r
2 This will be invoked only once. It will call FspMemoryInit API,\r
3 register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi\r
4 notify to call FspSiliconInit API.\r
5\r
6 Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php.\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17\r
18#include <PiPei.h>\r
19\r
20#include <Library/PeimEntryPoint.h>\r
21#include <Library/PeiServicesLib.h>\r
22#include <Library/PeiServicesTablePointerLib.h>\r
23#include <Library/BaseLib.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/BaseMemoryLib.h>\r
26#include <Library/MemoryAllocationLib.h>\r
27#include <Library/HobLib.h>\r
28#include <Library/PcdLib.h>\r
29#include <Library/TimerLib.h>\r
30#include <Library/PerformanceLib.h>\r
31#include <Library/FspWrapperPlatformLib.h>\r
32#include <Library/FspWrapperHobProcessLib.h>\r
33#include <Library/FspWrapperApiLib.h>\r
34\r
35#include <Ppi/FspSiliconInitDone.h>\r
36#include <Ppi/EndOfPeiPhase.h>\r
37#include <Ppi/MemoryDiscovered.h>\r
38#include <Ppi/SecPlatformInformation.h>\r
cf1d4549
JY
39#include <Library/FspWrapperApiTestLib.h>\r
40#include <FspEas.h>\r
41\r
42extern EFI_GUID gFspHobGuid;\r
43\r
44/**\r
45 Call FspMemoryInit API.\r
46\r
47 @return Status returned by FspMemoryInit API.\r
48**/\r
49EFI_STATUS\r
50PeiFspMemoryInit (\r
51 VOID\r
52 )\r
53{\r
54 FSP_INFO_HEADER *FspmHeaderPtr;\r
55 EFI_STATUS Status;\r
56 UINT64 TimeStampCounterStart;\r
57 VOID *FspHobListPtr;\r
58 VOID *HobData;\r
59 FSPM_UPD_COMMON *FspmUpdDataPtr;\r
60 UINTN *SourceData;\r
61\r
62 DEBUG ((DEBUG_INFO, "PeiFspMemoryInit enter\n"));\r
63\r
64 FspHobListPtr = NULL;\r
65\r
66 //\r
67 // Copy default FSP-M UPD data from Flash\r
68 //\r
69 FspmHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));\r
599c45ff
HW
70 DEBUG ((DEBUG_INFO, "FspmHeaderPtr - 0x%x\n", FspmHeaderPtr));\r
71 if (FspmHeaderPtr == NULL) {\r
72 return EFI_DEVICE_ERROR;\r
73 }\r
74\r
cf1d4549
JY
75 FspmUpdDataPtr = (FSPM_UPD_COMMON *)AllocateZeroPool ((UINTN)FspmHeaderPtr->CfgRegionSize);\r
76 ASSERT (FspmUpdDataPtr != NULL);\r
77 SourceData = (UINTN *)((UINTN)FspmHeaderPtr->ImageBase + (UINTN)FspmHeaderPtr->CfgRegionOffset);\r
78 CopyMem (FspmUpdDataPtr, SourceData, (UINTN)FspmHeaderPtr->CfgRegionSize);\r
79\r
1f1ec99d 80 DEBUG ((DEBUG_INFO, "UpdateFspmUpdData enter\n"));\r
cf1d4549
JY
81 UpdateFspmUpdData ((VOID *)FspmUpdDataPtr);\r
82 DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", FspmUpdDataPtr->FspmArchUpd.NvsBufferPtr));\r
83 DEBUG ((DEBUG_INFO, " StackBase - 0x%x\n", FspmUpdDataPtr->FspmArchUpd.StackBase));\r
84 DEBUG ((DEBUG_INFO, " StackSize - 0x%x\n", FspmUpdDataPtr->FspmArchUpd.StackSize));\r
85 DEBUG ((DEBUG_INFO, " BootLoaderTolumSize - 0x%x\n", FspmUpdDataPtr->FspmArchUpd.BootLoaderTolumSize));\r
86 DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", FspmUpdDataPtr->FspmArchUpd.BootMode));\r
87 DEBUG ((DEBUG_INFO, " HobListPtr - 0x%x\n", &FspHobListPtr));\r
88\r
89 TimeStampCounterStart = AsmReadTsc ();\r
90 Status = CallFspMemoryInit (FspmUpdDataPtr, &FspHobListPtr);\r
91 // Create hobs after memory initialization and not in temp RAM. Hence passing the recorded timestamp here\r
92 PERF_START_EX(&gFspApiPerformanceGuid, "EventRec", NULL, TimeStampCounterStart, 0xD000);\r
93 PERF_END_EX(&gFspApiPerformanceGuid, "EventRec", NULL, 0, 0xD07F);\r
94 DEBUG ((DEBUG_INFO, "Total time spent executing FspMemoryInitApi: %d millisecond\n", DivU64x32 (GetTimeInNanoSecond (AsmReadTsc () - TimeStampCounterStart), 1000000)));\r
f862a3b6
JY
95\r
96 //\r
97 // Reset the system if FSP API returned FSP_STATUS_RESET_REQUIRED status\r
98 //\r
99 if ((Status >= FSP_STATUS_RESET_REQUIRED_COLD) && (Status <= FSP_STATUS_RESET_REQUIRED_8)) {\r
100 DEBUG((DEBUG_INFO, "FspMemoryInitApi requested reset 0x%x\n", Status));\r
101 CallFspWrapperResetSystem ((UINT32)Status);\r
102 }\r
103\r
cf1d4549
JY
104 if (EFI_ERROR(Status)) {\r
105 DEBUG ((DEBUG_ERROR, "ERROR - Failed to execute FspMemoryInitApi(), Status = %r\n", Status));\r
106 }\r
107 DEBUG((DEBUG_INFO, "FspMemoryInit status: 0x%x\n", Status));\r
108 ASSERT_EFI_ERROR (Status);\r
109\r
110\r
111 Status = TestFspMemoryInitApiOutput (FspmUpdDataPtr, &FspHobListPtr);\r
112 if (EFI_ERROR (Status)) {\r
113 DEBUG ((DEBUG_ERROR, "ERROR - TestFspMemoryInitApiOutput () fail, Status = %r\n", Status));\r
114 }\r
115\r
116 DEBUG ((DEBUG_INFO, " FspHobListPtr (returned) - 0x%x\n", FspHobListPtr));\r
117 ASSERT (FspHobListPtr != NULL);\r
118\r
119 PostFspmHobProcess (FspHobListPtr);\r
120\r
121 //\r
122 // FspHobList is not complete at this moment.\r
123 // Save FspHobList pointer to hob, so that it can be got later\r
124 //\r
125 HobData = BuildGuidHob (\r
126 &gFspHobGuid,\r
127 sizeof (VOID *)\r
128 );\r
129 ASSERT (HobData != NULL);\r
130 CopyMem (HobData, &FspHobListPtr, sizeof (FspHobListPtr));\r
131\r
132 return Status;\r
133}\r
134\r
135/**\r
136 Do FSP initialization.\r
137\r
138 @return FSP initialization status.\r
139**/\r
140EFI_STATUS\r
141EFIAPI\r
142FspmWrapperInit (\r
143 VOID\r
144 )\r
145{\r
146 EFI_STATUS Status;\r
147\r
148 Status = PeiFspMemoryInit ();\r
149 ASSERT_EFI_ERROR (Status);\r
150\r
151 return Status;\r
152}\r
153\r
154/**\r
155 This is the entrypoint of PEIM\r
156\r
157 @param[in] FileHandle Handle of the file being invoked.\r
158 @param[in] PeiServices Describes the list of possible PEI Services.\r
159\r
160 @retval EFI_SUCCESS if it completed successfully.\r
161**/\r
162EFI_STATUS\r
163EFIAPI\r
164FspmWrapperPeimEntryPoint (\r
165 IN EFI_PEI_FILE_HANDLE FileHandle,\r
166 IN CONST EFI_PEI_SERVICES **PeiServices\r
167 )\r
168{\r
169 DEBUG((DEBUG_INFO, "FspmWrapperPeimEntryPoint\n"));\r
170\r
171 FspmWrapperInit ();\r
172\r
173 return EFI_SUCCESS;\r
174}\r