]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/CpuPei/CpuPei.c
ArmPkg: Create MpCoreInfo PPI and HOB to describe CPU Cores on a MPCore platform
[mirror_edk2.git] / ArmPkg / Drivers / CpuPei / CpuPei.c
index bc01f306b928308e583480b3f98cc1cfe9316588..f358cb845a6660ca66e49325a290a4d08a6904c1 100755 (executable)
@@ -2,6 +2,8 @@
 \r
 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2011 Hewlett Packard Corporation. All rights reserved.<BR>\r
+Copyright (c) 2011, ARM Limited. All rights reserved.<BR>\r
+\r
 This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -29,12 +31,14 @@ Abstract:
 //\r
 // The protocols, PPI and GUID defintions for this module\r
 //\r
+#include <Ppi/ArmMpCoreInfo.h>\r
 \r
 //\r
 // The Library classes this module consumes\r
 //\r
 #include <Library/DebugLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
+#include <Library/PeiServicesLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/ArmLib.h>\r
@@ -54,7 +58,7 @@ FindMainMemory (
 {\r
   EFI_PEI_HOB_POINTERS      NextHob;\r
 \r
-  // look at the resource descriptor hobs, choose the first system memory one\r
+  // Look at the resource descriptor hobs, choose the first system memory one\r
   NextHob.Raw = GetHobList ();\r
   while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL) {\r
     if(NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY)\r
@@ -75,7 +79,7 @@ ConfigureMmu (
   VOID\r
   )\r
 {\r
-  EFI_STATUS                 Status;\r
+  EFI_STATUS                    Status;\r
   UINTN                         Idx;\r
   UINT32                        CacheAttributes;\r
   UINT32                        SystemMemoryBase;\r
@@ -99,7 +103,7 @@ ConfigureMmu (
 \r
   SystemMemoryLastAddress = SystemMemoryBase + (SystemMemoryLength-1);\r
 \r
-  // if system memory does not begin at 0\r
+  // If system memory does not begin at 0\r
   if(SystemMemoryBase > 0) {\r
     MemoryTable[Idx].PhysicalBase = 0;\r
     MemoryTable[Idx].VirtualBase  = 0;\r
@@ -114,7 +118,7 @@ ConfigureMmu (
   MemoryTable[Idx].Attributes   = (ARM_MEMORY_REGION_ATTRIBUTES)CacheAttributes;\r
   Idx++;\r
 \r
-  // if system memory does not go to the last address (0xFFFFFFFF)\r
+  // If system memory does not go to the last address (0xFFFFFFFF)\r
   if( SystemMemoryLastAddress < MAX_ADDRESS ) {\r
     MemoryTable[Idx].PhysicalBase = SystemMemoryLastAddress + 1;\r
     MemoryTable[Idx].VirtualBase  = MemoryTable[Idx].PhysicalBase;\r
@@ -138,13 +142,6 @@ ConfigureMmu (
   BuildMemoryAllocationHob((EFI_PHYSICAL_ADDRESS)(UINTN)TranslationTableBase, TranslationTableSize, EfiBootServicesData);\r
 }\r
 \r
-\r
-EFI_STATUS\r
-EFIAPI\r
-InitializeCpuPeim (\r
-  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
-  IN CONST EFI_PEI_SERVICES     **PeiServices\r
-  )\r
 /*++\r
 \r
 Routine Description:\r
@@ -161,14 +158,37 @@ Returns:
   Status -  EFI_SUCCESS if the boot mode could be set\r
 \r
 --*/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeCpuPeim (\r
+  IN       EFI_PEI_FILE_HANDLE  FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
 {\r
+  EFI_STATUS              Status;\r
+  ARM_MP_CORE_INFO_PPI    *ArmMpCoreInfoPpi;\r
+  UINTN                   ArmCoreCount;\r
+  ARM_CORE_INFO           *ArmCoreInfoTable;\r
+\r
   // Enable program flow prediction, if supported.\r
   ArmEnableBranchPrediction ();\r
 \r
-  // publish the CPU memory and io spaces sizes\r
+  // Publish the CPU memory and io spaces sizes\r
   BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));\r
 \r
-  ConfigureMmu();\r
+  //ConfigureMmu();\r
+\r
+  // Only MP Core platform need to produce gArmMpCoreInfoPpiGuid\r
+  Status = PeiServicesLocatePpi (&gArmMpCoreInfoPpiGuid, 0, NULL, (VOID**)&ArmMpCoreInfoPpi);\r
+  if (!EFI_ERROR(Status)) {\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
   return EFI_SUCCESS;\r
 }\r