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