]>
Commit | Line | Data |
---|---|---|
615c6dd0 | 1 | /** @file\r |
b1f6a7c6 | 2 | EFI PEI Core PPI services\r |
3 | \r | |
188e4e84 | 4 | Copyright (c) 2006 - 2010, Intel Corporation\r |
58dcdada | 5 | All rights reserved. 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 | |
192f6d4c | 12 | \r |
b1f6a7c6 | 13 | **/\r |
192f6d4c | 14 | \r |
0d516397 | 15 | #include "PeiMain.h"\r |
192f6d4c | 16 | \r |
b1f6a7c6 | 17 | /**\r |
192f6d4c | 18 | \r |
b1f6a7c6 | 19 | Initialize PPI services.\r |
192f6d4c | 20 | \r |
b1f6a7c6 | 21 | @param PrivateData Pointer to the PEI Core data.\r |
22 | @param OldCoreData Pointer to old PEI Core data. \r | |
23 | NULL if being run in non-permament memory mode.\r | |
192f6d4c | 24 | \r |
b1f6a7c6 | 25 | **/\r |
192f6d4c | 26 | VOID\r |
27 | InitializePpiServices (\r | |
b0d803fe | 28 | IN PEI_CORE_INSTANCE *PrivateData,\r |
192f6d4c | 29 | IN PEI_CORE_INSTANCE *OldCoreData\r |
30 | )\r | |
192f6d4c | 31 | {\r |
192f6d4c | 32 | if (OldCoreData == NULL) {\r |
188e4e84 | 33 | PrivateData->PpiData.NotifyListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r |
34 | PrivateData->PpiData.DispatchListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r | |
35 | PrivateData->PpiData.LastDispatchedNotify = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;\r | |
192f6d4c | 36 | }\r |
192f6d4c | 37 | }\r |
38 | \r | |
b1f6a7c6 | 39 | /**\r |
40 | \r | |
3d4d0c34 | 41 | Migrate the Hob list from the temporary memory stack to PEI installed memory.\r |
b1f6a7c6 | 42 | \r |
0f65cdaa | 43 | @param PrivateData Pointer to PeiCore's private data structure.\r |
731bd38e | 44 | @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range\r |
45 | will be fixup for PpiData and PpiDescriptor pointer.\r | |
46 | @param OldCheckingTop Top of temporary memory range. All Ppi in this range\r | |
47 | will be fixup for PpiData and PpiDescriptor.\r | |
5c5a0601 | 48 | @param Fixup The address difference between\r |
49 | the new Hob list and old Hob list.\r | |
b1f6a7c6 | 50 | \r |
51 | **/\r | |
192f6d4c | 52 | VOID\r |
53 | ConvertPpiPointers (\r | |
40f26b8f | 54 | IN PEI_CORE_INSTANCE *PrivateData,\r |
55 | IN UINTN OldCheckingBottom,\r | |
56 | IN UINTN OldCheckingTop,\r | |
57 | IN INTN Fixup\r | |
192f6d4c | 58 | )\r |
192f6d4c | 59 | {\r |
192f6d4c | 60 | UINT8 Index;\r |
61 | PEI_PPI_LIST_POINTERS *PpiPointer;\r | |
192f6d4c | 62 | \r |
188e4e84 | 63 | for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {\r |
192f6d4c | 64 | if (Index < PrivateData->PpiData.PpiListEnd ||\r |
65 | Index > PrivateData->PpiData.NotifyListEnd) {\r | |
66 | PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index];\r | |
58dcdada | 67 | \r |
68 | if (((UINTN)PpiPointer->Raw < OldCheckingTop) &&\r | |
69 | ((UINTN)PpiPointer->Raw >= OldCheckingBottom)) {\r | |
192f6d4c | 70 | //\r |
71 | // Convert the pointer to the PEIM descriptor from the old HOB heap\r | |
72 | // to the relocated HOB heap.\r | |
73 | //\r | |
74 | PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Fixup);\r | |
75 | \r | |
76 | //\r | |
77 | // Only when the PEIM descriptor is in the old HOB should it be necessary\r | |
78 | // to try to convert the pointers in the PEIM descriptor\r | |
79 | //\r | |
58dcdada | 80 | \r |
81 | if (((UINTN)PpiPointer->Ppi->Guid < OldCheckingTop) &&\r | |
82 | ((UINTN)PpiPointer->Ppi->Guid >= OldCheckingBottom)) {\r | |
192f6d4c | 83 | //\r |
84 | // Convert the pointer to the GUID in the PPI or NOTIFY descriptor\r | |
85 | // from the old HOB heap to the relocated HOB heap.\r | |
86 | //\r | |
87 | PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Fixup);\r | |
88 | }\r | |
89 | \r | |
90 | //\r | |
91 | // Assume that no code is located in the temporary memory, so the pointer to\r | |
92 | // the notification function in the NOTIFY descriptor needs not be converted.\r | |
93 | //\r | |
94 | if (Index < PrivateData->PpiData.PpiListEnd &&\r | |
58dcdada | 95 | (UINTN)PpiPointer->Ppi->Ppi < OldCheckingTop &&\r |
96 | (UINTN)PpiPointer->Ppi->Ppi >= OldCheckingBottom) {\r | |
192f6d4c | 97 | //\r |
98 | // Convert the pointer to the PPI interface structure in the PPI descriptor\r | |
99 | // from the old HOB heap to the relocated HOB heap.\r | |
100 | //\r | |
58dcdada | 101 | PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi+ Fixup);\r |
192f6d4c | 102 | }\r |
103 | }\r | |
104 | }\r | |
105 | }\r | |
106 | }\r | |
107 | \r | |
b1f6a7c6 | 108 | /**\r |
192f6d4c | 109 | \r |
0f65cdaa | 110 | This function installs an interface in the PEI PPI database by GUID. \r |
111 | The purpose of the service is to publish an interface that other parties\r | |
112 | can use to call additional PEIMs.\r | |
192f6d4c | 113 | \r |
0f65cdaa | 114 | @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r |
115 | @param PpiList Pointer to a list of PEI PPI Descriptors.\r | |
b1f6a7c6 | 116 | \r |
0f65cdaa | 117 | @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.\r |
118 | @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer\r | |
731bd38e | 119 | if any PPI in PpiList is not valid\r |
0f65cdaa | 120 | @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI\r |
b1f6a7c6 | 121 | \r |
122 | **/\r | |
192f6d4c | 123 | EFI_STATUS\r |
124 | EFIAPI\r | |
125 | PeiInstallPpi (\r | |
0c2b5da8 | 126 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
127 | IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList\r | |
192f6d4c | 128 | )\r |
192f6d4c | 129 | {\r |
130 | PEI_CORE_INSTANCE *PrivateData;\r | |
131 | INTN Index;\r | |
132 | INTN LastCallbackInstall;\r | |
133 | \r | |
134 | \r | |
135 | if (PpiList == NULL) {\r | |
136 | return EFI_INVALID_PARAMETER;\r | |
137 | }\r | |
138 | \r | |
139 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r | |
140 | \r | |
141 | Index = PrivateData->PpiData.PpiListEnd;\r | |
142 | LastCallbackInstall = Index;\r | |
143 | \r | |
144 | //\r | |
145 | // This is loop installs all PPI descriptors in the PpiList. It is terminated\r | |
146 | // by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last\r | |
147 | // EFI_PEI_PPI_DESCRIPTOR in the list.\r | |
148 | //\r | |
58dcdada | 149 | \r |
192f6d4c | 150 | for (;;) {\r |
151 | //\r | |
731bd38e | 152 | // Since PpiData is used for NotifyList and PpiList, max resource\r |
192f6d4c | 153 | // is reached if the Install reaches the NotifyList\r |
97b2c9b5 | 154 | // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement.\r |
192f6d4c | 155 | //\r |
156 | if (Index == PrivateData->PpiData.NotifyListEnd + 1) {\r | |
157 | return EFI_OUT_OF_RESOURCES;\r | |
158 | }\r | |
159 | //\r | |
58dcdada | 160 | // Check if it is a valid PPI.\r |
192f6d4c | 161 | // If not, rollback list to exclude all in this list.\r |
162 | // Try to indicate which item failed.\r | |
163 | //\r | |
164 | if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {\r | |
165 | PrivateData->PpiData.PpiListEnd = LastCallbackInstall;\r | |
0e549d5b | 166 | DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));\r |
192f6d4c | 167 | return EFI_INVALID_PARAMETER;\r |
168 | }\r | |
169 | \r | |
58dcdada | 170 | DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));\r |
171 | PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;\r | |
192f6d4c | 172 | PrivateData->PpiData.PpiListEnd++;\r |
58dcdada | 173 | \r |
192f6d4c | 174 | //\r |
175 | // Continue until the end of the PPI List.\r | |
176 | //\r | |
58dcdada | 177 | if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r |
192f6d4c | 178 | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r |
179 | break;\r | |
180 | }\r | |
181 | PpiList++;\r | |
182 | Index++;\r | |
183 | }\r | |
184 | \r | |
185 | //\r | |
186 | // Dispatch any callback level notifies for newly installed PPIs.\r | |
187 | //\r | |
188 | DispatchNotify (\r | |
b0d803fe | 189 | PrivateData,\r |
192f6d4c | 190 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r |
191 | LastCallbackInstall,\r | |
192 | PrivateData->PpiData.PpiListEnd,\r | |
58dcdada | 193 | PrivateData->PpiData.DispatchListEnd,\r |
192f6d4c | 194 | PrivateData->PpiData.NotifyListEnd\r |
195 | );\r | |
196 | \r | |
197 | \r | |
198 | return EFI_SUCCESS;\r | |
199 | }\r | |
200 | \r | |
b1f6a7c6 | 201 | /**\r |
202 | \r | |
0f65cdaa | 203 | This function reinstalls an interface in the PEI PPI database by GUID. \r |
204 | The purpose of the service is to publish an interface that other parties can \r | |
205 | use to replace an interface of the same name in the protocol database with a \r | |
206 | different interface.\r | |
b1f6a7c6 | 207 | \r |
0f65cdaa | 208 | @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r |
209 | @param OldPpi Pointer to the old PEI PPI Descriptors.\r | |
210 | @param NewPpi Pointer to the new PEI PPI Descriptors.\r | |
192f6d4c | 211 | \r |
0f65cdaa | 212 | @retval EFI_SUCCESS if the operation was successful\r |
213 | @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL\r | |
214 | @retval EFI_INVALID_PARAMETER if NewPpi is not valid\r | |
215 | @retval EFI_NOT_FOUND if the PPI was not in the database\r | |
b1f6a7c6 | 216 | \r |
217 | **/\r | |
192f6d4c | 218 | EFI_STATUS\r |
219 | EFIAPI\r | |
220 | PeiReInstallPpi (\r | |
0c2b5da8 | 221 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
222 | IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,\r | |
223 | IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi\r | |
192f6d4c | 224 | )\r |
192f6d4c | 225 | {\r |
226 | PEI_CORE_INSTANCE *PrivateData;\r | |
227 | INTN Index;\r | |
228 | \r | |
229 | \r | |
230 | if ((OldPpi == NULL) || (NewPpi == NULL)) {\r | |
231 | return EFI_INVALID_PARAMETER;\r | |
232 | }\r | |
233 | \r | |
234 | if ((NewPpi->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {\r | |
235 | return EFI_INVALID_PARAMETER;\r | |
236 | }\r | |
237 | \r | |
238 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r | |
239 | \r | |
240 | //\r | |
241 | // Find the old PPI instance in the database. If we can not find it,\r | |
242 | // return the EFI_NOT_FOUND error.\r | |
243 | //\r | |
244 | for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {\r | |
245 | if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {\r | |
246 | break;\r | |
247 | }\r | |
248 | }\r | |
249 | if (Index == PrivateData->PpiData.PpiListEnd) {\r | |
250 | return EFI_NOT_FOUND;\r | |
251 | }\r | |
252 | \r | |
253 | //\r | |
254 | // Remove the old PPI from the database, add the new one.\r | |
58dcdada | 255 | //\r |
192f6d4c | 256 | DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));\r |
188e4e84 | 257 | ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));\r |
0c2b5da8 | 258 | PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;\r |
192f6d4c | 259 | \r |
260 | //\r | |
261 | // Dispatch any callback level notifies for the newly installed PPI.\r | |
262 | //\r | |
263 | DispatchNotify (\r | |
b0d803fe | 264 | PrivateData,\r |
192f6d4c | 265 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r |
266 | Index,\r | |
267 | Index+1,\r | |
58dcdada | 268 | PrivateData->PpiData.DispatchListEnd,\r |
192f6d4c | 269 | PrivateData->PpiData.NotifyListEnd\r |
270 | );\r | |
271 | \r | |
272 | \r | |
273 | return EFI_SUCCESS;\r | |
274 | }\r | |
275 | \r | |
b1f6a7c6 | 276 | /**\r |
277 | \r | |
278 | Locate a given named PPI.\r | |
279 | \r | |
192f6d4c | 280 | \r |
0f65cdaa | 281 | @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r |
282 | @param Guid Pointer to GUID of the PPI.\r | |
283 | @param Instance Instance Number to discover.\r | |
284 | @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,\r | |
285 | returns a pointer to the descriptor (includes flags, etc)\r | |
286 | @param Ppi Pointer to reference the found PPI\r | |
b1f6a7c6 | 287 | \r |
288 | @retval EFI_SUCCESS if the PPI is in the database\r | |
289 | @retval EFI_NOT_FOUND if the PPI is not in the database\r | |
290 | \r | |
291 | **/\r | |
192f6d4c | 292 | EFI_STATUS\r |
293 | EFIAPI\r | |
294 | PeiLocatePpi (\r | |
0c2b5da8 | 295 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
296 | IN CONST EFI_GUID *Guid,\r | |
0f65cdaa | 297 | IN UINTN Instance,\r |
298 | IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,\r | |
299 | IN OUT VOID **Ppi\r | |
192f6d4c | 300 | )\r |
192f6d4c | 301 | {\r |
302 | PEI_CORE_INSTANCE *PrivateData;\r | |
303 | INTN Index;\r | |
304 | EFI_GUID *CheckGuid;\r | |
305 | EFI_PEI_PPI_DESCRIPTOR *TempPtr;\r | |
306 | \r | |
58dcdada | 307 | \r |
192f6d4c | 308 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r |
309 | \r | |
310 | //\r | |
311 | // Search the data base for the matching instance of the GUIDed PPI.\r | |
312 | //\r | |
313 | for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {\r | |
314 | TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;\r | |
315 | CheckGuid = TempPtr->Guid;\r | |
316 | \r | |
317 | //\r | |
318 | // Don't use CompareGuid function here for performance reasons.\r | |
319 | // Instead we compare the GUID as INT32 at a time and branch\r | |
320 | // on the first failed comparison.\r | |
321 | //\r | |
322 | if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) &&\r | |
323 | (((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) &&\r | |
324 | (((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) &&\r | |
325 | (((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3])) {\r | |
326 | if (Instance == 0) {\r | |
327 | \r | |
328 | if (PpiDescriptor != NULL) {\r | |
329 | *PpiDescriptor = TempPtr;\r | |
330 | }\r | |
331 | \r | |
332 | if (Ppi != NULL) {\r | |
333 | *Ppi = TempPtr->Ppi;\r | |
334 | }\r | |
335 | \r | |
336 | \r | |
337 | return EFI_SUCCESS;\r | |
338 | }\r | |
339 | Instance--;\r | |
340 | }\r | |
341 | }\r | |
342 | \r | |
343 | return EFI_NOT_FOUND;\r | |
344 | }\r | |
345 | \r | |
b1f6a7c6 | 346 | /**\r |
192f6d4c | 347 | \r |
0f65cdaa | 348 | This function installs a notification service to be called back when a given \r |
349 | interface is installed or reinstalled. The purpose of the service is to publish \r | |
350 | an interface that other parties can use to call additional PPIs that may materialize later.\r | |
b1f6a7c6 | 351 | \r |
0f65cdaa | 352 | @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r |
353 | @param NotifyList Pointer to list of Descriptors to notify upon.\r | |
b1f6a7c6 | 354 | \r |
355 | @retval EFI_SUCCESS if successful\r | |
356 | @retval EFI_OUT_OF_RESOURCES if no space in the database\r | |
357 | @retval EFI_INVALID_PARAMETER if not a good decriptor\r | |
358 | \r | |
359 | **/\r | |
192f6d4c | 360 | EFI_STATUS\r |
361 | EFIAPI\r | |
362 | PeiNotifyPpi (\r | |
0c2b5da8 | 363 | IN CONST EFI_PEI_SERVICES **PeiServices,\r |
364 | IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList\r | |
192f6d4c | 365 | )\r |
192f6d4c | 366 | {\r |
367 | PEI_CORE_INSTANCE *PrivateData;\r | |
368 | INTN Index;\r | |
369 | INTN NotifyIndex;\r | |
370 | INTN LastCallbackNotify;\r | |
371 | EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;\r | |
372 | UINTN NotifyDispatchCount;\r | |
373 | \r | |
374 | \r | |
375 | NotifyDispatchCount = 0;\r | |
376 | \r | |
377 | if (NotifyList == NULL) {\r | |
378 | return EFI_INVALID_PARAMETER;\r | |
379 | }\r | |
380 | \r | |
381 | PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);\r | |
382 | \r | |
383 | Index = PrivateData->PpiData.NotifyListEnd;\r | |
384 | LastCallbackNotify = Index;\r | |
385 | \r | |
386 | //\r | |
387 | // This is loop installs all Notify descriptors in the NotifyList. It is\r | |
388 | // terminated by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last\r | |
389 | // EFI_PEI_NOTIFY_DESCRIPTOR in the list.\r | |
390 | //\r | |
391 | \r | |
392 | for (;;) {\r | |
393 | //\r | |
394 | // Since PpiData is used for NotifyList and InstallList, max resource\r | |
395 | // is reached if the Install reaches the PpiList\r | |
97b2c9b5 | 396 | // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement.\r |
192f6d4c | 397 | //\r |
398 | if (Index == PrivateData->PpiData.PpiListEnd - 1) {\r | |
399 | return EFI_OUT_OF_RESOURCES;\r | |
400 | }\r | |
58dcdada | 401 | \r |
192f6d4c | 402 | //\r |
403 | // If some of the PPI data is invalid restore original Notify PPI database value\r | |
404 | //\r | |
405 | if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {\r | |
406 | PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;\r | |
0e549d5b | 407 | DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList->Guid, NotifyList->Notify));\r |
192f6d4c | 408 | return EFI_INVALID_PARAMETER;\r |
409 | }\r | |
58dcdada | 410 | \r |
192f6d4c | 411 | if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {\r |
58dcdada | 412 | NotifyDispatchCount ++;\r |
413 | }\r | |
414 | \r | |
415 | PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;\r | |
416 | \r | |
192f6d4c | 417 | PrivateData->PpiData.NotifyListEnd--;\r |
418 | DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));\r | |
419 | if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r | |
420 | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r | |
421 | break;\r | |
422 | }\r | |
423 | //\r | |
424 | // Go the next descriptor. Remember the NotifyList moves down.\r | |
425 | //\r | |
426 | NotifyList++;\r | |
427 | Index--;\r | |
428 | }\r | |
58dcdada | 429 | \r |
192f6d4c | 430 | //\r |
58dcdada | 431 | // If there is Dispatch Notify PPI installed put them on the bottom\r |
192f6d4c | 432 | //\r |
433 | if (NotifyDispatchCount > 0) {\r | |
58dcdada | 434 | for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) {\r |
192f6d4c | 435 | if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {\r |
436 | NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;\r | |
58dcdada | 437 | \r |
192f6d4c | 438 | for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){\r |
439 | PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify;\r | |
440 | }\r | |
441 | PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;\r | |
58dcdada | 442 | PrivateData->PpiData.DispatchListEnd--;\r |
192f6d4c | 443 | }\r |
444 | }\r | |
58dcdada | 445 | \r |
446 | LastCallbackNotify -= NotifyDispatchCount;\r | |
192f6d4c | 447 | }\r |
58dcdada | 448 | \r |
192f6d4c | 449 | //\r |
450 | // Dispatch any callback level notifies for all previously installed PPIs.\r | |
451 | //\r | |
452 | DispatchNotify (\r | |
b0d803fe | 453 | PrivateData,\r |
192f6d4c | 454 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,\r |
455 | 0,\r | |
456 | PrivateData->PpiData.PpiListEnd,\r | |
457 | LastCallbackNotify,\r | |
458 | PrivateData->PpiData.NotifyListEnd\r | |
459 | );\r | |
58dcdada | 460 | \r |
192f6d4c | 461 | return EFI_SUCCESS;\r |
462 | }\r | |
463 | \r | |
464 | \r | |
b1f6a7c6 | 465 | /**\r |
192f6d4c | 466 | \r |
467 | Process the Notify List at dispatch level.\r | |
468 | \r | |
b1f6a7c6 | 469 | @param PrivateData PeiCore's private data structure.\r |
192f6d4c | 470 | \r |
b1f6a7c6 | 471 | **/\r |
472 | VOID\r | |
473 | ProcessNotifyList (\r | |
474 | IN PEI_CORE_INSTANCE *PrivateData\r | |
475 | )\r | |
192f6d4c | 476 | {\r |
192f6d4c | 477 | INTN TempValue;\r |
58dcdada | 478 | \r |
192f6d4c | 479 | while (TRUE) {\r |
480 | //\r | |
481 | // Check if the PEIM that was just dispatched resulted in any\r | |
482 | // Notifies getting installed. If so, go process any dispatch\r | |
483 | // level Notifies that match the previouly installed PPIs.\r | |
58dcdada | 484 | // Use "while" instead of "if" since DispatchNotify can modify\r |
192f6d4c | 485 | // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.\r |
486 | //\r | |
487 | while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) {\r | |
488 | TempValue = PrivateData->PpiData.DispatchListEnd;\r | |
489 | DispatchNotify (\r | |
b0d803fe | 490 | PrivateData,\r |
192f6d4c | 491 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,\r |
492 | 0,\r | |
493 | PrivateData->PpiData.LastDispatchedInstall,\r | |
494 | PrivateData->PpiData.LastDispatchedNotify,\r | |
495 | PrivateData->PpiData.DispatchListEnd\r | |
496 | );\r | |
497 | PrivateData->PpiData.LastDispatchedNotify = TempValue;\r | |
498 | }\r | |
58dcdada | 499 | \r |
500 | \r | |
192f6d4c | 501 | //\r |
502 | // Check if the PEIM that was just dispatched resulted in any\r | |
503 | // PPIs getting installed. If so, go process any dispatch\r | |
504 | // level Notifies that match the installed PPIs.\r | |
58dcdada | 505 | // Use "while" instead of "if" since DispatchNotify can modify\r |
192f6d4c | 506 | // PpiListEnd (with InstallPpi) so we have to iterate until the same.\r |
507 | //\r | |
508 | while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) {\r | |
509 | TempValue = PrivateData->PpiData.PpiListEnd;\r | |
510 | DispatchNotify (\r | |
b0d803fe | 511 | PrivateData,\r |
192f6d4c | 512 | EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,\r |
513 | PrivateData->PpiData.LastDispatchedInstall,\r | |
514 | PrivateData->PpiData.PpiListEnd,\r | |
188e4e84 | 515 | PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,\r |
192f6d4c | 516 | PrivateData->PpiData.DispatchListEnd\r |
517 | );\r | |
518 | PrivateData->PpiData.LastDispatchedInstall = TempValue;\r | |
519 | }\r | |
58dcdada | 520 | \r |
192f6d4c | 521 | if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) {\r |
522 | break;\r | |
523 | }\r | |
58dcdada | 524 | }\r |
192f6d4c | 525 | return;\r |
526 | }\r | |
527 | \r | |
b1f6a7c6 | 528 | /**\r |
529 | \r | |
530 | Dispatch notifications.\r | |
531 | \r | |
532 | @param PrivateData PeiCore's private data structure\r | |
533 | @param NotifyType Type of notify to fire.\r | |
534 | @param InstallStartIndex Install Beginning index.\r | |
535 | @param InstallStopIndex Install Ending index.\r | |
536 | @param NotifyStartIndex Notify Beginning index.\r | |
537 | @param NotifyStopIndex Notify Ending index.\r | |
538 | \r | |
539 | **/\r | |
192f6d4c | 540 | VOID\r |
541 | DispatchNotify (\r | |
b0d803fe | 542 | IN PEI_CORE_INSTANCE *PrivateData,\r |
192f6d4c | 543 | IN UINTN NotifyType,\r |
544 | IN INTN InstallStartIndex,\r | |
545 | IN INTN InstallStopIndex,\r | |
546 | IN INTN NotifyStartIndex,\r | |
547 | IN INTN NotifyStopIndex\r | |
548 | )\r | |
192f6d4c | 549 | {\r |
192f6d4c | 550 | INTN Index1;\r |
551 | INTN Index2;\r | |
552 | EFI_GUID *SearchGuid;\r | |
553 | EFI_GUID *CheckGuid;\r | |
554 | EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;\r | |
555 | \r | |
192f6d4c | 556 | //\r |
557 | // Remember that Installs moves up and Notifies moves down.\r | |
558 | //\r | |
559 | for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {\r | |
560 | NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;\r | |
561 | \r | |
562 | CheckGuid = NotifyDescriptor->Guid;\r | |
563 | \r | |
564 | for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {\r | |
565 | SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;\r | |
566 | //\r | |
567 | // Don't use CompareGuid function here for performance reasons.\r | |
568 | // Instead we compare the GUID as INT32 at a time and branch\r | |
569 | // on the first failed comparison.\r | |
570 | //\r | |
571 | if ((((INT32 *)SearchGuid)[0] == ((INT32 *)CheckGuid)[0]) &&\r | |
572 | (((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) &&\r | |
573 | (((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) &&\r | |
574 | (((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) {\r | |
0e549d5b | 575 | DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %p\n",\r |
58dcdada | 576 | SearchGuid,\r |
192f6d4c | 577 | NotifyDescriptor->Notify\r |
578 | ));\r | |
579 | NotifyDescriptor->Notify (\r | |
284c8400 | 580 | (EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),\r |
192f6d4c | 581 | NotifyDescriptor,\r |
582 | (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi\r | |
583 | );\r | |
584 | }\r | |
585 | }\r | |
586 | }\r | |
192f6d4c | 587 | }\r |
588 | \r |