PeiCore should fixup heap/stack pointer according to heap's/stack's base address separately.

After this check-in, PeiCore will do not make any assumption of heap/stack layout in CAR.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5421 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2008-07-08 07:49:10 +00:00
parent 2419660827
commit 66c69dea0d
1 changed files with 12 additions and 7 deletions

View File

@ -274,7 +274,8 @@ Returns:
TEMPORARY_RAM_SUPPORT_PPI *TemporaryRamSupportPpi;
EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffTable;
EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffTable;
INTN Offset;
INTN StackOffset;
INTN HeapOffset;
PEI_CORE_INSTANCE *PrivateInMem;
UINT64 NewPeiStackSize;
UINT64 OldPeiStackSize;
@ -484,7 +485,7 @@ Returns:
if (Private->StackSize > OldPeiStackSize) {
StackGap = Private->StackSize - OldPeiStackSize;
}
//
// Update HandOffHob for new installed permenent memory
//
@ -497,9 +498,13 @@ Returns:
// CAUTION: The new base is computed accounding to gap of new stack.
//
NewPermenentMemoryBase = Private->PhysicalMemoryBegin + StackGap;
Offset = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->TemporaryRamBase;
NewHandOffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + Offset);
PrivateInMem = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + Offset);
StackOffset = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->StackBase;
HeapOffset = (INTN) ((UINTN) Private->PhysicalMemoryBegin + Private->StackSize - \
(UINTN) SecCoreData->PeiTemporaryRamBase);
DEBUG ((EFI_D_INFO, "Heap Offset = 0x%X Stack Offset = 0x%X\n", HeapOffset, StackOffset));
NewHandOffTable = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + HeapOffset);
PrivateInMem = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + StackOffset);
//
// TemporaryRamSupportPpi is produced by platform's SEC
@ -536,7 +541,7 @@ Returns:
//
PrivateInMem->PS = &PrivateInMem->ServiceTableShadow;
PrivateInMem->CpuIo = &PrivateInMem->ServiceTableShadow.CpuIo;
PrivateInMem->HobList.Raw = (VOID*) ((UINTN) PrivateInMem->HobList.Raw + Offset);
PrivateInMem->HobList.Raw = (VOID*) ((UINTN) PrivateInMem->HobList.Raw + HeapOffset);
PrivateInMem->StackBase = (EFI_PHYSICAL_ADDRESS)(((UINTN)PrivateInMem->PhysicalMemoryBegin + EFI_PAGE_MASK) & ~EFI_PAGE_MASK);
PeiServices = &PrivateInMem->PS;
@ -550,7 +555,7 @@ Returns:
// Update HandOffHob for new installed permenent memory
//
NewHandOffTable->EfiEndOfHobList =
(EFI_PHYSICAL_ADDRESS)((UINTN) NewHandOffTable->EfiEndOfHobList + Offset);
(EFI_PHYSICAL_ADDRESS)((UINTN) NewHandOffTable->EfiEndOfHobList + HeapOffset);
NewHandOffTable->EfiMemoryTop = PrivateInMem->PhysicalMemoryBegin +
PrivateInMem->PhysicalMemoryLength;
NewHandOffTable->EfiMemoryBottom = PrivateInMem->PhysicalMemoryBegin;