summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-15 06:48:20 +0000
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-15 06:48:20 +0000
commit424b7c9f8f0b1587210de67baaee235288380c6a (patch)
tree7fd3d690bb9127059fd5d6ebd54299c9772bdd98 /MdeModulePkg
parenta9292c1363437b081ea72fd8f3b2ed075e2a7ef3 (diff)
downloadedk2-424b7c9f8f0b1587210de67baaee235288380c6a.zip
edk2-424b7c9f8f0b1587210de67baaee235288380c6a.tar.gz
edk2-424b7c9f8f0b1587210de67baaee235288380c6a.tar.bz2
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
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c2
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain.h21
-rw-r--r--MdeModulePkg/Core/Pei/PeiMain/PeiMain.c6
-rw-r--r--MdeModulePkg/Core/Pei/Ppi/Ppi.c72
4 files changed, 53 insertions, 48 deletions
diff --git a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
index f29c4c2..c7f0f8a 100644
--- a/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
+++ b/MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
@@ -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)));
diff --git a/MdeModulePkg/Core/Pei/PeiMain.h b/MdeModulePkg/Core/Pei/PeiMain.h
index 48f3bc3..ec6d6e1 100644
--- a/MdeModulePkg/Core/Pei/PeiMain.h
+++ b/MdeModulePkg/Core/Pei/PeiMain.h
@@ -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
);
/**
diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 0c0b270..2f63e4c 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -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
diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
index 65dc5be..9129c23 100644
--- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c
+++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c
@@ -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);
+ }
}
}
}