]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePi/PrePi.c
Fix build failure.
[mirror_edk2.git] / ArmPlatformPkg / PrePi / PrePi.c
index 1d2cbcec5e8fb56ec2607477282396cd20f7a4b0..bdeb60d84c75420dd62261bb36fa760f2e017bb6 100755 (executable)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
@@ -14,7 +14,6 @@
 \r
 #include <PiPei.h>\r
 \r
-#include <Library/ArmCpuLib.h>\r
 #include <Library/DebugAgentLib.h>\r
 #include <Library/PrePiLib.h>\r
 #include <Library/PrintLib.h>\r
@@ -24,6 +23,7 @@
 #include <Library/PerformanceLib.h>\r
 \r
 #include <Ppi/GuidedSectionExtraction.h>\r
+#include <Ppi/ArmMpCoreInfo.h>\r
 #include <Guid/LzmaDecompress.h>\r
 #include <Guid/ArmGlobalVariableHob.h>\r
 \r
 // Not used when PrePi in run in XIP mode\r
 UINTN mGlobalVariableBase = 0;\r
 \r
-VOID\r
-PrePiCommonExceptionEntry (\r
-  IN UINT32 Entry,\r
-  IN UINT32 LR\r
-  );\r
-\r
 EFI_STATUS\r
 EFIAPI\r
 ExtractGuidedSectionLibConstructor (\r
@@ -71,6 +65,30 @@ BuildGlobalVariableHob (
   Hob->GlobalVariableSize = GlobalVariableSize;\r
 }\r
 \r
+EFI_STATUS\r
+GetPlatformPpi (\r
+  IN  EFI_GUID  *PpiGuid,\r
+  OUT VOID      **Ppi\r
+  )\r
+{\r
+  UINTN                   PpiListSize;\r
+  UINTN                   PpiListCount;\r
+  EFI_PEI_PPI_DESCRIPTOR  *PpiList;\r
+  UINTN                   Index;\r
+\r
+  PpiListSize = 0;\r
+  ArmPlatformGetPlatformPpiList (&PpiListSize, &PpiList);\r
+  PpiListCount = PpiListSize / sizeof(EFI_PEI_PPI_DESCRIPTOR);\r
+  for (Index = 0; Index < PpiListCount; Index++, PpiList++) {\r
+    if (CompareGuid (PpiList->Guid, PpiGuid) == TRUE) {\r
+      *Ppi = PpiList->Ppi;\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
 VOID\r
 PrePiMain (\r
   IN  UINTN                     UefiMemoryBase,\r
@@ -80,6 +98,9 @@ PrePiMain (
   )\r
 {\r
   EFI_HOB_HANDOFF_INFO_TABLE*   HobList;\r
+  ARM_MP_CORE_INFO_PPI*         ArmMpCoreInfoPpi;\r
+  UINTN                         ArmCoreCount;\r
+  ARM_CORE_INFO*                ArmCoreInfoTable;\r
   EFI_STATUS                    Status;\r
   CHAR8                         Buffer[100];\r
   UINTN                         CharCount;\r
@@ -99,7 +120,8 @@ PrePiMain (
 \r
   // Initialize the Serial Port\r
   SerialPortInitialize ();\r
-  CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware built at %a on %a\n\r",__TIME__, __DATE__);\r
+  CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",\r
+    (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);\r
   SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
 \r
   // Initialize the Debug Agent for Source Level Debugging\r
@@ -133,6 +155,22 @@ PrePiMain (
   //TODO: Call CpuPei as a library\r
   BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));\r
 \r
+  if (ArmIsMpCore ()) {\r
+    // Only MP Core platform need to produce gArmMpCoreInfoPpiGuid\r
+    Status = GetPlatformPpi (&gArmMpCoreInfoPpiGuid, (VOID**)&ArmMpCoreInfoPpi);\r
+\r
+    // On MP Core Platform we must implement the ARM MP Core Info PPI (gArmMpCoreInfoPpiGuid)\r
+    ASSERT_EFI_ERROR (Status);\r
+\r
+    // Build the MP Core Info Table\r
+    ArmCoreCount = 0;\r
+    Status = ArmMpCoreInfoPpi->GetMpCoreInfo (&ArmCoreCount, &ArmCoreInfoTable);\r
+    if (!EFI_ERROR(Status) && (ArmCoreCount > 0)) {\r
+      // Build MPCore Info HOB\r
+      BuildGuidDataHob (&gArmMpCoreInfoGuid, ArmCoreInfoTable, sizeof (ARM_CORE_INFO) * ArmCoreCount);\r
+    }\r
+  }\r
+\r
   // Set the Boot Mode\r
   SetBootMode (ArmPlatformGetBootMode ());\r
 \r
@@ -140,8 +178,6 @@ PrePiMain (
   Status = PlatformPeim ();\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  BuildMemoryTypeInformationHob ();\r
-\r
   // Now, the HOB List has been initialized, we can register performance information\r
   PERF_START (NULL, "PEI", NULL, StartTimeStamp);\r
 \r
@@ -176,6 +212,11 @@ CEntryPoint (
 {\r
   UINT64   StartTimeStamp;\r
  \r
+  ASSERT(!ArmIsMpCore() || (PcdGet32 (PcdCoreCount) > 1));\r
+\r
+  // Initialize the platform specific controllers\r
+  ArmPlatformInitialize (MpId);\r
+\r
   if (IS_PRIMARY_CORE(MpId) && PerformanceMeasurementEnabled ()) {\r
     // Initialize the Timer Library to setup the Timer HW controller\r
     TimerConstructor ();\r
@@ -201,17 +242,16 @@ CEntryPoint (
   if (!IS_XIP()) {\r
     if (IS_PRIMARY_CORE(MpId)) {\r
       mGlobalVariableBase = GlobalVariableBase;\r
-      ArmCpuSynchronizeSignal (ARM_CPU_EVENT_DEFAULT);\r
+      if (ArmIsMpCore()) {\r
+        // Signal the Global Variable Region is defined (event: ARM_CPU_EVENT_DEFAULT)\r
+        ArmCallSEV ();\r
+      }\r
     } else {\r
-         // Wait the Primay core has defined the address of the Global Variable region\r
-         ArmCpuSynchronizeWait (ARM_CPU_EVENT_DEFAULT);\r
+      // Wait the Primay core has defined the address of the Global Variable region (event: ARM_CPU_EVENT_DEFAULT)\r
+      ArmCallWFE ();\r
     }\r
   }\r
   \r
-  // Write VBAR - The Vector table must be 32-byte aligned\r
-  ASSERT (((UINT32)PrePiVectorTable & ((1 << 5)-1)) == 0);\r
-  ArmWriteVBar ((UINT32)PrePiVectorTable);\r
-\r
   // If not primary Jump to Secondary Main\r
   if (IS_PRIMARY_CORE(MpId)) {\r
     // Goto primary Main.\r
@@ -224,44 +264,3 @@ CEntryPoint (
   ASSERT (FALSE);\r
 }\r
 \r
-VOID\r
-PrePiCommonExceptionEntry (\r
-  IN UINT32 Entry,\r
-  IN UINT32 LR\r
-  )\r
-{\r
-  CHAR8           Buffer[100];\r
-  UINTN           CharCount;\r
-\r
-  switch (Entry) {\r
-  case 0:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reset Exception at 0x%X\n\r",LR);\r
-    break;\r
-  case 1:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Undefined Exception at 0x%X\n\r",LR);\r
-    break;\r
-  case 2:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"SWI Exception at 0x%X\n\r",LR);\r
-    break;\r
-  case 3:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"PrefetchAbort Exception at 0x%X\n\r",LR);\r
-    break;\r
-  case 4:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"DataAbort Exception at 0x%X\n\r",LR);\r
-    break;\r
-  case 5:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Reserved Exception at 0x%X\n\r",LR);\r
-    break;\r
-  case 6:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"IRQ Exception at 0x%X\n\r",LR);\r
-    break;\r
-  case 7:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"FIQ Exception at 0x%X\n\r",LR);\r
-    break;\r
-  default:\r
-    CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"Unknown Exception at 0x%X\n\r",LR);\r
-    break;\r
-  }\r
-  SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
-  while(1);\r
-}\r