]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - IntelFspWrapperPkg/FspInitPei/FspInitPei.c
Update IntelFspPkg according to FSP1.1.
[mirror_edk2.git] / IntelFspWrapperPkg / FspInitPei / FspInitPei.c
... / ...
CommitLineData
1/** @file\r
2 This PEIM will be invoked twice by pei core. In 1st entry, it will call FspInit API.\r
3 In 2nd entry, it will parse the hoblist from fsp and report them into pei core.\r
4 This file contains the main entrypoint of the PEIM.\r
5\r
6 Copyright (c) 2014, 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 "FspInitPei.h"\r
19\r
20/**\r
21 FSP Init continuation function.\r
22 Control will be returned to this callback function after FspInit API call.\r
23\r
24 @param[in] Status Status of the FSP INIT API\r
25 @param[in] HobListPtr Pointer to the HOB data structure defined in the PI specification.\r
26\r
27**/\r
28VOID\r
29ContinuationFunc (\r
30 IN FSP_STATUS Status,\r
31 IN VOID *HobListPtr\r
32 )\r
33{\r
34 EFI_BOOT_MODE BootMode;\r
35 UINT64 StackSize;\r
36 EFI_PHYSICAL_ADDRESS StackBase;\r
37\r
38 DEBUG ((DEBUG_INFO, "ContinuationFunc - %r\n", Status));\r
39 DEBUG ((DEBUG_INFO, "HobListPtr - 0x%x\n", HobListPtr));\r
40\r
41 if (Status != FSP_SUCCESS) {\r
42 CpuDeadLoop ();\r
43 }\r
44\r
45 //\r
46 // Can not call any PeiServices\r
47 //\r
48 BootMode = GetBootMode ();\r
49\r
50 GetStackInfo (BootMode, TRUE, &StackBase, &StackSize);\r
51 DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));\r
52 DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));\r
53 CallPeiCoreEntryPoint (\r
54 HobListPtr,\r
55 (VOID *)(UINTN)StackBase,\r
56 (VOID *)(UINTN)(StackBase + StackSize)\r
57 );\r
58}\r
59\r
60/**\r
61 Call FspInit API.\r
62\r
63 @param[in] FspHeader FSP header pointer.\r
64**/\r
65VOID\r
66SecFspInit (\r
67 IN FSP_INFO_HEADER *FspHeader\r
68 )\r
69{\r
70 FSP_INIT_PARAMS FspInitParams;\r
71 FSP_INIT_RT_COMMON_BUFFER FspRtBuffer;\r
72 UINT8 FspUpdRgn[FixedPcdGet32 (PcdMaxUpdRegionSize)];\r
73 UINT32 UpdRegionSize;\r
74 EFI_BOOT_MODE BootMode;\r
75 UINT64 StackSize;\r
76 EFI_PHYSICAL_ADDRESS StackBase;\r
77 FSP_STATUS FspStatus;\r
78\r
79 DEBUG ((DEBUG_INFO, "SecFspInit enter\n"));\r
80\r
81 PeiServicesGetBootMode (&BootMode);\r
82 DEBUG ((DEBUG_INFO, "BootMode - 0x%x\n", BootMode));\r
83\r
84 GetStackInfo (BootMode, FALSE, &StackBase, &StackSize);\r
85 DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));\r
86 DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));\r
87\r
88 ZeroMem (&FspRtBuffer, sizeof(FspRtBuffer));\r
89 FspRtBuffer.StackTop = (UINT32 *)(UINTN)(StackBase + StackSize);\r
90\r
91 FspRtBuffer.BootMode = BootMode;\r
92\r
93 /* Platform override any UPD configs */\r
94 UpdRegionSize = GetUpdRegionSize();\r
95 DEBUG ((DEBUG_INFO, "UpdRegionSize - 0x%x\n", UpdRegionSize));\r
96 DEBUG ((DEBUG_INFO, "sizeof(FspUpdRgn) - 0x%x\n", sizeof(FspUpdRgn)));\r
97 ASSERT(sizeof(FspUpdRgn) >= UpdRegionSize);\r
98 ZeroMem (FspUpdRgn, UpdRegionSize);\r
99 FspRtBuffer.UpdDataRgnPtr = UpdateFspUpdConfigs (FspUpdRgn);\r
100\r
101 ZeroMem (&FspInitParams, sizeof(FspInitParams));\r
102 FspInitParams.NvsBufferPtr = GetNvsBuffer ();\r
103 DEBUG ((DEBUG_INFO, "NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));\r
104 FspInitParams.RtBufferPtr = (VOID *)&FspRtBuffer;\r
105 FspInitParams.ContinuationFunc = (CONTINUATION_PROC)ContinuationFunc;\r
106\r
107 SaveSecContext (GetPeiServicesTablePointer ());\r
108\r
109 DEBUG ((DEBUG_INFO, "FspInitParams - 0x%x\n", &FspInitParams));\r
110 DEBUG ((DEBUG_INFO, " NvsBufferPtr - 0x%x\n", FspInitParams.NvsBufferPtr));\r
111 DEBUG ((DEBUG_INFO, " RtBufferPtr - 0x%x\n", FspInitParams.RtBufferPtr));\r
112 DEBUG ((DEBUG_INFO, " StackTop - 0x%x\n", FspRtBuffer.StackTop));\r
113 DEBUG ((DEBUG_INFO, " BootMode - 0x%x\n", FspRtBuffer.BootMode));\r
114 DEBUG ((DEBUG_INFO, " UpdDataRgnPtr - 0x%x\n", FspRtBuffer.UpdDataRgnPtr));\r
115 DEBUG ((DEBUG_INFO, " ContinuationFunc - 0x%x\n", FspInitParams.ContinuationFunc));\r
116\r
117 FspStatus = CallFspInit (FspHeader, &FspInitParams);\r
118 //\r
119 // Should never return\r
120 //\r
121 DEBUG((DEBUG_ERROR, "FSP Init failed, status: 0x%x\n", FspStatus));\r
122 CpuDeadLoop ();\r
123}\r
124\r
125/**\r
126 This is the entrypoint of PEIM\r
127\r
128 @param[in] FileHandle Handle of the file being invoked.\r
129 @param[in] PeiServices Describes the list of possible PEI Services.\r
130\r
131 @retval EFI_SUCCESS if it completed successfully.\r
132**/\r
133EFI_STATUS\r
134EFIAPI\r
135FspPeiEntryPoint (\r
136 IN EFI_PEI_FILE_HANDLE FileHandle,\r
137 IN CONST EFI_PEI_SERVICES **PeiServices\r
138 )\r
139{\r
140 FSP_INFO_HEADER *FspHeader;\r
141 EFI_STATUS Status;\r
142 FSP_INIT_DONE_PPI *FspInitDone;\r
143 VOID *FspHobList;\r
144 EFI_BOOT_MODE BootMode;\r
145\r
146 DEBUG ((DEBUG_INFO, "FspPeiEntryPoint\n"));\r
147\r
148 Status = PeiServicesLocatePpi (\r
149 &gFspInitDonePpiGuid,\r
150 0,\r
151 NULL,\r
152 (VOID **) &FspInitDone\r
153 );\r
154 if (EFI_ERROR (Status)) {\r
155 //\r
156 // 1st entry\r
157 //\r
158 DEBUG ((DEBUG_INFO, "1st entry\n"));\r
159 FspHeader = FspFindFspHeader (PcdGet32 (PcdFlashFvFspBase));\r
160 DEBUG ((DEBUG_INFO, "FspHeader - 0x%x\n", FspHeader));\r
161 if (FspHeader == NULL) {\r
162 return EFI_DEVICE_ERROR;\r
163 }\r
164\r
165 SecFspInit (FspHeader);\r
166\r
167 //\r
168 // Never return here\r
169 //\r
170 CpuDeadLoop ();\r
171 } else {\r
172 //\r
173 // 2nd entry\r
174 //\r
175 DEBUG ((DEBUG_INFO, "2nd entry\n"));\r
176 Status = FspInitDone->GetFspHobList (PeiServices, FspInitDone, &FspHobList);\r
177 DEBUG ((DEBUG_INFO, "FspHobList - 0x%x\n", FspHobList));\r
178 FspHobProcess (FspHobList);\r
179\r
180 PeiServicesGetBootMode (&BootMode);\r
181 if (BootMode == BOOT_ON_S3_RESUME) {\r
182 Status = PeiServicesNotifyPpi (&mS3EndOfPeiNotifyDesc);\r
183 ASSERT_EFI_ERROR (Status);\r
184 }\r
185 }\r
186\r
187 return EFI_SUCCESS;\r
188}\r