2 EFI PEI Core PPI services
4 Copyright (c) 2006 - 2018, 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
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.
19 Migrate Pointer from the temporary memory to PEI installed memory.
21 @param Pointer Pointer to the Pointer needs to be converted.
22 @param TempBottom Base of old temporary memory
23 @param TempTop Top of old temporary memory
24 @param Offset Offset of new memory to old temporary memory.
25 @param OffsetPositive Positive flag of Offset value.
30 IN OUT VOID
**Pointer
,
34 IN BOOLEAN OffsetPositive
37 if (((UINTN
) *Pointer
< TempTop
) &&
38 ((UINTN
) *Pointer
>= TempBottom
)) {
40 *Pointer
= (VOID
*) ((UINTN
) *Pointer
+ Offset
);
42 *Pointer
= (VOID
*) ((UINTN
) *Pointer
- Offset
);
49 Migrate Pointer in ranges of the temporary memory to PEI installed memory.
51 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
52 and location of temporary RAM, the stack location and the BFV location.
53 @param PrivateData Pointer to PeiCore's private data structure.
54 @param Pointer Pointer to the Pointer needs to be converted.
58 ConvertPointerInRanges (
59 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
60 IN PEI_CORE_INSTANCE
*PrivateData
,
66 if (PrivateData
->MemoryPages
.Size
!= 0) {
68 // Convert PPI pointer in old memory pages
69 // It needs to be done before Convert PPI pointer in old Heap
73 (UINTN
)PrivateData
->MemoryPages
.Base
,
74 (UINTN
)PrivateData
->MemoryPages
.Base
+ PrivateData
->MemoryPages
.Size
,
75 PrivateData
->MemoryPages
.Offset
,
76 PrivateData
->MemoryPages
.OffsetPositive
81 // Convert PPI pointer in old Heap
85 (UINTN
)SecCoreData
->PeiTemporaryRamBase
,
86 (UINTN
)SecCoreData
->PeiTemporaryRamBase
+ SecCoreData
->PeiTemporaryRamSize
,
87 PrivateData
->HeapOffset
,
88 PrivateData
->HeapOffsetPositive
92 // Convert PPI pointer in old Stack
96 (UINTN
)SecCoreData
->StackBase
,
97 (UINTN
)SecCoreData
->StackBase
+ SecCoreData
->StackSize
,
98 PrivateData
->StackOffset
,
99 PrivateData
->StackOffsetPositive
103 // Convert PPI pointer in old TempRam Hole
105 for (IndexHole
= 0; IndexHole
< HOLE_MAX_NUMBER
; IndexHole
++) {
106 if (PrivateData
->HoleData
[IndexHole
].Size
== 0) {
112 (UINTN
)PrivateData
->HoleData
[IndexHole
].Base
,
113 (UINTN
)PrivateData
->HoleData
[IndexHole
].Base
+ PrivateData
->HoleData
[IndexHole
].Size
,
114 PrivateData
->HoleData
[IndexHole
].Offset
,
115 PrivateData
->HoleData
[IndexHole
].OffsetPositive
122 Migrate Single PPI Pointer from the temporary memory to PEI installed memory.
124 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
125 and location of temporary RAM, the stack location and the BFV location.
126 @param PrivateData Pointer to PeiCore's private data structure.
127 @param PpiPointer Pointer to Ppi
131 ConvertSinglePpiPointer (
132 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
133 IN PEI_CORE_INSTANCE
*PrivateData
,
134 IN PEI_PPI_LIST_POINTERS
*PpiPointer
138 // 1. Convert the pointer to the PPI descriptor from the old TempRam
139 // to the relocated physical memory.
140 // It (for the pointer to the PPI descriptor) needs to be done before 2 (for
141 // the pointer to the GUID) and 3 (for the pointer to the PPI interface structure).
143 ConvertPointerInRanges (SecCoreData
, PrivateData
, &PpiPointer
->Raw
);
145 // 2. Convert the pointer to the GUID in the PPI or NOTIFY descriptor
146 // from the old TempRam to the relocated physical memory.
148 ConvertPointerInRanges (SecCoreData
, PrivateData
, (VOID
**) &PpiPointer
->Ppi
->Guid
);
150 // 3. Convert the pointer to the PPI interface structure in the PPI descriptor
151 // from the old TempRam to the relocated physical memory.
153 ConvertPointerInRanges (SecCoreData
, PrivateData
, (VOID
**) &PpiPointer
->Ppi
->Ppi
);
158 Migrate PPI Pointers from the temporary memory to PEI installed memory.
160 @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
161 and location of temporary RAM, the stack location and the BFV location.
162 @param PrivateData Pointer to PeiCore's private data structure.
167 IN CONST EFI_SEC_PEI_HAND_OFF
*SecCoreData
,
168 IN PEI_CORE_INSTANCE
*PrivateData
174 // Convert normal PPIs.
176 for (Index
= 0; Index
< PrivateData
->PpiData
.PpiList
.CurrentCount
; Index
++) {
177 ConvertSinglePpiPointer (
180 &PrivateData
->PpiData
.PpiList
.PpiPtrs
[Index
]
185 // Convert Callback Notification PPIs.
187 for (Index
= 0; Index
< PrivateData
->PpiData
.CallbackNotifyList
.CurrentCount
; Index
++) {
188 ConvertSinglePpiPointer (
191 &PrivateData
->PpiData
.CallbackNotifyList
.NotifyPtrs
[Index
]
196 // Convert Dispatch Notification PPIs.
198 for (Index
= 0; Index
< PrivateData
->PpiData
.DispatchNotifyList
.CurrentCount
; Index
++) {
199 ConvertSinglePpiPointer (
202 &PrivateData
->PpiData
.DispatchNotifyList
.NotifyPtrs
[Index
]
209 This function installs an interface in the PEI PPI database by GUID.
210 The purpose of the service is to publish an interface that other parties
211 can use to call additional PEIMs.
213 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
214 @param PpiList Pointer to a list of PEI PPI Descriptors.
215 @param Single TRUE if only single entry in the PpiList.
216 FALSE if the PpiList is ended with an entry which has the
217 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field.
219 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.
220 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer
221 if any PPI in PpiList is not valid
222 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI
226 InternalPeiInstallPpi (
227 IN CONST EFI_PEI_SERVICES
**PeiServices
,
228 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
,
232 PEI_CORE_INSTANCE
*PrivateData
;
233 PEI_PPI_LIST
*PpiListPointer
;
238 if (PpiList
== NULL
) {
239 return EFI_INVALID_PARAMETER
;
242 PrivateData
= PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices
);
244 PpiListPointer
= &PrivateData
->PpiData
.PpiList
;
245 Index
= PpiListPointer
->CurrentCount
;
249 // This is loop installs all PPI descriptors in the PpiList. It is terminated
250 // by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last
251 // EFI_PEI_PPI_DESCRIPTOR in the list.
256 // Check if it is a valid PPI.
257 // If not, rollback list to exclude all in this list.
258 // Try to indicate which item failed.
260 if ((PpiList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_PPI
) == 0) {
261 PpiListPointer
->CurrentCount
= LastCount
;
262 DEBUG((EFI_D_ERROR
, "ERROR -> InstallPpi: %g %p\n", PpiList
->Guid
, PpiList
->Ppi
));
263 return EFI_INVALID_PARAMETER
;
266 if (Index
>= PpiListPointer
->MaxCount
) {
268 // Run out of room, grow the buffer.
270 TempPtr
= AllocateZeroPool (
271 sizeof (PEI_PPI_LIST_POINTERS
) * (PpiListPointer
->MaxCount
+ PPI_GROWTH_STEP
)
273 ASSERT (TempPtr
!= NULL
);
276 PpiListPointer
->PpiPtrs
,
277 sizeof (PEI_PPI_LIST_POINTERS
) * PpiListPointer
->MaxCount
279 PpiListPointer
->PpiPtrs
= TempPtr
;
280 PpiListPointer
->MaxCount
= PpiListPointer
->MaxCount
+ PPI_GROWTH_STEP
;
283 DEBUG((EFI_D_INFO
, "Install PPI: %g\n", PpiList
->Guid
));
284 PpiListPointer
->PpiPtrs
[Index
].Ppi
= (EFI_PEI_PPI_DESCRIPTOR
*) PpiList
;
286 PpiListPointer
->CurrentCount
++;
290 // Only single entry in the PpiList.
293 } else if ((PpiList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) ==
294 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) {
296 // Continue until the end of the PPI List.
301 // Go to the next descriptor.
307 // Process any callback level notifies for newly installed PPIs.
311 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
,
313 PpiListPointer
->CurrentCount
,
315 PrivateData
->PpiData
.CallbackNotifyList
.CurrentCount
323 This function installs an interface in the PEI PPI database by GUID.
324 The purpose of the service is to publish an interface that other parties
325 can use to call additional PEIMs.
327 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
328 @param PpiList Pointer to a list of PEI PPI Descriptors.
330 @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.
331 @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer
332 if any PPI in PpiList is not valid
333 @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI
339 IN CONST EFI_PEI_SERVICES
**PeiServices
,
340 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
343 return InternalPeiInstallPpi (PeiServices
, PpiList
, FALSE
);
348 This function reinstalls an interface in the PEI PPI database by GUID.
349 The purpose of the service is to publish an interface that other parties can
350 use to replace an interface of the same name in the protocol database with a
353 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
354 @param OldPpi Pointer to the old PEI PPI Descriptors.
355 @param NewPpi Pointer to the new PEI PPI Descriptors.
357 @retval EFI_SUCCESS if the operation was successful
358 @retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL
359 @retval EFI_INVALID_PARAMETER if NewPpi is not valid
360 @retval EFI_NOT_FOUND if the PPI was not in the database
366 IN CONST EFI_PEI_SERVICES
**PeiServices
,
367 IN CONST EFI_PEI_PPI_DESCRIPTOR
*OldPpi
,
368 IN CONST EFI_PEI_PPI_DESCRIPTOR
*NewPpi
371 PEI_CORE_INSTANCE
*PrivateData
;
375 if ((OldPpi
== NULL
) || (NewPpi
== NULL
)) {
376 return EFI_INVALID_PARAMETER
;
379 if ((NewPpi
->Flags
& EFI_PEI_PPI_DESCRIPTOR_PPI
) == 0) {
380 return EFI_INVALID_PARAMETER
;
383 PrivateData
= PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices
);
386 // Find the old PPI instance in the database. If we can not find it,
387 // return the EFI_NOT_FOUND error.
389 for (Index
= 0; Index
< PrivateData
->PpiData
.PpiList
.CurrentCount
; Index
++) {
390 if (OldPpi
== PrivateData
->PpiData
.PpiList
.PpiPtrs
[Index
].Ppi
) {
394 if (Index
== PrivateData
->PpiData
.PpiList
.CurrentCount
) {
395 return EFI_NOT_FOUND
;
399 // Replace the old PPI with the new one.
401 DEBUG((EFI_D_INFO
, "Reinstall PPI: %g\n", NewPpi
->Guid
));
402 PrivateData
->PpiData
.PpiList
.PpiPtrs
[Index
].Ppi
= (EFI_PEI_PPI_DESCRIPTOR
*) NewPpi
;
405 // Process any callback level notifies for the newly installed PPI.
409 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
,
413 PrivateData
->PpiData
.CallbackNotifyList
.CurrentCount
421 Locate a given named PPI.
424 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
425 @param Guid Pointer to GUID of the PPI.
426 @param Instance Instance Number to discover.
427 @param PpiDescriptor Pointer to reference the found descriptor. If not NULL,
428 returns a pointer to the descriptor (includes flags, etc)
429 @param Ppi Pointer to reference the found PPI
431 @retval EFI_SUCCESS if the PPI is in the database
432 @retval EFI_NOT_FOUND if the PPI is not in the database
438 IN CONST EFI_PEI_SERVICES
**PeiServices
,
439 IN CONST EFI_GUID
*Guid
,
441 IN OUT EFI_PEI_PPI_DESCRIPTOR
**PpiDescriptor
,
445 PEI_CORE_INSTANCE
*PrivateData
;
448 EFI_PEI_PPI_DESCRIPTOR
*TempPtr
;
451 PrivateData
= PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices
);
454 // Search the data base for the matching instance of the GUIDed PPI.
456 for (Index
= 0; Index
< PrivateData
->PpiData
.PpiList
.CurrentCount
; Index
++) {
457 TempPtr
= PrivateData
->PpiData
.PpiList
.PpiPtrs
[Index
].Ppi
;
458 CheckGuid
= TempPtr
->Guid
;
461 // Don't use CompareGuid function here for performance reasons.
462 // Instead we compare the GUID as INT32 at a time and branch
463 // on the first failed comparison.
465 if ((((INT32
*)Guid
)[0] == ((INT32
*)CheckGuid
)[0]) &&
466 (((INT32
*)Guid
)[1] == ((INT32
*)CheckGuid
)[1]) &&
467 (((INT32
*)Guid
)[2] == ((INT32
*)CheckGuid
)[2]) &&
468 (((INT32
*)Guid
)[3] == ((INT32
*)CheckGuid
)[3])) {
471 if (PpiDescriptor
!= NULL
) {
472 *PpiDescriptor
= TempPtr
;
486 return EFI_NOT_FOUND
;
491 This function installs a notification service to be called back when a given
492 interface is installed or reinstalled. The purpose of the service is to publish
493 an interface that other parties can use to call additional PPIs that may materialize later.
495 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
496 @param NotifyList Pointer to list of Descriptors to notify upon.
497 @param Single TRUE if only single entry in the NotifyList.
498 FALSE if the NotifyList is ended with an entry which has the
499 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field.
501 @retval EFI_SUCCESS if successful
502 @retval EFI_OUT_OF_RESOURCES if no space in the database
503 @retval EFI_INVALID_PARAMETER if not a good descriptor
507 InternalPeiNotifyPpi (
508 IN CONST EFI_PEI_SERVICES
**PeiServices
,
509 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
,
513 PEI_CORE_INSTANCE
*PrivateData
;
514 PEI_CALLBACK_NOTIFY_LIST
*CallbackNotifyListPointer
;
515 UINTN CallbackNotifyIndex
;
516 UINTN LastCallbackNotifyCount
;
517 PEI_DISPATCH_NOTIFY_LIST
*DispatchNotifyListPointer
;
518 UINTN DispatchNotifyIndex
;
519 UINTN LastDispatchNotifyCount
;
522 if (NotifyList
== NULL
) {
523 return EFI_INVALID_PARAMETER
;
526 PrivateData
= PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices
);
528 CallbackNotifyListPointer
= &PrivateData
->PpiData
.CallbackNotifyList
;
529 CallbackNotifyIndex
= CallbackNotifyListPointer
->CurrentCount
;
530 LastCallbackNotifyCount
= CallbackNotifyIndex
;
532 DispatchNotifyListPointer
= &PrivateData
->PpiData
.DispatchNotifyList
;
533 DispatchNotifyIndex
= DispatchNotifyListPointer
->CurrentCount
;
534 LastDispatchNotifyCount
= DispatchNotifyIndex
;
537 // This is loop installs all Notify descriptors in the NotifyList. It is
538 // terminated by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last
539 // EFI_PEI_NOTIFY_DESCRIPTOR in the list.
544 // If some of the PPI data is invalid restore original Notify PPI database value
546 if ((NotifyList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
) == 0) {
547 CallbackNotifyListPointer
->CurrentCount
= LastCallbackNotifyCount
;
548 DispatchNotifyListPointer
->CurrentCount
= LastDispatchNotifyCount
;
549 DEBUG((DEBUG_ERROR
, "ERROR -> NotifyPpi: %g %p\n", NotifyList
->Guid
, NotifyList
->Notify
));
550 return EFI_INVALID_PARAMETER
;
553 if ((NotifyList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
) != 0) {
554 if (CallbackNotifyIndex
>= CallbackNotifyListPointer
->MaxCount
) {
556 // Run out of room, grow the buffer.
558 TempPtr
= AllocateZeroPool (
559 sizeof (PEI_PPI_LIST_POINTERS
) * (CallbackNotifyListPointer
->MaxCount
+ CALLBACK_NOTIFY_GROWTH_STEP
)
561 ASSERT (TempPtr
!= NULL
);
564 CallbackNotifyListPointer
->NotifyPtrs
,
565 sizeof (PEI_PPI_LIST_POINTERS
) * CallbackNotifyListPointer
->MaxCount
567 CallbackNotifyListPointer
->NotifyPtrs
= TempPtr
;
568 CallbackNotifyListPointer
->MaxCount
= CallbackNotifyListPointer
->MaxCount
+ CALLBACK_NOTIFY_GROWTH_STEP
;
570 CallbackNotifyListPointer
->NotifyPtrs
[CallbackNotifyIndex
].Notify
= (EFI_PEI_NOTIFY_DESCRIPTOR
*) NotifyList
;
571 CallbackNotifyIndex
++;
572 CallbackNotifyListPointer
->CurrentCount
++;
574 if (DispatchNotifyIndex
>= DispatchNotifyListPointer
->MaxCount
) {
576 // Run out of room, grow the buffer.
578 TempPtr
= AllocateZeroPool (
579 sizeof (PEI_PPI_LIST_POINTERS
) * (DispatchNotifyListPointer
->MaxCount
+ DISPATCH_NOTIFY_GROWTH_STEP
)
581 ASSERT (TempPtr
!= NULL
);
584 DispatchNotifyListPointer
->NotifyPtrs
,
585 sizeof (PEI_PPI_LIST_POINTERS
) * DispatchNotifyListPointer
->MaxCount
587 DispatchNotifyListPointer
->NotifyPtrs
= TempPtr
;
588 DispatchNotifyListPointer
->MaxCount
= DispatchNotifyListPointer
->MaxCount
+ DISPATCH_NOTIFY_GROWTH_STEP
;
590 DispatchNotifyListPointer
->NotifyPtrs
[DispatchNotifyIndex
].Notify
= (EFI_PEI_NOTIFY_DESCRIPTOR
*) NotifyList
;
591 DispatchNotifyIndex
++;
592 DispatchNotifyListPointer
->CurrentCount
++;
595 DEBUG((EFI_D_INFO
, "Register PPI Notify: %g\n", NotifyList
->Guid
));
599 // Only single entry in the NotifyList.
602 } else if ((NotifyList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) ==
603 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) {
605 // Continue until the end of the Notify List.
610 // Go to the next descriptor.
616 // Process any callback level notifies for all previously installed PPIs.
620 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
,
622 PrivateData
->PpiData
.PpiList
.CurrentCount
,
623 LastCallbackNotifyCount
,
624 CallbackNotifyListPointer
->CurrentCount
632 This function installs a notification service to be called back when a given
633 interface is installed or reinstalled. The purpose of the service is to publish
634 an interface that other parties can use to call additional PPIs that may materialize later.
636 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
637 @param NotifyList Pointer to list of Descriptors to notify upon.
639 @retval EFI_SUCCESS if successful
640 @retval EFI_OUT_OF_RESOURCES if no space in the database
641 @retval EFI_INVALID_PARAMETER if not a good descriptor
647 IN CONST EFI_PEI_SERVICES
**PeiServices
,
648 IN CONST EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyList
651 return InternalPeiNotifyPpi (PeiServices
, NotifyList
, FALSE
);
656 Process the Notify List at dispatch level.
658 @param PrivateData PeiCore's private data structure.
662 ProcessDispatchNotifyList (
663 IN PEI_CORE_INSTANCE
*PrivateData
670 // Check if the PEIM that was just dispatched resulted in any
671 // Notifies getting installed. If so, go process any dispatch
672 // level Notifies that match the previouly installed PPIs.
673 // Use "while" instead of "if" since ProcessNotify can modify
674 // DispatchNotifyList.CurrentCount (with NotifyPpi) so we have
675 // to iterate until the same.
677 while (PrivateData
->PpiData
.DispatchNotifyList
.LastDispatchedCount
!= PrivateData
->PpiData
.DispatchNotifyList
.CurrentCount
) {
678 TempValue
= PrivateData
->PpiData
.DispatchNotifyList
.CurrentCount
;
681 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH
,
683 PrivateData
->PpiData
.PpiList
.LastDispatchedCount
,
684 PrivateData
->PpiData
.DispatchNotifyList
.LastDispatchedCount
,
685 PrivateData
->PpiData
.DispatchNotifyList
.CurrentCount
687 PrivateData
->PpiData
.DispatchNotifyList
.LastDispatchedCount
= TempValue
;
691 // Check if the PEIM that was just dispatched resulted in any
692 // PPIs getting installed. If so, go process any dispatch
693 // level Notifies that match the installed PPIs.
694 // Use "while" instead of "if" since ProcessNotify can modify
695 // PpiList.CurrentCount (with InstallPpi) so we have to iterate
698 while (PrivateData
->PpiData
.PpiList
.LastDispatchedCount
!= PrivateData
->PpiData
.PpiList
.CurrentCount
) {
699 TempValue
= PrivateData
->PpiData
.PpiList
.CurrentCount
;
702 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH
,
703 PrivateData
->PpiData
.PpiList
.LastDispatchedCount
,
704 PrivateData
->PpiData
.PpiList
.CurrentCount
,
706 PrivateData
->PpiData
.DispatchNotifyList
.LastDispatchedCount
708 PrivateData
->PpiData
.PpiList
.LastDispatchedCount
= TempValue
;
711 if (PrivateData
->PpiData
.DispatchNotifyList
.LastDispatchedCount
== PrivateData
->PpiData
.DispatchNotifyList
.CurrentCount
) {
720 Process notifications.
722 @param PrivateData PeiCore's private data structure
723 @param NotifyType Type of notify to fire.
724 @param InstallStartIndex Install Beginning index.
725 @param InstallStopIndex Install Ending index.
726 @param NotifyStartIndex Notify Beginning index.
727 @param NotifyStopIndex Notify Ending index.
732 IN PEI_CORE_INSTANCE
*PrivateData
,
734 IN INTN InstallStartIndex
,
735 IN INTN InstallStopIndex
,
736 IN INTN NotifyStartIndex
,
737 IN INTN NotifyStopIndex
742 EFI_GUID
*SearchGuid
;
744 EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
;
746 for (Index1
= NotifyStartIndex
; Index1
< NotifyStopIndex
; Index1
++) {
747 if (NotifyType
== EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK
) {
748 NotifyDescriptor
= PrivateData
->PpiData
.CallbackNotifyList
.NotifyPtrs
[Index1
].Notify
;
750 NotifyDescriptor
= PrivateData
->PpiData
.DispatchNotifyList
.NotifyPtrs
[Index1
].Notify
;
753 CheckGuid
= NotifyDescriptor
->Guid
;
755 for (Index2
= InstallStartIndex
; Index2
< InstallStopIndex
; Index2
++) {
756 SearchGuid
= PrivateData
->PpiData
.PpiList
.PpiPtrs
[Index2
].Ppi
->Guid
;
758 // Don't use CompareGuid function here for performance reasons.
759 // Instead we compare the GUID as INT32 at a time and branch
760 // on the first failed comparison.
762 if ((((INT32
*)SearchGuid
)[0] == ((INT32
*)CheckGuid
)[0]) &&
763 (((INT32
*)SearchGuid
)[1] == ((INT32
*)CheckGuid
)[1]) &&
764 (((INT32
*)SearchGuid
)[2] == ((INT32
*)CheckGuid
)[2]) &&
765 (((INT32
*)SearchGuid
)[3] == ((INT32
*)CheckGuid
)[3])) {
766 DEBUG ((EFI_D_INFO
, "Notify: PPI Guid: %g, Peim notify entry point: %p\n",
768 NotifyDescriptor
->Notify
770 NotifyDescriptor
->Notify (
771 (EFI_PEI_SERVICES
**) GetPeiServicesTablePointer (),
773 (PrivateData
->PpiData
.PpiList
.PpiPtrs
[Index2
].Ppi
)->Ppi
781 Process PpiList from SEC phase.
783 @param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
784 @param PpiList Points to a list of one or more PPI descriptors to be installed initially by the PEI core.
785 These PPI's will be installed and/or immediately signaled if they are notification type.
789 ProcessPpiListFromSec (
790 IN CONST EFI_PEI_SERVICES
**PeiServices
,
791 IN CONST EFI_PEI_PPI_DESCRIPTOR
*PpiList
795 EFI_SEC_HOB_DATA_PPI
*SecHobDataPpi
;
796 EFI_HOB_GENERIC_HEADER
*SecHobList
;
799 if ((PpiList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES
) != 0) {
801 // It is a notification PPI.
803 Status
= InternalPeiNotifyPpi (PeiServices
, (CONST EFI_PEI_NOTIFY_DESCRIPTOR
*) PpiList
, TRUE
);
804 ASSERT_EFI_ERROR (Status
);
807 // It is a normal PPI.
809 Status
= InternalPeiInstallPpi (PeiServices
, PpiList
, TRUE
);
810 ASSERT_EFI_ERROR (Status
);
813 if ((PpiList
->Flags
& EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST
) {
815 // Continue until the end of the PPI List.
824 // If the EFI_SEC_HOB_DATA_PPI is in the list of PPIs passed to the PEI entry point,
825 // the PEI Foundation will call the GetHobs() member function and install all HOBs
826 // returned into the HOB list. It does this after installing all PPIs passed from SEC
827 // into the PPI database and before dispatching any PEIMs.
829 Status
= PeiLocatePpi (PeiServices
, &gEfiSecHobDataPpiGuid
, 0, NULL
, (VOID
**) &SecHobDataPpi
);
830 if (!EFI_ERROR (Status
)) {
831 Status
= SecHobDataPpi
->GetHobs (SecHobDataPpi
, &SecHobList
);
832 if (!EFI_ERROR (Status
)) {
833 Status
= PeiInstallSecHobData (PeiServices
, SecHobList
);
834 ASSERT_EFI_ERROR (Status
);