X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FCore%2FPei%2FPpi%2FPpi.c;h=db6eded6d6eddd4cf0cdb21402148abdbec1c27f;hb=322d827c0f41efe14387ee67834ddced09f95c9c;hp=90d5c925a0c73d480e0c70befa7ecfd8db9bdd39;hpb=0e549d5be531a840503445d38b4dad2315ef3413;p=mirror_edk2.git diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index 90d5c925a0..db6eded6d6 100644 --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -1,8 +1,8 @@ /** @file EFI PEI Core PPI services -Copyright (c) 2006, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2006 - 2014, 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 @@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include +#include "PeiMain.h" /** @@ -30,76 +30,134 @@ InitializePpiServices ( ) { if (OldCoreData == NULL) { - PrivateData->PpiData.NotifyListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1; - PrivateData->PpiData.DispatchListEnd = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1; - PrivateData->PpiData.LastDispatchedNotify = FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1; + PrivateData->PpiData.NotifyListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1; + PrivateData->PpiData.DispatchListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1; + PrivateData->PpiData.LastDispatchedNotify = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1; } } /** - Migrate the Hob list from the CAR stack to PEI installed memory. + Migrate Single PPI Pointer from the temporary memory to PEI installed memory. - @param PrivateData Pointer to PeiCore's private data structure. - @param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range - will be fixup for PpiData and PpiDescriptor pointer. - @param OldCheckingTop Top of temporary memory range. All Ppi in this range - will be fixup for PpiData and PpiDescriptor. - @param Fixup The address difference between - the new Hob list and old Hob list. + @param PpiPointer Pointer to Ppi + @param TempBottom Base of old temporary memory + @param TempTop Top of old temporary memory + @param Offset Offset of new memory to old temporary memory. + @param OffsetPositive Positive flag of Offset value. + +**/ +VOID +ConvertSinglePpiPointer ( + IN PEI_PPI_LIST_POINTERS *PpiPointer, + IN UINTN TempBottom, + IN UINTN TempTop, + IN UINTN Offset, + IN BOOLEAN OffsetPositive + ) +{ + if (((UINTN)PpiPointer->Raw < TempTop) && + ((UINTN)PpiPointer->Raw >= TempBottom)) { + // + // Convert the pointer to the PPI descriptor from the old TempRam + // to the relocated physical memory. + // + if (OffsetPositive) { + PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Offset); + } else { + PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - Offset); + } + + // + // Only when the PEIM descriptor is in the old TempRam should it be necessary + // to try to convert the pointers in the PEIM descriptor + // + + if (((UINTN)PpiPointer->Ppi->Guid < TempTop) && + ((UINTN)PpiPointer->Ppi->Guid >= TempBottom)) { + // + // Convert the pointer to the GUID in the PPI or NOTIFY descriptor + // from the old TempRam to the relocated physical memory. + // + if (OffsetPositive) { + PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Offset); + } else { + PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - Offset); + } + } + + // + // Convert the pointer to the PPI interface structure in the PPI descriptor + // from the old TempRam to the relocated physical memory. + // + if ((UINTN)PpiPointer->Ppi->Ppi < TempTop && + (UINTN)PpiPointer->Ppi->Ppi >= TempBottom) { + if (OffsetPositive) { + PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + Offset); + } else { + PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - Offset); + } + } + } +} + +/** + + Migrate PPI Pointers from the temporary memory stack to PEI installed memory. + + @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size + and location of temporary RAM, the stack location and the BFV location. + @param PrivateData Pointer to PeiCore's private data structure. **/ VOID ConvertPpiPointers ( - IN PEI_CORE_INSTANCE *PrivateData, - IN UINTN OldCheckingBottom, - IN UINTN OldCheckingTop, - IN INTN Fixup + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN PEI_CORE_INSTANCE *PrivateData ) { UINT8 Index; - PEI_PPI_LIST_POINTERS *PpiPointer; - - for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) { - if (Index < PrivateData->PpiData.PpiListEnd || - Index > PrivateData->PpiData.NotifyListEnd) { - PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index]; - - 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. - // - PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Fixup); - - // - // 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 < 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. - // - PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Fixup); - } + UINT8 IndexHole; - // - // Assume that no code is located in the temporary memory, so the pointer to - // the notification function in the NOTIFY descriptor needs not be converted. - // - if (Index < PrivateData->PpiData.PpiListEnd && - (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); + for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) { + if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData->PpiData.NotifyListEnd) { + // + // Convert PPI pointer in old Heap + // + ConvertSinglePpiPointer ( + &PrivateData->PpiData.PpiListPtrs[Index], + (UINTN)SecCoreData->PeiTemporaryRamBase, + (UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize, + PrivateData->HeapOffset, + PrivateData->HeapOffsetPositive + ); + + // + // Convert PPI pointer in old Stack + // + ConvertSinglePpiPointer ( + &PrivateData->PpiData.PpiListPtrs[Index], + (UINTN)SecCoreData->StackBase, + (UINTN)SecCoreData->StackBase + SecCoreData->StackSize, + PrivateData->StackOffset, + PrivateData->StackOffsetPositive + ); + + // + // Convert PPI pointer in old TempRam Hole + // + for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole ++) { + if (PrivateData->HoleData[IndexHole].Size == 0) { + continue; } + + ConvertSinglePpiPointer ( + &PrivateData->PpiData.PpiListPtrs[Index], + (UINTN)PrivateData->HoleData[IndexHole].Base, + (UINTN)PrivateData->HoleData[IndexHole].Base + PrivateData->HoleData[IndexHole].Size, + PrivateData->HoleData[IndexHole].Offset, + PrivateData->HoleData[IndexHole].OffsetPositive + ); } } } @@ -151,6 +209,7 @@ PeiInstallPpi ( // // Since PpiData is used for NotifyList and PpiList, max resource // is reached if the Install reaches the NotifyList + // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement. // if (Index == PrivateData->PpiData.NotifyListEnd + 1) { return EFI_OUT_OF_RESOURCES; @@ -253,6 +312,7 @@ PeiReInstallPpi ( // Remove the old PPI from the database, add the new one. // DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid)); + ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported))); PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi; // @@ -391,6 +451,7 @@ PeiNotifyPpi ( // // Since PpiData is used for NotifyList and InstallList, max resource // is reached if the Install reaches the PpiList + // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement. // if (Index == PrivateData->PpiData.PpiListEnd - 1) { return EFI_OUT_OF_RESOURCES; @@ -509,7 +570,7 @@ ProcessNotifyList ( EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, PrivateData->PpiData.LastDispatchedInstall, PrivateData->PpiData.PpiListEnd, - FixedPcdGet32 (PcdPeiCoreMaxPpiSupported)-1, + PcdGet32 (PcdPeiCoreMaxPpiSupported)-1, PrivateData->PpiData.DispatchListEnd ); PrivateData->PpiData.LastDispatchedInstall = TempValue;