From 2740a797df7ee56e4aa11fab46a8bc6ead91369f Mon Sep 17 00:00:00 2001 From: rsun3 Date: Tue, 20 Sep 2011 09:17:48 +0000 Subject: MdeModulePkg PeiMain: Enhance the PEI Core to convert GUID/PPI pointers pointing to somewhere in the temporary stack in PPI descriptors. Signed-off-by: rsun3 Reviewed-by: lzeng14 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12390 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Pei/Ppi/Ppi.c | 53 ++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/MdeModulePkg/Core/Pei/Ppi/Ppi.c b/MdeModulePkg/Core/Pei/Ppi/Ppi.c index 9129c23..6664b5b 100644 --- a/MdeModulePkg/Core/Pei/Ppi/Ppi.c +++ b/MdeModulePkg/Core/Pei/Ppi/Ppi.c @@ -105,15 +105,15 @@ ConvertPpiPointers ( if (Index < PrivateData->PpiData.PpiListEnd && (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 (PrivateData->HeapOffsetPositive) { - PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + PrivateData->HeapOffset); - } else { - PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - PrivateData->HeapOffset); - } + // + // Convert the pointer to the PPI interface structure in the PPI descriptor + // from the old HOB heap to the relocated HOB heap. + // + if (PrivateData->HeapOffsetPositive) { + PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + PrivateData->HeapOffset); + } else { + PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - PrivateData->HeapOffset); + } } } else if (((UINTN)PpiPointer->Raw < OldStackTop) && ((UINTN)PpiPointer->Raw >= OldStackBottom)) { // @@ -125,6 +125,41 @@ ConvertPpiPointers ( } else { PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - PrivateData->StackOffset); } + + // + // Try to convert the pointers in the PEIM descriptor + // + + if (((UINTN)PpiPointer->Ppi->Guid < OldStackTop) && + ((UINTN)PpiPointer->Ppi->Guid >= OldStackBottom)) { + // + // Convert the pointer to the GUID in the PPI or NOTIFY descriptor + // from the the temporary stack to the permanent PEI stack. + // + if (PrivateData->StackOffsetPositive) { + PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + PrivateData->StackOffset); + } else { + PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - PrivateData->StackOffset); + } + } + + // + // Assume that no code is located in the temporary memory, so the pointer to + // the notification function in the NOTIFY descriptor needs not be converted. + // + if (Index < PrivateData->PpiData.PpiListEnd && + (UINTN)PpiPointer->Ppi->Ppi < OldStackTop && + (UINTN)PpiPointer->Ppi->Ppi >= OldStackBottom) { + // + // Convert the pointer to the PPI interface structure in the PPI descriptor + // from the the temporary stack to the permanent PEI stack. + // + if (PrivateData->StackOffsetPositive) { + PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + PrivateData->StackOffset); + } else { + PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - PrivateData->StackOffset); + } + } } } } -- cgit v1.1