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