#include <Library/SerialPortLib.h>\r
\r
#include <Ppi/ArmGlobalVariable.h>\r
-#include <Chipset/ArmV7.h>\r
\r
#include "PrePeiCore.h"\r
\r
-EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};\r
+EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mTemporaryRamSupportPpi = { PrePeiCoreTemporaryRamSupport };\r
ARM_GLOBAL_VARIABLE_PPI mGlobalVariablePpi = { PrePeiCoreGetGlobalVariableMemory };\r
\r
EFI_PEI_PPI_DESCRIPTOR gCommonPpiTable[] = {\r
{\r
EFI_PEI_PPI_DESCRIPTOR_PPI,\r
&gEfiTemporaryRamSupportPpiGuid,\r
- &mSecTemporaryRamSupportPpi\r
+ &mTemporaryRamSupportPpi\r
},\r
{\r
- EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+ EFI_PEI_PPI_DESCRIPTOR_PPI,\r
&gArmGlobalVariablePpiGuid,\r
&mGlobalVariablePpi\r
}\r
};\r
\r
+VOID\r
+CreatePpiList (\r
+ OUT UINTN *PpiListSize,\r
+ OUT EFI_PEI_PPI_DESCRIPTOR **PpiList\r
+ )\r
+{\r
+ EFI_PEI_PPI_DESCRIPTOR *PlatformPpiList;\r
+ UINTN PlatformPpiListSize;\r
+ UINTN ListBase;\r
+ EFI_PEI_PPI_DESCRIPTOR *LastPpi;\r
+\r
+ // Get the Platform PPIs\r
+ PlatformPpiListSize = 0;\r
+ ArmPlatformGetPlatformPpiList (&PlatformPpiListSize, &PlatformPpiList);\r
+\r
+ // Copy the Common and Platform PPis in Temporrary Memory\r
+ ListBase = PcdGet32 (PcdCPUCoresStackBase);\r
+ CopyMem ((VOID*)ListBase, gCommonPpiTable, sizeof(gCommonPpiTable));\r
+ CopyMem ((VOID*)(ListBase + sizeof(gCommonPpiTable)), PlatformPpiList, PlatformPpiListSize);\r
+\r
+ // Set the Terminate flag on the last PPI entry\r
+ LastPpi = (EFI_PEI_PPI_DESCRIPTOR*)ListBase + ((sizeof(gCommonPpiTable) + PlatformPpiListSize) / sizeof(EFI_PEI_PPI_DESCRIPTOR)) - 1;\r
+ LastPpi->Flags |= EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;\r
+\r
+ *PpiList = (EFI_PEI_PPI_DESCRIPTOR*)ListBase;\r
+ *PpiListSize = sizeof(gCommonPpiTable) + PlatformPpiListSize;\r
+}\r
+\r
VOID\r
CEntryPoint (\r
IN UINTN MpId,\r
\r
//Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on.\r
\r
- //If not primary Jump to Secondary Main\r
+ // If not primary Jump to Secondary Main\r
if (IS_PRIMARY_CORE(MpId)) {\r
// Initialize the Debug Agent for Source Level Debugging\r
InitializeDebugAgent (DEBUG_AGENT_INIT_POSTMEM_SEC, NULL, NULL);\r
SaveAndSetDebugTimerInterrupt (TRUE);\r
\r
+ // Initialize the platform specific controllers\r
+ ArmPlatformInitialize (MpId);\r
+\r
// Goto primary Main.\r
PrimaryMain (PeiCoreEntryPoint);\r
} else {\r
\r
EFI_STATUS\r
EFIAPI\r
-SecTemporaryRamSupport (\r
+PrePeiCoreTemporaryRamSupport (\r
IN CONST EFI_PEI_SERVICES **PeiServices,\r
IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,\r
IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,\r
IN UINTN CopySize\r
)\r
{\r
+ VOID *OldHeap;\r
+ VOID *NewHeap;\r
+ VOID *OldStack;\r
+ VOID *NewStack;\r
+\r
+ OldHeap = (VOID*)(UINTN)TemporaryMemoryBase;\r
+ NewHeap = (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1));\r
+\r
+ OldStack = (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1));\r
+ NewStack = (VOID*)(UINTN)PermanentMemoryBase;\r
+\r
//\r
- // Migrate the whole temporary memory to permenent memory.\r
+ // Migrate the temporary memory stack to permanent memory stack.\r
//\r
- CopyMem (\r
- (VOID*)(UINTN)PermanentMemoryBase, \r
- (VOID*)(UINTN)TemporaryMemoryBase, \r
- CopySize\r
- );\r
+ CopyMem (NewStack, OldStack, CopySize >> 1);\r
\r
- SecSwitchStack((UINTN)(PermanentMemoryBase - TemporaryMemoryBase));\r
+ //\r
+ // Migrate the temporary memory heap to permanent memory heap.\r
+ //\r
+ CopyMem (NewHeap, OldHeap, CopySize >> 1);\r
+ \r
+ SecSwitchStack ((UINTN)NewStack - (UINTN)OldStack);\r
+\r
+ return EFI_SUCCESS;\r
+}\r
\r
EFI_STATUS\r
PrePeiCoreGetGlobalVariableMemory (\r