\r
/**\r
\r
- Migrate Single PPI Pointer from the temporary memory to PEI installed memory.\r
+ Migrate Pointer from the temporary memory to PEI installed memory.\r
\r
- @param PpiPointer Pointer to Ppi\r
+ @param Pointer Pointer to the Pointer needs to be converted.\r
@param TempBottom Base of old temporary memory\r
@param TempTop Top of old temporary memory\r
@param Offset Offset of new memory to old temporary memory.\r
\r
**/\r
VOID\r
-ConvertSinglePpiPointer (\r
- IN PEI_PPI_LIST_POINTERS *PpiPointer,\r
+ConvertPointer (\r
+ IN OUT VOID **Pointer,\r
IN UINTN TempBottom,\r
IN UINTN TempTop,\r
IN UINTN Offset,\r
IN BOOLEAN OffsetPositive\r
)\r
{\r
- if (((UINTN)PpiPointer->Raw < TempTop) &&\r
- ((UINTN)PpiPointer->Raw >= TempBottom)) {\r
- //\r
- // Convert the pointer to the PPI descriptor from the old TempRam\r
- // to the relocated physical memory.\r
- //\r
+ if (((UINTN) *Pointer < TempTop) &&\r
+ ((UINTN) *Pointer >= TempBottom)) {\r
if (OffsetPositive) {\r
- PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Offset);\r
+ *Pointer = (VOID *) ((UINTN) *Pointer + Offset);\r
} else {\r
- PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - Offset);\r
+ *Pointer = (VOID *) ((UINTN) *Pointer - Offset);\r
}\r
+ }\r
+}\r
\r
- //\r
- // Only when the PEIM descriptor is in the old TempRam should it be necessary\r
- // to try to convert the pointers in the PEIM descriptor\r
- //\r
+/**\r
\r
- if (((UINTN)PpiPointer->Ppi->Guid < TempTop) &&\r
- ((UINTN)PpiPointer->Ppi->Guid >= TempBottom)) {\r
- //\r
- // Convert the pointer to the GUID in the PPI or NOTIFY descriptor\r
- // from the old TempRam to the relocated physical memory.\r
- //\r
- if (OffsetPositive) {\r
- PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Offset);\r
- } else {\r
- PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - Offset);\r
- }\r
- }\r
+ Migrate Pointer in ranges of the temporary memory to PEI installed memory.\r
+\r
+ @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
+ and location of temporary RAM, the stack location and the BFV location.\r
+ @param PrivateData Pointer to PeiCore's private data structure.\r
+ @param Pointer Pointer to the Pointer needs to be converted.\r
+\r
+**/\r
+VOID\r
+ConvertPointerInRanges (\r
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
+ IN PEI_CORE_INSTANCE *PrivateData,\r
+ IN OUT VOID **Pointer\r
+ )\r
+{\r
+ UINT8 IndexHole;\r
\r
+ if (PrivateData->MemoryPages.Size != 0) {\r
//\r
- // Convert the pointer to the PPI interface structure in the PPI descriptor\r
- // from the old TempRam to the relocated physical memory.\r
+ // Convert PPI pointer in old memory pages\r
+ // It needs to be done before Convert PPI pointer in old Heap\r
//\r
- if ((UINTN)PpiPointer->Ppi->Ppi < TempTop &&\r
- (UINTN)PpiPointer->Ppi->Ppi >= TempBottom) {\r
- if (OffsetPositive) {\r
- PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + Offset);\r
- } else {\r
- PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - Offset);\r
- }\r
+ ConvertPointer (\r
+ Pointer,\r
+ (UINTN)PrivateData->MemoryPages.Base,\r
+ (UINTN)PrivateData->MemoryPages.Base + PrivateData->MemoryPages.Size,\r
+ PrivateData->MemoryPages.Offset,\r
+ PrivateData->MemoryPages.OffsetPositive\r
+ );\r
+ }\r
+\r
+ //\r
+ // Convert PPI pointer in old Heap\r
+ //\r
+ ConvertPointer (\r
+ Pointer,\r
+ (UINTN)SecCoreData->PeiTemporaryRamBase,\r
+ (UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize,\r
+ PrivateData->HeapOffset,\r
+ PrivateData->HeapOffsetPositive\r
+ );\r
+\r
+ //\r
+ // Convert PPI pointer in old Stack\r
+ //\r
+ ConvertPointer (\r
+ Pointer,\r
+ (UINTN)SecCoreData->StackBase,\r
+ (UINTN)SecCoreData->StackBase + SecCoreData->StackSize,\r
+ PrivateData->StackOffset,\r
+ PrivateData->StackOffsetPositive\r
+ );\r
+\r
+ //\r
+ // Convert PPI pointer in old TempRam Hole\r
+ //\r
+ for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole ++) {\r
+ if (PrivateData->HoleData[IndexHole].Size == 0) {\r
+ continue;\r
}\r
+\r
+ ConvertPointer (\r
+ Pointer,\r
+ (UINTN)PrivateData->HoleData[IndexHole].Base,\r
+ (UINTN)PrivateData->HoleData[IndexHole].Base + PrivateData->HoleData[IndexHole].Size,\r
+ PrivateData->HoleData[IndexHole].Offset,\r
+ PrivateData->HoleData[IndexHole].OffsetPositive\r
+ );\r
}\r
}\r
\r
+/**\r
+\r
+ Migrate Single PPI Pointer from the temporary memory to PEI installed memory.\r
+\r
+ @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
+ and location of temporary RAM, the stack location and the BFV location.\r
+ @param PrivateData Pointer to PeiCore's private data structure.\r
+ @param PpiPointer Pointer to Ppi\r
+\r
+**/\r
+VOID\r
+ConvertSinglePpiPointer (\r
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,\r
+ IN PEI_CORE_INSTANCE *PrivateData,\r
+ IN PEI_PPI_LIST_POINTERS *PpiPointer\r
+ )\r
+{\r
+ //\r
+ // 1. Convert the pointer to the PPI descriptor from the old TempRam\r
+ // to the relocated physical memory.\r
+ // It (for the pointer to the PPI descriptor) needs to be done before 2 (for\r
+ // the pointer to the GUID) and 3 (for the pointer to the PPI interface structure).\r
+ //\r
+ ConvertPointerInRanges (SecCoreData, PrivateData, &PpiPointer->Raw);\r
+ //\r
+ // 2. Convert the pointer to the GUID in the PPI or NOTIFY descriptor\r
+ // from the old TempRam to the relocated physical memory.\r
+ //\r
+ ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **) &PpiPointer->Ppi->Guid);\r
+ //\r
+ // 3. Convert the pointer to the PPI interface structure in the PPI descriptor\r
+ // from the old TempRam to the relocated physical memory.\r
+ //\r
+ ConvertPointerInRanges (SecCoreData, PrivateData, (VOID **) &PpiPointer->Ppi->Ppi);\r
+}\r
+\r
/**\r
\r
Migrate PPI Pointers from the temporary memory to PEI installed memory.\r
\r
- @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size\r
+ @param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size \r
and location of temporary RAM, the stack location and the BFV location.\r
@param PrivateData Pointer to PeiCore's private data structure.\r
\r
)\r
{\r
UINT8 Index;\r
- UINT8 IndexHole;\r
\r
for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {\r
if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData->PpiData.NotifyListEnd) {\r
- if (PrivateData->MemoryPages.Size != 0) {\r
- //\r
- // Convert PPI pointer in old memory pages\r
- // It needs to be done before Convert PPI pointer in old Heap\r
- //\r
- ConvertSinglePpiPointer (\r
- &PrivateData->PpiData.PpiListPtrs[Index],\r
- (UINTN)PrivateData->MemoryPages.Base,\r
- (UINTN)PrivateData->MemoryPages.Base + PrivateData->MemoryPages.Size,\r
- PrivateData->MemoryPages.Offset,\r
- PrivateData->MemoryPages.OffsetPositive\r
- );\r
- }\r
-\r
- //\r
- // Convert PPI pointer in old Heap\r
- //\r
ConvertSinglePpiPointer (\r
- &PrivateData->PpiData.PpiListPtrs[Index],\r
- (UINTN)SecCoreData->PeiTemporaryRamBase,\r
- (UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize,\r
- PrivateData->HeapOffset,\r
- PrivateData->HeapOffsetPositive\r
- );\r
-\r
- //\r
- // Convert PPI pointer in old Stack\r
- //\r
- ConvertSinglePpiPointer (\r
- &PrivateData->PpiData.PpiListPtrs[Index],\r
- (UINTN)SecCoreData->StackBase,\r
- (UINTN)SecCoreData->StackBase + SecCoreData->StackSize,\r
- PrivateData->StackOffset,\r
- PrivateData->StackOffsetPositive\r
+ SecCoreData,\r
+ PrivateData,\r
+ &PrivateData->PpiData.PpiListPtrs[Index]\r
);\r
-\r
- //\r
- // Convert PPI pointer in old TempRam Hole\r
- //\r
- for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole ++) {\r
- if (PrivateData->HoleData[IndexHole].Size == 0) {\r
- continue;\r
- }\r
-\r
- ConvertSinglePpiPointer (\r
- &PrivateData->PpiData.PpiListPtrs[Index],\r
- (UINTN)PrivateData->HoleData[IndexHole].Base,\r
- (UINTN)PrivateData->HoleData[IndexHole].Base + PrivateData->HoleData[IndexHole].Size,\r
- PrivateData->HoleData[IndexHole].Offset,\r
- PrivateData->HoleData[IndexHole].OffsetPositive\r
- );\r
- }\r
}\r
}\r
}\r