]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePeiCore/PrePeiCore.c
ArmPlatformPkg: Introduce ArmPlatformGlobalVariableLib
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / PrePeiCore.c
index 56186471fa2f31a5822acf89090260bb6abc34a1..a61d0b88575da4a5579331b7a59f3af80dd43b64 100644 (file)
 *\r
 **/\r
 \r
-#include <Library/DebugLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/IoLib.h>\r
 #include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugAgentLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/ArmLib.h>\r
 #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
+ARM_GLOBAL_VARIABLE_PPI             mGlobalVariablePpi = { PrePeiCoreGetGlobalVariableMemory };\r
 \r
-EFI_PEI_PPI_DESCRIPTOR      gSecPpiTable[] = {\r
+EFI_PEI_PPI_DESCRIPTOR      gCommonPpiTable[] = {\r
   {\r
-    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI,\r
     &gEfiTemporaryRamSupportPpiGuid,\r
     &mSecTemporaryRamSupportPpi\r
+  },\r
+  {\r
+    EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,\r
+    &gArmGlobalVariablePpiGuid,\r
+    &mGlobalVariablePpi\r
   }\r
 };\r
 \r
 VOID\r
 CEntryPoint (\r
-  IN  UINTN                     CoreId,\r
+  IN  UINTN                     MpId,\r
   IN  EFI_PEI_CORE_ENTRY_POINT  PeiCoreEntryPoint\r
   )\r
 {\r
@@ -63,11 +68,15 @@ CEntryPoint (
   //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(0 == CoreId) {\r
-    //Goto primary 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
+    // Goto primary Main.\r
     PrimaryMain (PeiCoreEntryPoint);\r
   } else {\r
-    SecondaryMain (CoreId);\r
+    SecondaryMain (MpId);\r
   }\r
 \r
   // PEI Core should always load and never return\r
@@ -94,6 +103,17 @@ SecTemporaryRamSupport (
 \r
   SecSwitchStack((UINTN)(PermanentMemoryBase - TemporaryMemoryBase));\r
 \r
+EFI_STATUS\r
+PrePeiCoreGetGlobalVariableMemory (\r
+  OUT EFI_PHYSICAL_ADDRESS    *GlobalVariableBase\r
+  )\r
+{\r
+  ASSERT (GlobalVariableBase != NULL);\r
+\r
+  *GlobalVariableBase = (UINTN)PcdGet32 (PcdCPUCoresStackBase) +\r
+                        (UINTN)PcdGet32 (PcdCPUCorePrimaryStackSize) -\r
+                        (UINTN)PcdGet32 (PcdPeiGlobalVariableSize);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r