From 30c8f8616d9f2c764e4b8c3566bef4f562115005 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Thu, 8 Nov 2007 03:57:04 +0000 Subject: PI spec will be updated to make it clear that this HOB should describe the stack range before going to DXE. Therefore, we should update stack Hob in DxeLoad to reflect real stack git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4290 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/DxeIplPeim/DxeIpl.h | 7 ++++++ MdeModulePkg/Core/DxeIplPeim/DxeLoad.c | 30 +++++++++++++++++++++++++ MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c | 9 ++++++++ MdeModulePkg/Core/DxeIplPeim/Ipf/DxeLoadFunc.c | 5 +++++ MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c | 5 +++++ 5 files changed, 56 insertions(+) diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h index 5e47ca1ba8..dab6839ef3 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.h @@ -33,6 +33,7 @@ Abstract: #include #include +#include #include #include @@ -105,6 +106,12 @@ HandOffToDxeCore ( IN EFI_PEI_PPI_DESCRIPTOR *EndOfPeiSignal ); +VOID +UpdateStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ); + EFI_STATUS EFIAPI PeimInitializeDxeIpl ( diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c index 28c9ececd2..d593e30c74 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c +++ b/MdeModulePkg/Core/DxeIplPeim/DxeLoad.c @@ -751,3 +751,33 @@ Decompress ( return EFI_SUCCESS; } +VOID +UpdateStackHob ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + EFI_PEI_HOB_POINTERS Hob; + + Hob.Raw = GetHobList (); + while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) { + if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) { + // + // Build a new memory allocation HOB with old stack info with EfiConventionalMemory type + // to be reclaimed by DXE core. + // + BuildMemoryAllocationHob ( + Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress, + Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength, + EfiConventionalMemory + ); + // + // Update the BSP Stack Hob to reflect the new stack info. + // + Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress = BaseAddress; + Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength = Length; + break; + } + Hob.Raw = GET_NEXT_HOB (Hob); + } +} diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c index 129b05516d..867c771bc4 100644 --- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c +++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c @@ -106,6 +106,10 @@ HandOffToDxeCore ( AsmWriteCr3 (PageTables); + // + // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore. + // + UpdateStackHob (BaseOfStack, STACK_SIZE); if (FeaturePcdGet (PcdDxeIplEnableIdt)) { SizeOfTemplate = AsmGetVectorTemplatInfo (&TemplateBase); @@ -163,6 +167,11 @@ HandOffToDxeCore ( Status = PeiServicesInstallPpi (EndOfPeiSignal); ASSERT_EFI_ERROR (Status); + // + // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore. + // + UpdateStackHob (BaseOfStack, STACK_SIZE); + SwitchStack ( (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint, HobList.Raw, diff --git a/MdeModulePkg/Core/DxeIplPeim/Ipf/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/Ipf/DxeLoadFunc.c index 34141ab9f6..bf97439549 100644 --- a/MdeModulePkg/Core/DxeIplPeim/Ipf/DxeLoadFunc.c +++ b/MdeModulePkg/Core/DxeIplPeim/Ipf/DxeLoadFunc.c @@ -62,6 +62,11 @@ HandOffToDxeCore ( Status = PeiServicesInstallPpi (EndOfPeiSignal); ASSERT_EFI_ERROR (Status); + // + // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore. + // + UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack, STACK_SIZE); + SwitchStack ( (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint, HobList.Raw, diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c index 53febd563d..aab710a120 100644 --- a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c +++ b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c @@ -51,6 +51,11 @@ HandOffToDxeCore ( Status = PeiServicesInstallPpi (EndOfPeiSignal); ASSERT_EFI_ERROR (Status); + // + // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore. + // + UpdateStackHob (BaseOfStack, STACK_SIZE); + SwitchStack ( (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint, HobList.Raw, -- cgit v1.2.3