mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-31 01:24:12 +02:00
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;
|
StackOffsetPositive = FALSE;
|
||||||
StackOffset = (UINTN)(TopOfOldStack - TopOfNewStack);
|
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)));
|
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;
|
EFI_PHYSICAL_ADDRESS FreePhysicalMemoryTop;
|
||||||
UINTN HeapOffset;
|
UINTN HeapOffset;
|
||||||
BOOLEAN HeapOffsetPositive;
|
BOOLEAN HeapOffsetPositive;
|
||||||
|
UINTN StackOffset;
|
||||||
|
BOOLEAN StackOffsetPositive;
|
||||||
PEICORE_FUNCTION_POINTER ShadowedPeiCore;
|
PEICORE_FUNCTION_POINTER ShadowedPeiCore;
|
||||||
CACHE_SECTION_DATA CacheSection;
|
CACHE_SECTION_DATA CacheSection;
|
||||||
//
|
//
|
||||||
@ -377,24 +379,15 @@ InitializePpiServices (
|
|||||||
|
|
||||||
Migrate the Hob list from the temporary memory stack to PEI installed memory.
|
Migrate the Hob list from the temporary memory stack to PEI installed memory.
|
||||||
|
|
||||||
@param PrivateData Pointer to PeiCore's private data structure.
|
@param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
|
||||||
@param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range
|
and location of temporary RAM, the stack location and the BFV location.
|
||||||
will be fixup for PpiData and PpiDescriptor pointer.
|
@param PrivateData Pointer to PeiCore's private data structure.
|
||||||
@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.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ConvertPpiPointers (
|
ConvertPpiPointers (
|
||||||
IN PEI_CORE_INSTANCE *PrivateData,
|
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
||||||
IN UINTN OldCheckingBottom,
|
IN PEI_CORE_INSTANCE *PrivateData
|
||||||
IN UINTN OldCheckingTop,
|
|
||||||
IN UINTN Fixup,
|
|
||||||
IN BOOLEAN FixupPositive
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Pei Core Main Entry Point
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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);
|
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
|
// After the whole temporary memory is migrated, then we can allocate page in
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
EFI PEI Core PPI services
|
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
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
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.
|
Migrate the Hob list from the temporary memory stack to PEI installed memory.
|
||||||
|
|
||||||
@param PrivateData Pointer to PeiCore's private data structure.
|
@param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
|
||||||
@param OldCheckingBottom Bottom of temporary memory range. All Ppi in this range
|
and location of temporary RAM, the stack location and the BFV location.
|
||||||
will be fixup for PpiData and PpiDescriptor pointer.
|
@param PrivateData Pointer to PeiCore's private data structure.
|
||||||
@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.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
ConvertPpiPointers (
|
ConvertPpiPointers (
|
||||||
IN PEI_CORE_INSTANCE *PrivateData,
|
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
||||||
IN UINTN OldCheckingBottom,
|
IN PEI_CORE_INSTANCE *PrivateData
|
||||||
IN UINTN OldCheckingTop,
|
|
||||||
IN UINTN Fixup,
|
|
||||||
IN BOOLEAN FixupPositive
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT8 Index;
|
UINT8 Index;
|
||||||
PEI_PPI_LIST_POINTERS *PpiPointer;
|
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++) {
|
for (Index = 0; Index < FixedPcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {
|
||||||
if (Index < PrivateData->PpiData.PpiListEnd ||
|
if (Index < PrivateData->PpiData.PpiListEnd ||
|
||||||
Index > PrivateData->PpiData.NotifyListEnd) {
|
Index > PrivateData->PpiData.NotifyListEnd) {
|
||||||
PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index];
|
PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index];
|
||||||
|
|
||||||
if (((UINTN)PpiPointer->Raw < OldCheckingTop) &&
|
if (((UINTN)PpiPointer->Raw < OldHeapTop) &&
|
||||||
((UINTN)PpiPointer->Raw >= OldCheckingBottom)) {
|
((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.
|
// to the relocated HOB heap.
|
||||||
//
|
//
|
||||||
if (FixupPositive) {
|
if (PrivateData->HeapOffsetPositive) {
|
||||||
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Fixup);
|
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + PrivateData->HeapOffset);
|
||||||
} else {
|
} 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
|
// to try to convert the pointers in the PEIM descriptor
|
||||||
//
|
//
|
||||||
|
|
||||||
if (((UINTN)PpiPointer->Ppi->Guid < OldCheckingTop) &&
|
if (((UINTN)PpiPointer->Ppi->Guid < OldHeapTop) &&
|
||||||
((UINTN)PpiPointer->Ppi->Guid >= OldCheckingBottom)) {
|
((UINTN)PpiPointer->Ppi->Guid >= OldHeapBottom)) {
|
||||||
//
|
//
|
||||||
// Convert the pointer to the GUID in the PPI or NOTIFY descriptor
|
// Convert the pointer to the GUID in the PPI or NOTIFY descriptor
|
||||||
// from the old HOB heap to the relocated HOB heap.
|
// from the old HOB heap to the relocated HOB heap.
|
||||||
//
|
//
|
||||||
if (FixupPositive) {
|
if (PrivateData->HeapOffsetPositive) {
|
||||||
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Fixup);
|
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + PrivateData->HeapOffset);
|
||||||
} else {
|
} 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.
|
// the notification function in the NOTIFY descriptor needs not be converted.
|
||||||
//
|
//
|
||||||
if (Index < PrivateData->PpiData.PpiListEnd &&
|
if (Index < PrivateData->PpiData.PpiListEnd &&
|
||||||
(UINTN)PpiPointer->Ppi->Ppi < OldCheckingTop &&
|
(UINTN)PpiPointer->Ppi->Ppi < OldHeapTop &&
|
||||||
(UINTN)PpiPointer->Ppi->Ppi >= OldCheckingBottom) {
|
(UINTN)PpiPointer->Ppi->Ppi >= OldHeapBottom) {
|
||||||
//
|
//
|
||||||
// Convert the pointer to the PPI interface structure in the PPI descriptor
|
// Convert the pointer to the PPI interface structure in the PPI descriptor
|
||||||
// from the old HOB heap to the relocated HOB heap.
|
// from the old HOB heap to the relocated HOB heap.
|
||||||
//
|
//
|
||||||
if (FixupPositive) {
|
if (PrivateData->HeapOffsetPositive) {
|
||||||
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + Fixup);
|
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + PrivateData->HeapOffset);
|
||||||
} else {
|
} 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…
x
Reference in New Issue
Block a user