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