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

View File

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