From a3a15d2108bb276f8a668a059c86ccfc101e5986 Mon Sep 17 00:00:00 2001 From: qwang12 Date: Thu, 8 Nov 2007 03:50:37 +0000 Subject: [PATCH] 1) If PeiLoadImage fails, the section extraction PPI or Decompress PPI may not be ready, we flag that more Peims need to be dispatched. 2) Set the stack to be cacheable before the stack switch occurs so that IPF recovery path will be run from cacheble memory for code, data and stack. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4288 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 6 ++++++ MdeModulePkg/Core/Pei/Ipf/SwitchToCacheMode.c | 7 ------- MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 15 ++++++++++++--- MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 7 +------ 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c index 8fccf3413e..164c2c8746 100644 --- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c +++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c @@ -372,6 +372,12 @@ Returns: ); PERF_END (0, "PEIM", NULL, 0); + } else { + // + // If PeiLoadImage fails, the section extraction PPI or Decompress PPI may not be ready, + // we flag that more Peims need to be dispatched. + // + PeimNeedingDispatch = TRUE; } // diff --git a/MdeModulePkg/Core/Pei/Ipf/SwitchToCacheMode.c b/MdeModulePkg/Core/Pei/Ipf/SwitchToCacheMode.c index 45676f0e49..1f261af5cb 100644 --- a/MdeModulePkg/Core/Pei/Ipf/SwitchToCacheMode.c +++ b/MdeModulePkg/Core/Pei/Ipf/SwitchToCacheMode.c @@ -44,13 +44,6 @@ Returns: { EFI_HOB_HANDOFF_INFO_TABLE *Phit; - if (CoreData == NULL) { - // - // the first call with CoreData as NULL. - // - return; - } - if ((GetHandOffStatus().r10 & 0xFF) == RecoveryFn) { CoreData->StackBase = CoreData->StackBase & CACHE_MODE_ADDRESS_MASK; CoreData->HobList.Raw = (UINT8 *)((UINTN)CoreData->HobList.Raw & CACHE_MODE_ADDRESS_MASK); diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c index 728b963afa..e2b2ccc30f 100644 --- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c +++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c @@ -114,6 +114,8 @@ Returns: UINT64 PeiStackSize; UINT64 EfiFreeMemorySize; EFI_PHYSICAL_ADDRESS PhysicalAddressOfOldHob; + + DEBUG ((EFI_D_INFO, "PeiInstallPeiMemory MemoryBegin 0x%LX, MemoryLength 0x%LX\n", MemoryBegin, MemoryLength)); PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices); @@ -137,8 +139,8 @@ Returns: EfiFreeMemorySize = OldHandOffHob->EfiFreeMemoryBottom - PhysicalAddressOfOldHob; - DEBUG ((EFI_D_INFO, "HOBLIST address before memory init = 0x%08x\n", OldHandOffHob)); - DEBUG ((EFI_D_INFO, "HOBLIST address after memory init = 0x%08x\n", NewHandOffHob)); + DEBUG ((EFI_D_INFO, "HOBLIST address before memory init = 0x%p\n", OldHandOffHob)); + DEBUG ((EFI_D_INFO, "HOBLIST address after memory init = 0x%p\n", NewHandOffHob)); CopyMem ( NewHandOffHob, @@ -155,7 +157,13 @@ Returns: NewHandOffHob->EfiEndOfHobList = (UINTN)NewHandOffHob + (OldHandOffHob->EfiEndOfHobList - PhysicalAddressOfOldHob); - + + // + // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory() + // the 63-bit of address is set to 1. + // + SWITCH_TO_CACHE_MODE (PrivateData); + ConvertPpiPointers (PeiServices, OldHandOffHob, NewHandOffHob); BuildStackHob (PrivateData->StackBase, PrivateData->StackSize); @@ -223,6 +231,7 @@ Returns: Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset; } + ASSERT (Hob.HandoffInformationTable->EfiFreeMemoryTop >= Hob.HandoffInformationTable->EfiFreeMemoryBottom); // // Verify that there is sufficient memory to satisfy the allocation // diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c index 5c6efb95c0..7f7a8cf670 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -135,12 +135,6 @@ Returns: } } - // - // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory() - // the 63-bit of address is set to 1. - // - SWITCH_TO_CACHE_MODE (OldCoreData); - if (OldCoreData != NULL) { CopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE)); @@ -312,3 +306,4 @@ Returns: return EFI_NOT_FOUND; } + -- 2.39.2