X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FPei%2FPpi%2FPpi.c;h=1e400225fb385a8482a7a18f6d48f410a45e5356;hb=615c6dd0d4c428658d761d96bcb51f2fbd5e7523;hp=c8bea851a5df7d1ed017421c72b425888eb37e3c;hpb=859b72fa7e3ff1cf1d7476a3446af4ebbb5fe3e6;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index c8bea851a5..1e400225fb 100644 --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -1,13 +1,13 @@ -/*++ +/** @file + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Module Name: @@ -19,13 +19,13 @@ Abstract: Revision History ---*/ +**/ #include VOID InitializePpiServices ( - IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CORE_INSTANCE *PrivateData, IN PEI_CORE_INSTANCE *OldCoreData ) /*++ @@ -45,23 +45,20 @@ Returns: --*/ { - PEI_CORE_INSTANCE *PrivateData; - if (OldCoreData == NULL) { - PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); - PrivateData->PpiData.NotifyListEnd = MAX_PPI_DESCRIPTORS-1; PrivateData->PpiData.DispatchListEnd = MAX_PPI_DESCRIPTORS-1; PrivateData->PpiData.LastDispatchedNotify = MAX_PPI_DESCRIPTORS-1; } - - return; + + return; } VOID ConvertPpiPointers ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob, + IN CONST EFI_PEI_SERVICES **PeiServices, + IN UINTN OldCheckingBottom, + IN UINTN OldCheckingTop, IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob ) /*++ @@ -72,12 +69,13 @@ Routine Description: Arguments: - PeiServices - The PEI core services table. - OldHandOffHob - The old handoff HOB list. - NewHandOffHob - The new handoff HOB list. + PeiServices - The PEI core services table. + OldCheckingBottom - The old checking bottom. + OldCheckingTop - The old checking top. + NewHandOffHob - The new handoff HOB list. Returns: - + --*/ { PEI_CORE_INSTANCE *PrivateData; @@ -87,15 +85,15 @@ Returns: PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); - Fixup = (UINTN)NewHandOffHob - (UINTN)OldHandOffHob; - + Fixup = (UINTN)NewHandOffHob - OldCheckingBottom; + for (Index = 0; Index < MAX_PPI_DESCRIPTORS; Index++) { if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData->PpiData.NotifyListEnd) { PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index]; - - if (((UINTN)PpiPointer->Raw < (UINTN)OldHandOffHob->EfiFreeMemoryBottom) && - ((UINTN)PpiPointer->Raw >= (UINTN)OldHandOffHob)) { + + if (((UINTN)PpiPointer->Raw < OldCheckingTop) && + ((UINTN)PpiPointer->Raw >= OldCheckingBottom)) { // // Convert the pointer to the PEIM descriptor from the old HOB heap // to the relocated HOB heap. @@ -106,9 +104,9 @@ Returns: // Only when the PEIM descriptor is in the old HOB should it be necessary // to try to convert the pointers in the PEIM descriptor // - - if (((UINTN)PpiPointer->Ppi->Guid < (UINTN)OldHandOffHob->EfiFreeMemoryBottom) && - ((UINTN)PpiPointer->Ppi->Guid >= (UINTN)OldHandOffHob)) { + + if (((UINTN)PpiPointer->Ppi->Guid < OldCheckingTop) && + ((UINTN)PpiPointer->Ppi->Guid >= OldCheckingBottom)) { // // Convert the pointer to the GUID in the PPI or NOTIFY descriptor // from the old HOB heap to the relocated HOB heap. @@ -121,13 +119,13 @@ Returns: // the notification function in the NOTIFY descriptor needs not be converted. // if (Index < PrivateData->PpiData.PpiListEnd && - (UINTN)PpiPointer->Ppi->Ppi < (UINTN)OldHandOffHob->EfiFreeMemoryBottom && - (UINTN)PpiPointer->Ppi->Ppi >= (UINTN)OldHandOffHob) { + (UINTN)PpiPointer->Ppi->Ppi < OldCheckingTop && + (UINTN)PpiPointer->Ppi->Ppi >= OldCheckingBottom) { // // Convert the pointer to the PPI interface structure in the PPI descriptor // from the old HOB heap to the relocated HOB heap. // - PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi+ Fixup); + PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi+ Fixup); } } } @@ -139,8 +137,8 @@ Returns: EFI_STATUS EFIAPI PeiInstallPpi ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_PPI_DESCRIPTOR *PpiList + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList ) /*++ @@ -181,7 +179,7 @@ Returns: // by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last // EFI_PEI_PPI_DESCRIPTOR in the list. // - + for (;;) { // // Since PpiData is used for NotifyList and InstallList, max resource @@ -191,7 +189,7 @@ Returns: return EFI_OUT_OF_RESOURCES; } // - // Check if it is a valid PPI. + // Check if it is a valid PPI. // If not, rollback list to exclude all in this list. // Try to indicate which item failed. // @@ -201,14 +199,14 @@ Returns: return EFI_INVALID_PARAMETER; } - DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid)); - PrivateData->PpiData.PpiListPtrs[Index].Ppi = PpiList; + DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid)); + PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList; PrivateData->PpiData.PpiListEnd++; - + // // Continue until the end of the PPI List. // - if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == + if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) { break; } @@ -220,11 +218,11 @@ Returns: // Dispatch any callback level notifies for newly installed PPIs. // DispatchNotify ( - PeiServices, + PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, LastCallbackInstall, PrivateData->PpiData.PpiListEnd, - PrivateData->PpiData.DispatchListEnd, + PrivateData->PpiData.DispatchListEnd, PrivateData->PpiData.NotifyListEnd ); @@ -236,9 +234,9 @@ Returns: EFI_STATUS EFIAPI PeiReInstallPpi ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_PPI_DESCRIPTOR *OldPpi, - IN EFI_PEI_PPI_DESCRIPTOR *NewPpi + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi, + IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi ) /*++ @@ -290,19 +288,19 @@ Returns: // // Remove the old PPI from the database, add the new one. - // + // DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid)); - PrivateData->PpiData.PpiListPtrs[Index].Ppi = NewPpi; + PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi; // // Dispatch any callback level notifies for the newly installed PPI. // DispatchNotify ( - PeiServices, + PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, Index, Index+1, - PrivateData->PpiData.DispatchListEnd, + PrivateData->PpiData.DispatchListEnd, PrivateData->PpiData.NotifyListEnd ); @@ -314,8 +312,8 @@ Returns: EFI_STATUS EFIAPI PeiLocatePpi ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_GUID *Guid, + 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 @@ -337,7 +335,7 @@ Arguments: Returns: - Status - EFI_SUCCESS if the PPI is in the database + Status - EFI_SUCCESS if the PPI is in the database EFI_NOT_FOUND if the PPI is not in the database --*/ { @@ -346,7 +344,7 @@ Returns: EFI_GUID *CheckGuid; EFI_PEI_PPI_DESCRIPTOR *TempPtr; - + PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); // @@ -389,8 +387,8 @@ Returns: EFI_STATUS EFIAPI PeiNotifyPpi ( - IN EFI_PEI_SERVICES **PeiServices, - IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList + IN CONST EFI_PEI_SERVICES **PeiServices, + IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList ) /*++ @@ -444,7 +442,7 @@ Returns: if (Index == PrivateData->PpiData.PpiListEnd - 1) { return EFI_OUT_OF_RESOURCES; } - + // // If some of the PPI data is invalid restore original Notify PPI database value // @@ -453,13 +451,13 @@ Returns: DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %x\n", NotifyList->Guid, NotifyList->Notify)); return EFI_INVALID_PARAMETER; } - + if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) { - NotifyDispatchCount ++; - } - - PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyList; - + NotifyDispatchCount ++; + } + + PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList; + PrivateData->PpiData.NotifyListEnd--; DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid)); if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == @@ -472,46 +470,46 @@ Returns: NotifyList++; Index--; } - + // - // If there is Dispatch Notify PPI installed put them on the bottom + // If there is Dispatch Notify PPI installed put them on the bottom // if (NotifyDispatchCount > 0) { - for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) { + for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) { if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) { NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify; - + for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){ PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify; } PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr; - PrivateData->PpiData.DispatchListEnd--; + PrivateData->PpiData.DispatchListEnd--; } } - - LastCallbackNotify -= NotifyDispatchCount; + + LastCallbackNotify -= NotifyDispatchCount; } - + // // Dispatch any callback level notifies for all previously installed PPIs. // DispatchNotify ( - PeiServices, + PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, 0, PrivateData->PpiData.PpiListEnd, LastCallbackNotify, PrivateData->PpiData.NotifyListEnd ); - - + + return EFI_SUCCESS; } VOID ProcessNotifyList ( - IN EFI_PEI_SERVICES **PeiServices + IN PEI_CORE_INSTANCE *PrivateData ) /*++ @@ -528,24 +526,20 @@ Returns: --*/ { - PEI_CORE_INSTANCE *PrivateData; INTN TempValue; - PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); - - while (TRUE) { // // Check if the PEIM that was just dispatched resulted in any // Notifies getting installed. If so, go process any dispatch // level Notifies that match the previouly installed PPIs. - // Use "while" instead of "if" since DispatchNotify can modify + // Use "while" instead of "if" since DispatchNotify can modify // DispatchListEnd (with NotifyPpi) so we have to iterate until the same. // while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) { TempValue = PrivateData->PpiData.DispatchListEnd; DispatchNotify ( - PeiServices, + PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, 0, PrivateData->PpiData.LastDispatchedInstall, @@ -554,19 +548,19 @@ Returns: ); PrivateData->PpiData.LastDispatchedNotify = TempValue; } - - + + // // Check if the PEIM that was just dispatched resulted in any // PPIs getting installed. If so, go process any dispatch // level Notifies that match the installed PPIs. - // Use "while" instead of "if" since DispatchNotify can modify + // Use "while" instead of "if" since DispatchNotify can modify // PpiListEnd (with InstallPpi) so we have to iterate until the same. // while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) { TempValue = PrivateData->PpiData.PpiListEnd; DispatchNotify ( - PeiServices, + PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, PrivateData->PpiData.LastDispatchedInstall, PrivateData->PpiData.PpiListEnd, @@ -575,17 +569,17 @@ Returns: ); PrivateData->PpiData.LastDispatchedInstall = TempValue; } - + if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) { break; } - } + } return; } VOID DispatchNotify ( - IN EFI_PEI_SERVICES **PeiServices, + IN PEI_CORE_INSTANCE *PrivateData, IN UINTN NotifyType, IN INTN InstallStartIndex, IN INTN InstallStopIndex, @@ -612,15 +606,12 @@ Returns: None --*/ { - PEI_CORE_INSTANCE *PrivateData; INTN Index1; INTN Index2; EFI_GUID *SearchGuid; EFI_GUID *CheckGuid; EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor; - PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices); - // // Remember that Installs moves up and Notifies moves down. // @@ -640,12 +631,12 @@ Returns: None (((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) && (((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) && (((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) { - DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %x\n", - SearchGuid, + DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %x\n", + SearchGuid, NotifyDescriptor->Notify )); NotifyDescriptor->Notify ( - PeiServices, + GetPeiServicesTablePointer (), NotifyDescriptor, (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi );