24 IN OUT VOID **Pointer,
28 IN BOOLEAN OffsetPositive
31 if (((
UINTN)*Pointer < TempTop) &&
32 ((
UINTN)*Pointer >= TempBottom))
35 *Pointer = (VOID *)((
UINTN)*Pointer + Offset);
37 *Pointer = (VOID *)((
UINTN)*Pointer - Offset);
61 if (PrivateData->MemoryPages.Size != 0) {
68 (
UINTN)PrivateData->MemoryPages.Base,
69 (
UINTN)PrivateData->MemoryPages.Base + PrivateData->MemoryPages.Size,
70 PrivateData->MemoryPages.Offset,
71 PrivateData->MemoryPages.OffsetPositive
80 (
UINTN)SecCoreData->PeiTemporaryRamBase,
81 (
UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize,
82 PrivateData->HeapOffset,
83 PrivateData->HeapOffsetPositive
91 (
UINTN)SecCoreData->StackBase,
92 (
UINTN)SecCoreData->StackBase + SecCoreData->StackSize,
93 PrivateData->StackOffset,
94 PrivateData->StackOffsetPositive
100 for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole++) {
101 if (PrivateData->HoleData[IndexHole].Size == 0) {
107 (
UINTN)PrivateData->HoleData[IndexHole].Base,
108 (
UINTN)PrivateData->HoleData[IndexHole].Base + PrivateData->HoleData[IndexHole].Size,
109 PrivateData->HoleData[IndexHole].Offset,
110 PrivateData->HoleData[IndexHole].OffsetPositive
171 for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
175 &PrivateData->PpiData.PpiList.PpiPtrs[Index]
182 for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) {
186 &PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index]
193 for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {
197 &PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index]
222 BOOLEAN OffsetPositive;
228 GuidCheckList[0] = &gEfiPeiFirmwareVolumeInfoPpiGuid;
229 GuidCheckList[1] = &gEfiPeiFirmwareVolumeInfo2PpiGuid;
231 if (FvHandle > OrgFvHandle) {
232 OffsetPositive =
TRUE;
233 Offset = FvHandle - OrgFvHandle;
235 OffsetPositive =
FALSE;
236 Offset = OrgFvHandle - FvHandle;
239 DEBUG ((DEBUG_VERBOSE,
"Converting PPI pointers in FV.\n"));
242 " OrgFvHandle at 0x%08x. FvHandle at 0x%08x. FvSize = 0x%x\n",
249 " OrgFvHandle range: 0x%08x - 0x%08x\n",
254 for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) {
256 (VOID **)&PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw,
258 OrgFvHandle + FvSize,
263 (VOID **)&PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Guid,
265 OrgFvHandle + FvSize,
270 (VOID **)&PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Notify,
272 OrgFvHandle + FvSize,
278 for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {
280 (VOID **)&PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw,
282 OrgFvHandle + FvSize,
287 (VOID **)&PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Guid,
289 OrgFvHandle + FvSize,
294 (VOID **)&PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Notify,
296 OrgFvHandle + FvSize,
302 for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
304 (VOID **)&PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw,
306 OrgFvHandle + FvSize,
311 (VOID **)&PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid,
313 OrgFvHandle + FvSize,
318 (VOID **)&PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Ppi,
320 OrgFvHandle + FvSize,
325 Guid = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid;
326 for (GuidIndex = 0; GuidIndex <
ARRAY_SIZE (GuidCheckList); ++GuidIndex) {
332 if ((((INT32 *)Guid)[0] == ((INT32 *)GuidCheckList[GuidIndex])[0]) &&
333 (((INT32 *)Guid)[1] == ((INT32 *)GuidCheckList[GuidIndex])[1]) &&
334 (((INT32 *)Guid)[2] == ((INT32 *)GuidCheckList[GuidIndex])[2]) &&
335 (((INT32 *)Guid)[3] == ((INT32 *)GuidCheckList[GuidIndex])[3]))
337 FvInfoPpi = PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Ppi;
338 DEBUG ((DEBUG_VERBOSE,
" FvInfo: %p -> ", FvInfoPpi->
FvInfo));
341 (VOID **)&FvInfoPpi->
FvInfo,
343 OrgFvHandle + FvSize,
350 DEBUG ((DEBUG_VERBOSE,
"\n"));
372 if (PrivateData ==
NULL) {
376 for (Index = 0; Index < PrivateData->PpiData.CallbackNotifyList.CurrentCount; Index++) {
379 "CallbackNotify[%2d] {%g} at 0x%x (%a)\n",
381 PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Notify->Guid,
382 (
UINTN)PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw,
385 ((
EFI_PHYSICAL_ADDRESS)(
UINTN)PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index].Raw >= PrivateData->PhysicalMemoryBegin) &&
388 ?
"CAR" :
"Post-Memory"
393 for (Index = 0; Index < PrivateData->PpiData.DispatchNotifyList.CurrentCount; Index++) {
396 "DispatchNotify[%2d] {%g} at 0x%x (%a)\n",
398 PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Notify->Guid,
399 (
UINTN)PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw,
402 ((
EFI_PHYSICAL_ADDRESS)(
UINTN)PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index].Raw >= PrivateData->PhysicalMemoryBegin) &&
405 ?
"CAR" :
"Post-Memory"
410 for (Index = 0; Index < PrivateData->PpiData.PpiList.CurrentCount; Index++) {
413 "PPI[%2d] {%g} at 0x%x (%a)\n",
415 PrivateData->PpiData.PpiList.PpiPtrs[Index].Ppi->Guid,
416 (
UINTN)PrivateData->PpiData.PpiList.PpiPtrs[Index].Raw,
422 ?
"CAR" :
"Post-Memory"
461 if (PpiList ==
NULL) {
462 return EFI_INVALID_PARAMETER;
467 PpiListPointer = &PrivateData->PpiData.
PpiList;
468 Index = PpiListPointer->CurrentCount;
483 if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
484 PpiListPointer->CurrentCount = LastCount;
485 DEBUG ((DEBUG_ERROR,
"ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));
486 return EFI_INVALID_PARAMETER;
489 if (Index >= PpiListPointer->MaxCount) {
496 ASSERT (TempPtr !=
NULL);
502 PpiListPointer->
PpiPtrs = TempPtr;
506 DEBUG ((DEBUG_INFO,
"Install PPI: %g\n", PpiList->Guid));
509 PpiListPointer->CurrentCount++;
516 }
else if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
517 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST)
536 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
538 PpiListPointer->CurrentCount,
599 if ((OldPpi ==
NULL) || (NewPpi ==
NULL)) {
600 return EFI_INVALID_PARAMETER;
603 if ((NewPpi->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
604 return EFI_INVALID_PARAMETER;
613 for (Index = 0; Index < PrivateData->PpiData.
PpiList.CurrentCount; Index++) {
619 if (Index == PrivateData->PpiData.
PpiList.CurrentCount) {
620 return EFI_NOT_FOUND;
626 DEBUG ((DEBUG_INFO,
"Reinstall PPI: %g\n", NewPpi->Guid));
634 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
680 for (Index = 0; Index < PrivateData->PpiData.
PpiList.CurrentCount; Index++) {
682 CheckGuid = TempPtr->
Guid;
689 if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) &&
690 (((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) &&
691 (((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) &&
692 (((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3]))
695 if (PpiDescriptor !=
NULL) {
696 *PpiDescriptor = TempPtr;
710 return EFI_NOT_FOUND;
739 UINTN CallbackNotifyIndex;
740 UINTN LastCallbackNotifyCount;
742 UINTN DispatchNotifyIndex;
743 UINTN LastDispatchNotifyCount;
746 if (NotifyList ==
NULL) {
747 return EFI_INVALID_PARAMETER;
753 CallbackNotifyIndex = CallbackNotifyListPointer->CurrentCount;
754 LastCallbackNotifyCount = CallbackNotifyIndex;
757 DispatchNotifyIndex = DispatchNotifyListPointer->CurrentCount;
758 LastDispatchNotifyCount = DispatchNotifyIndex;
770 if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
771 CallbackNotifyListPointer->CurrentCount = LastCallbackNotifyCount;
772 DispatchNotifyListPointer->CurrentCount = LastDispatchNotifyCount;
773 DEBUG ((DEBUG_ERROR,
"ERROR -> NotifyPpi: %g %p\n", NotifyList->Guid, NotifyList->Notify));
774 return EFI_INVALID_PARAMETER;
777 if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) != 0) {
778 if (CallbackNotifyIndex >= CallbackNotifyListPointer->MaxCount) {
785 ASSERT (TempPtr !=
NULL);
791 CallbackNotifyListPointer->
NotifyPtrs = TempPtr;
792 CallbackNotifyListPointer->MaxCount = CallbackNotifyListPointer->MaxCount + CALLBACK_NOTIFY_GROWTH_STEP;
796 CallbackNotifyIndex++;
797 CallbackNotifyListPointer->CurrentCount++;
799 if (DispatchNotifyIndex >= DispatchNotifyListPointer->MaxCount) {
806 ASSERT (TempPtr !=
NULL);
812 DispatchNotifyListPointer->
NotifyPtrs = TempPtr;
813 DispatchNotifyListPointer->MaxCount = DispatchNotifyListPointer->MaxCount + DISPATCH_NOTIFY_GROWTH_STEP;
817 DispatchNotifyIndex++;
818 DispatchNotifyListPointer->CurrentCount++;
821 DEBUG ((DEBUG_INFO,
"Register PPI Notify: %g\n", NotifyList->Guid));
828 }
else if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
829 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST)
848 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
850 PrivateData->PpiData.
PpiList.CurrentCount,
851 LastCallbackNotifyCount,
852 CallbackNotifyListPointer->CurrentCount
905 while (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount != PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
906 TempValue = PrivateData->PpiData.DispatchNotifyList.CurrentCount;
909 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
911 PrivateData->PpiData.PpiList.LastDispatchedCount,
912 PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount,
913 PrivateData->PpiData.DispatchNotifyList.CurrentCount
915 PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount = TempValue;
926 while (PrivateData->PpiData.PpiList.LastDispatchedCount != PrivateData->PpiData.PpiList.CurrentCount) {
927 TempValue = PrivateData->PpiData.PpiList.CurrentCount;
930 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
931 PrivateData->PpiData.PpiList.LastDispatchedCount,
932 PrivateData->PpiData.PpiList.CurrentCount,
934 PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount
936 PrivateData->PpiData.PpiList.LastDispatchedCount = TempValue;
939 if (PrivateData->PpiData.DispatchNotifyList.LastDispatchedCount == PrivateData->PpiData.DispatchNotifyList.CurrentCount) {
963 IN INTN InstallStartIndex,
975 for (Index1 = NotifyStartIndex; Index1 < NotifyStopIndex; Index1++) {
976 if (NotifyType == EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK) {
977 NotifyDescriptor = PrivateData->PpiData.CallbackNotifyList.NotifyPtrs[Index1].
Notify;
979 NotifyDescriptor = PrivateData->PpiData.DispatchNotifyList.NotifyPtrs[Index1].
Notify;
982 CheckGuid = NotifyDescriptor->
Guid;
984 for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {
985 SearchGuid = PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi->Guid;
991 if ((((INT32 *)SearchGuid)[0] == ((INT32 *)CheckGuid)[0]) &&
992 (((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) &&
993 (((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) &&
994 (((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3]))
998 "Notify: PPI Guid: %g, Peim notify entry point: %p\n",
1002 NotifyDescriptor->
Notify (
1005 (PrivateData->PpiData.PpiList.PpiPtrs[Index2].Ppi)->Ppi
1031 if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) != 0) {
1045 if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
1061 Status =
PeiLocatePpi (PeiServices, &gEfiSecHobDataPpiGuid, 0,
NULL, (VOID **)&SecHobDataPpi);
1062 if (!EFI_ERROR (Status)) {
1063 Status = SecHobDataPpi->GetHobs (SecHobDataPpi, &SecHobList);
1064 if (!EFI_ERROR (Status)) {
1088 UINTN PeiCoreModuleSize;
1090 VOID *PeiCoreImageBase;
1091 VOID *PeiCoreEntryPoint;
1094 PeiCoreFileHandle =
NULL;
1099 Status = CoreFvHandle->FvPpi->FindFileByType (
1100 CoreFvHandle->FvPpi,
1101 EFI_FV_FILETYPE_PEI_CORE,
1102 CoreFvHandle->FvHandle,
1107 if (!EFI_ERROR (Status)) {
1108 Status = CoreFvHandle->FvPpi->GetFileInfo (CoreFvHandle->FvPpi, PeiCoreFileHandle, &
FileInfo);
1117 Status = PeCoffLoaderGetEntryPoint ((VOID *)(
UINTN)PeiCoreImageBase, &PeiCoreEntryPoint);
1120 OrgImageBase = (
UINTN)PeiCoreImageBase;
1121 MigratedImageBase = (
UINTN)_ModuleEntryPoint - ((
UINTN)PeiCoreEntryPoint - (
UINTN)PeiCoreImageBase);
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
EFI_STATUS PeiGetPe32Data(IN EFI_PEI_FILE_HANDLE FileHandle, OUT VOID **Pe32Data)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
EFI_STATUS PeiInstallSecHobData(IN CONST EFI_PEI_SERVICES **PeiServices, IN EFI_HOB_GENERIC_HEADER *SecHobList)
#define ARRAY_SIZE(Array)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define PEI_CORE_INSTANCE_FROM_PS_THIS(a)
VOID * EFI_PEI_FILE_HANDLE
EFI_STATUS EFIAPI PeiLocatePpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
VOID ConvertPeiCorePpiPointers(IN PEI_CORE_INSTANCE *PrivateData, IN PEI_CORE_FV_HANDLE *CoreFvHandle)
EFI_STATUS InternalPeiNotifyPpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList, IN BOOLEAN Single)
VOID ProcessNotify(IN PEI_CORE_INSTANCE *PrivateData, IN UINTN NotifyType, IN INTN InstallStartIndex, IN INTN InstallStopIndex, IN INTN NotifyStartIndex, IN INTN NotifyStopIndex)
VOID ConvertSinglePpiPointer(IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN PEI_CORE_INSTANCE *PrivateData, IN PEI_PPI_LIST_POINTERS *PpiPointer)
EFI_STATUS EFIAPI PeiInstallPpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
VOID ProcessDispatchNotifyList(IN PEI_CORE_INSTANCE *PrivateData)
EFI_STATUS EFIAPI PeiReInstallPpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi, IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi)
VOID DumpPpiList(IN PEI_CORE_INSTANCE *PrivateData)
VOID ConvertPpiPointersFv(IN PEI_CORE_INSTANCE *PrivateData, IN UINTN OrgFvHandle, IN UINTN FvHandle, IN UINTN FvSize)
VOID ConvertPpiPointers(IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN PEI_CORE_INSTANCE *PrivateData)
VOID ProcessPpiListFromSec(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI PeiNotifyPpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
EFI_STATUS InternalPeiInstallPpi(IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList, IN BOOLEAN Single)
VOID ConvertPointer(IN OUT VOID **Pointer, IN UINTN TempBottom, IN UINTN TempTop, IN UINTN Offset, IN BOOLEAN OffsetPositive)
VOID ConvertPointerInRanges(IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, IN PEI_CORE_INSTANCE *PrivateData, IN OUT VOID **Pointer)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
UINT64 EFI_PHYSICAL_ADDRESS
EFI_PEIM_NOTIFY_ENTRY_POINT Notify
PEI_PPI_LIST_POINTERS * NotifyPtrs
PEI_PPI_LIST_POINTERS * NotifyPtrs
PEI_CALLBACK_NOTIFY_LIST CallbackNotifyList
PEI_DISPATCH_NOTIFY_LIST DispatchNotifyList
PEI_PPI_LIST_POINTERS * PpiPtrs