mirror of https://github.com/acidanthera/audk.git
Enhance the PEI Core to convert pointers pointing to PPI descriptors on the temporary stack.
Signed-off by: rsun3 Reviewed-by: li-elvin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12354 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
a9292c1363
commit
424b7c9f8f
|
@ -894,6 +894,8 @@ PeiDispatcher (
|
|||
StackOffsetPositive = FALSE;
|
||||
StackOffset = (UINTN)(TopOfOldStack - TopOfNewStack);
|
||||
}
|
||||
Private->StackOffsetPositive = StackOffsetPositive;
|
||||
Private->StackOffset = StackOffset;
|
||||
|
||||
DEBUG ((EFI_D_INFO, "Heap Offset = 0x%lX Stack Offset = 0x%lX\n", (UINT64)Private->HeapOffset, (UINT64)(StackOffset)));
|
||||
|
||||
|
|
|
@ -200,6 +200,8 @@ struct _PEI_CORE_INSTANCE {
|
|||
EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;
|
||||
UINTN HeapOffset;
|
||||
BOOLEAN HeapOffsetPositive;
|
||||
UINTN StackOffset;
|
||||
BOOLEAN StackOffsetPositive;
|
||||
PEICORE_FUNCTION_POINTER ShadowedPeiCore;
|
||||
CACHE_SECTION_DATA CacheSection;
|
||||
//
|
||||
|
@ -377,24 +379,15 @@ InitializePpiServices (
|
|||
|
||||
Migrate the Hob list from the temporary memory stack 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 FixupPositive TRUE if new Hob list is above the old Hob list.
|
||||
Otherwise FALSE.
|
||||
@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 UINTN Fixup,
|
||||
IN BOOLEAN FixupPositive
|
||||
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
||||
IN PEI_CORE_INSTANCE *PrivateData
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
Pei Core Main Entry Point
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
||||
|
@ -204,9 +204,9 @@ PeiCore (
|
|||
HandoffInformationTable->EfiFreeMemoryBottom = HandoffInformationTable->EfiEndOfHobList + sizeof (EFI_HOB_GENERIC_HEADER);
|
||||
|
||||
//
|
||||
// We need convert the PPI desciptor's pointer
|
||||
// We need convert the PPI descriptor's pointer
|
||||
//
|
||||
ConvertPpiPointers (OldCoreData, (UINTN)SecCoreData->TemporaryRamBase, (UINTN)SecCoreData->TemporaryRamBase + SecCoreData->TemporaryRamSize, OldCoreData->HeapOffset, OldCoreData->HeapOffsetPositive);
|
||||
ConvertPpiPointers (SecCoreData, OldCoreData);
|
||||
|
||||
//
|
||||
// After the whole temporary memory is migrated, then we can allocate page in
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** @file
|
||||
EFI PEI Core PPI services
|
||||
|
||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
|
||||
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
|
||||
|
@ -40,44 +40,44 @@ InitializePpiServices (
|
|||
|
||||
Migrate the Hob list from the temporary memory stack 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 FixupPositive TRUE if new Hob list is above the old Hob list.
|
||||
Otherwise FALSE.
|
||||
@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 UINTN Fixup,
|
||||
IN BOOLEAN FixupPositive
|
||||
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
||||
IN PEI_CORE_INSTANCE *PrivateData
|
||||
)
|
||||
{
|
||||
UINT8 Index;
|
||||
PEI_PPI_LIST_POINTERS *PpiPointer;
|
||||
UINTN OldHeapTop;
|
||||
UINTN OldHeapBottom;
|
||||
UINTN OldStackTop;
|
||||
UINTN OldStackBottom;
|
||||
|
||||
OldHeapBottom = (UINTN)SecCoreData->PeiTemporaryRamBase;
|
||||
OldHeapTop = (UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize;
|
||||
OldStackBottom = (UINTN)SecCoreData->StackBase;
|
||||
OldStackTop = (UINTN)SecCoreData->StackBase + SecCoreData->StackSize;
|
||||
|
||||
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)) {
|
||||
if (((UINTN)PpiPointer->Raw < OldHeapTop) &&
|
||||
((UINTN)PpiPointer->Raw >= OldHeapBottom)) {
|
||||
//
|
||||
// Convert the pointer to the PEIM descriptor from the old HOB heap
|
||||
// Convert the pointer to the PPI descriptor from the old HOB heap
|
||||
// to the relocated HOB heap.
|
||||
//
|
||||
if (FixupPositive) {
|
||||
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Fixup);
|
||||
if (PrivateData->HeapOffsetPositive) {
|
||||
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + PrivateData->HeapOffset);
|
||||
} else {
|
||||
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - Fixup);
|
||||
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - PrivateData->HeapOffset);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -85,16 +85,16 @@ ConvertPpiPointers (
|
|||
// to try to convert the pointers in the PEIM descriptor
|
||||
//
|
||||
|
||||
if (((UINTN)PpiPointer->Ppi->Guid < OldCheckingTop) &&
|
||||
((UINTN)PpiPointer->Ppi->Guid >= OldCheckingBottom)) {
|
||||
if (((UINTN)PpiPointer->Ppi->Guid < OldHeapTop) &&
|
||||
((UINTN)PpiPointer->Ppi->Guid >= OldHeapBottom)) {
|
||||
//
|
||||
// Convert the pointer to the GUID in the PPI or NOTIFY descriptor
|
||||
// from the old HOB heap to the relocated HOB heap.
|
||||
//
|
||||
if (FixupPositive) {
|
||||
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Fixup);
|
||||
if (PrivateData->HeapOffsetPositive) {
|
||||
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + PrivateData->HeapOffset);
|
||||
} else {
|
||||
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - Fixup);
|
||||
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - PrivateData->HeapOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,18 +103,28 @@ ConvertPpiPointers (
|
|||
// 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) {
|
||||
(UINTN)PpiPointer->Ppi->Ppi < OldHeapTop &&
|
||||
(UINTN)PpiPointer->Ppi->Ppi >= OldHeapBottom) {
|
||||
//
|
||||
// Convert the pointer to the PPI interface structure in the PPI descriptor
|
||||
// from the old HOB heap to the relocated HOB heap.
|
||||
//
|
||||
if (FixupPositive) {
|
||||
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + Fixup);
|
||||
if (PrivateData->HeapOffsetPositive) {
|
||||
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + PrivateData->HeapOffset);
|
||||
} else {
|
||||
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - Fixup);
|
||||
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - PrivateData->HeapOffset);
|
||||
}
|
||||
}
|
||||
} else if (((UINTN)PpiPointer->Raw < OldStackTop) && ((UINTN)PpiPointer->Raw >= OldStackBottom)) {
|
||||
//
|
||||
// Convert the pointer to the PPI descriptor from the temporary stack
|
||||
// to the permanent PEI stack.
|
||||
//
|
||||
if (PrivateData->StackOffsetPositive) {
|
||||
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + PrivateData->StackOffset);
|
||||
} else {
|
||||
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - PrivateData->StackOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue