]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/ArmVExpressDxe: Identify the current platform
authorOlivier Martin <olivier.martin@arm.com>
Wed, 25 Feb 2015 19:14:26 +0000 (19:14 +0000)
committeroliviermartin <oliviermartin@Edk2>
Wed, 25 Feb 2015 19:14:26 +0000 (19:14 +0000)
Add a function to ArmVExpressDxe to identify the current platform we
are running on. This includes ARM32 and AArch64 models and hardware.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16931 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c [new file with mode: 0644]
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/Arm/ArmFvpDxeArm.c [new file with mode: 0644]
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.c
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmFvpDxe.inf
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.c
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmHwDxe.inf
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressCommon.c [new file with mode: 0644]
ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressInternal.h [new file with mode: 0644]
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSM.c
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/RTSMFoundation.c
ArmPlatformPkg/Include/Library/ArmPlatformLib.h

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/AArch64/ArmFvpDxeAArch64.c
new file mode 100644 (file)
index 0000000..2c7c5fa
--- /dev/null
@@ -0,0 +1,75 @@
+/** @file\r
+\r
+  Copyright (c) 2014-2015, ARM Ltd. All rights reserved.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "ArmVExpressInternal.h"\r
+\r
+//\r
+// Description of the two AARCH64 model platforms :\r
+// just the platform id for the time being.\r
+// Platform ids are defined in ArmVExpressInternal.h for\r
+// all "ArmVExpress-like" platforms (AARCH64 or ARM architecture,\r
+// model or hardware platforms).\r
+//\r
+CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[] = {\r
+  { ARM_FVP_VEXPRESS_AEMv8x4 },\r
+  { ARM_FVP_BASE_AEMv8x4_AEMv8x4 },\r
+  { ARM_FVP_FOUNDATION },\r
+  { ARM_FVP_VEXPRESS_UNKNOWN }\r
+};\r
+\r
+/**\r
+  Get information about the VExpress platform the firmware is running on.\r
+\r
+  @param[out]  Platform   Address where the pointer to the platform information\r
+                          (type ARM_VEXPRESS_PLATFORM*) should be stored.\r
+                          The returned pointer does not point to an allocated\r
+                          memory area.\r
+\r
+  @retval  EFI_SUCCESS    The platform information was returned.\r
+  @retval  EFI_NOT_FOUND  The platform was not recognised.\r
+\r
+**/\r
+EFI_STATUS\r
+ArmVExpressGetPlatform (\r
+  OUT CONST ARM_VEXPRESS_PLATFORM** Platform\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  UINT32                SysId;\r
+\r
+  ASSERT (Platform != NULL);\r
+\r
+  Status = EFI_NOT_FOUND;\r
+\r
+  SysId = MmioRead32 (ARM_VE_SYS_ID_REG);\r
+  if (SysId != ARM_RTSM_SYS_ID) {\r
+    // Take out the FVP GIC variant to reduce the permutations. The GIC driver\r
+    // detects the version and does the right thing.\r
+    SysId &= ~ARM_FVP_SYS_ID_VARIANT_MASK;\r
+    if (SysId == (ARM_FVP_BASE_SYS_ID & ~ARM_FVP_SYS_ID_VARIANT_MASK)) {\r
+      Status = ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4, Platform);\r
+    } else if (SysId == (ARM_FVP_FOUNDATION_SYS_ID & ~ARM_FVP_SYS_ID_VARIANT_MASK)) {\r
+      Status = ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION, Platform);\r
+    }\r
+  } else {\r
+    Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_AEMv8x4, Platform);\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "Unsupported AArch64 RTSM (SysId:0x%X).\n", SysId));\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return Status;\r
+}\r
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/Arm/ArmFvpDxeArm.c b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/Arm/ArmFvpDxeArm.c
new file mode 100644 (file)
index 0000000..7ac89ad
--- /dev/null
@@ -0,0 +1,85 @@
+/** @file\r
+\r
+  Copyright (c) 2014, ARM Ltd. All rights reserved.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "ArmVExpressInternal.h"\r
+#include <Library/ArmPlatformLib.h>  // To get Core Count\r
+\r
+//\r
+// Description of the four ARM model platforms :\r
+// just the platform id for the time being.\r
+// Platform ids are defined in ArmVExpressInternal.h for\r
+// all "ArmVExpress-like" platforms (AARCH64 or ARM architecture,\r
+// model or hardware platforms).\r
+//\r
+CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[] = {\r
+  { ARM_FVP_VEXPRESS_A9x4 },\r
+  { ARM_FVP_VEXPRESS_A15x1 },\r
+  { ARM_FVP_VEXPRESS_A15x2 },\r
+  { ARM_FVP_VEXPRESS_A15x4 },\r
+  { ARM_FVP_VEXPRESS_UNKNOWN }\r
+};\r
+\r
+/**\r
+  Get information about the VExpress platform the firmware is running on.\r
+\r
+  @param[out]  Platform   Address where the pointer to the platform information\r
+                          (type ARM_VEXPRESS_PLATFORM*) should be stored.\r
+                          The returned pointer does not point to an allocated\r
+                          memory area.\r
+\r
+  @retval  EFI_SUCCESS    The platform information was returned.\r
+  @retval  EFI_NOT_FOUND  The platform was not recognised.\r
+\r
+**/\r
+EFI_STATUS\r
+ArmVExpressGetPlatform (\r
+  OUT CONST ARM_VEXPRESS_PLATFORM** Platform\r
+  )\r
+{\r
+  UINT32                SysId;\r
+  UINTN                 CpuType;\r
+  EFI_STATUS            Status;\r
+  UINTN                 CoreCount;\r
+\r
+  ASSERT (Platform != NULL);\r
+\r
+  CpuType   = 0;\r
+  Status    = EFI_NOT_FOUND;\r
+  *Platform = NULL;\r
+\r
+  SysId = MmioRead32 (ARM_VE_SYS_ID_REG);\r
+  if (SysId == ARM_RTSM_SYS_ID) {\r
+    // Get the Cortex-A version\r
+    CpuType = (ArmReadMidr () >> 4) & ARM_CPU_TYPE_MASK;\r
+    if (CpuType == ARM_CPU_TYPE_A9) {\r
+      Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A9x4, Platform);\r
+    } else if (CpuType == ARM_CPU_TYPE_A15) {\r
+      CoreCount = ArmGetCpuCountPerCluster ();\r
+      if (CoreCount == 1) {\r
+        Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A15x1, Platform);\r
+      } else if (CoreCount == 2) {\r
+        Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A15x2, Platform);\r
+      } else if (CoreCount == 4) {\r
+        Status = ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_A15x4, Platform);\r
+      }\r
+    }\r
+  }\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "Unsupported platform (SysId:0x%X, CpuType:0x%X)\n", SysId, CpuType));\r
+    ASSERT_EFI_ERROR (Status);\r
+  }\r
+\r
+  return Status;\r
+}\r
index 64e4158053d68b4b8f6de05e954ea20f8eaa6b8e..6a3d3503824c552a596b1b785c42dcb65ff0ec34 100644 (file)
 \r
 **/\r
 \r
-#include <Library/UefiLib.h>\r
+#include "ArmVExpressInternal.h"\r
+\r
 #include <Library/VirtioMmioDeviceLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/ArmShellCmdLib.h>\r
 \r
 #define ARM_FVP_BASE_VIRTIO_BLOCK_BASE    0x1c130000\r
index 7112144095125f7b3607e217761cbf65d9827023..8a096baae28301e1ac5e635b3fd7987a1a56ba29 100644 (file)
 \r
 [Sources.common]\r
   ArmFvpDxe.c\r
+  ArmVExpressCommon.c\r
+\r
+[Sources.ARM]\r
+  Arm/ArmFvpDxeArm.c\r
+\r
+[Sources.AARCH64]\r
+  AArch64/ArmFvpDxeAArch64.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
+  ArmPkg/ArmPkg.dec\r
   ArmPlatformPkg/ArmPlatformPkg.dec\r
+  ArmPlatformPkg/ArmVExpressPkg/ArmVExpressPkg.dec\r
   OvmfPkg/OvmfPkg.dec\r
 \r
 [LibraryClasses]\r
   ArmShellCmdRunAxfLib\r
+  ArmLib\r
+  ArmPlatformLib\r
+  BaseMemoryLib\r
   UefiDriverEntryPoint\r
   UefiBootServicesTableLib\r
   VirtioMmioDeviceLib\r
-  BaseMemoryLib\r
index 7ed5c610593e405dbdf8e605b6e50e37075d5c1e..66ec9963ca82b7c5bd1dd23b50d561a0db6f83be 100644 (file)
 \r
 **/\r
 \r
-#include <Library/UefiLib.h>\r
-#include <Library/DebugLib.h>\r
+#include "ArmVExpressInternal.h"\r
 #include <Library/ArmShellCmdLib.h>\r
 \r
+//\r
+// Description of the four hardware platforms :\r
+// just the platform id for the time being.\r
+// Platform ids are defined in ArmVExpressInternal.h for\r
+// all "ArmVExpress-like" platforms (AARCH64 or ARM architecture,\r
+// model or hardware platforms).\r
+//\r
+CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[] = {\r
+  { ARM_HW_A9x4 },\r
+  { ARM_HW_A15x2_A7x3 },\r
+  { ARM_HW_A15 },\r
+  { ARM_HW_A5 },\r
+  { ARM_FVP_VEXPRESS_UNKNOWN }\r
+};\r
+\r
+/**\r
+  Get information about the VExpress platform the firmware is running on.\r
+\r
+  @param[out]  Platform   Address where the pointer to the platform information\r
+                          (type ARM_VEXPRESS_PLATFORM*) should be stored.\r
+                          The returned pointer does not point to an allocated\r
+                          memory area. Not used here.\r
+\r
+  @retval  EFI_NOT_FOUND  The platform was not recognised.\r
+\r
+**/\r
+EFI_STATUS\r
+ArmVExpressGetPlatform (\r
+  OUT CONST ARM_VEXPRESS_PLATFORM** Platform\r
+  )\r
+{\r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
 EFI_STATUS\r
 EFIAPI\r
 ArmHwInitialise (\r
index 3bcdbd06fbac4eff2e471eb7e3dd1d43ff84064c..92a193f8a0705bd3e3e560f9a754cc9e33c33c3e 100644 (file)
 \r
 [Sources.common]\r
   ArmHwDxe.c\r
+  ArmVExpressCommon.c\r
 \r
 [Packages]\r
-  MdePkg/MdePkg.dec\r
+  ArmPkg/ArmPkg.dec\r
   ArmPlatformPkg/ArmPlatformPkg.dec\r
+  MdePkg/MdePkg.dec\r
 \r
 [LibraryClasses]\r
   ArmShellCmdRunAxfLib\r
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressCommon.c b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressCommon.c
new file mode 100644 (file)
index 0000000..e1cac7f
--- /dev/null
@@ -0,0 +1,48 @@
+/** @file\r
+\r
+  Copyright (c) 2014, ARM Ltd. All rights reserved.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "ArmVExpressInternal.h"\r
+\r
+/**\r
+  Get information about the VExpress platform the firmware is running on given its Id.\r
+\r
+  @param[in]   PlatformId  Id of the VExpress platform.\r
+  @param[out]  Platform    Address where the pointer to the platform information\r
+                           (type ARM_VEXPRESS_PLATFORM*) should be stored.\r
+                           The returned pointer does not point to an allocated\r
+                           memory area.\r
+\r
+  @retval  EFI_SUCCESS    The platform information was returned.\r
+  @retval  EFI_NOT_FOUND  The platform was not recognised.\r
+\r
+**/\r
+EFI_STATUS\r
+ArmVExpressGetPlatformFromId (\r
+  IN  CONST ARM_VEXPRESS_PLATFORM_ID PlatformId,\r
+  OUT CONST ARM_VEXPRESS_PLATFORM**  Platform\r
+  )\r
+{\r
+  UINTN Index;\r
+\r
+  ASSERT (Platform != NULL);\r
+\r
+  for (Index = 0; ArmVExpressPlatforms[Index].Id != ARM_FVP_VEXPRESS_UNKNOWN; Index++) {\r
+    if (ArmVExpressPlatforms[Index].Id == PlatformId) {\r
+      *Platform = &ArmVExpressPlatforms[Index];\r
+      return EFI_SUCCESS;\r
+    }\r
+  }\r
+\r
+  return EFI_NOT_FOUND;\r
+}\r
diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressInternal.h b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpressDxe/ArmVExpressInternal.h
new file mode 100644 (file)
index 0000000..2e93350
--- /dev/null
@@ -0,0 +1,92 @@
+/** @file\r
+\r
+  Copyright (c) 2014, ARM Ltd. All rights reserved.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __ARM_VEXPRESS_INTERNAL_H__\r
+#define __ARM_VEXPRESS_INTERNAL_H__\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Library/ArmLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiLib.h>\r
+\r
+#include <VExpressMotherBoard.h>\r
+\r
+// This 'enum' is needed as variations based on existing platform exist\r
+typedef enum {\r
+  ARM_FVP_VEXPRESS_UNKNOWN = 0,\r
+  ARM_FVP_VEXPRESS_A9x4,\r
+  ARM_FVP_VEXPRESS_A15x1,\r
+  ARM_FVP_VEXPRESS_A15x2,\r
+  ARM_FVP_VEXPRESS_A15x4,\r
+  ARM_FVP_VEXPRESS_A15x1_A7x1,\r
+  ARM_FVP_VEXPRESS_A15x4_A7x4,\r
+  ARM_FVP_VEXPRESS_AEMv8x4,\r
+  ARM_FVP_BASE_AEMv8x4_AEMv8x4,\r
+  ARM_FVP_FOUNDATION,\r
+  ARM_HW_A9x4,\r
+  ARM_HW_A15x2_A7x3,\r
+  ARM_HW_A15,\r
+  ARM_HW_A5\r
+} ARM_VEXPRESS_PLATFORM_ID;\r
+\r
+typedef struct {\r
+  ARM_VEXPRESS_PLATFORM_ID  Id;\r
+  // Will be extended with platform specific information\r
+} ARM_VEXPRESS_PLATFORM;\r
+\r
+// Array that contains the list of the VExpress based platform supported by this DXE driver\r
+extern CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms[];\r
+\r
+/**\r
+  Get information about the VExpress platform the firmware is running on given its Id.\r
+\r
+  @param[in]   PlatformId  Id of the VExpress platform.\r
+  @param[out]  Platform    Address where the pointer to the platform information\r
+                           (type ARM_VEXPRESS_PLATFORM*) should be stored.\r
+                           The returned pointer does not point to an allocated\r
+                           memory area.\r
+\r
+  @retval  EFI_SUCCESS    The platform information was returned.\r
+  @retval  EFI_NOT_FOUND  The platform was not recognised.\r
+\r
+**/\r
+EFI_STATUS\r
+ArmVExpressGetPlatformFromId (\r
+  IN  CONST ARM_VEXPRESS_PLATFORM_ID PlatformId,\r
+  OUT CONST ARM_VEXPRESS_PLATFORM**  Platform\r
+  );\r
+\r
+/**\r
+\r
+  Get information about the VExpress platform the firmware is running on.\r
+\r
+  @param[out]  Platform   Address where the pointer to the platform information\r
+                          (type ARM_VEXPRESS_PLATFORM*) should be stored.\r
+                          The returned pointer does not point to an allocated\r
+                          memory area.\r
+\r
+  @retval  EFI_SUCCESS    The platform information was returned.\r
+  @retval  EFI_NOT_FOUND  The platform was not recognised.\r
+\r
+**/\r
+EFI_STATUS\r
+ArmVExpressGetPlatform (\r
+  OUT CONST ARM_VEXPRESS_PLATFORM** Platform\r
+  );\r
+\r
+#endif // __ARM_VEXPRESS_INTERNAL_H__\r
index ea73f6295694c12cfd475fb9944d047b77fe0c32..6ec512bfb709e6091c5a6a4aa9f829d4f9b93081 100644 (file)
 \r
 #include <ArmPlatform.h>\r
 \r
-UINTN\r
-ArmGetCpuCountPerCluster (\r
-  VOID\r
-  );\r
-\r
 ARM_CORE_INFO mVersatileExpressMpCoreInfoTable[] = {\r
   {\r
     // Cluster 0, Core 0\r
index 1b1671a86778ab2f54bec8f4cc7da1f63104d3e3..33bef8366d93e335c155a413ffead0d57c50748b 100644 (file)
 \r
 #include <ArmPlatform.h>\r
 \r
-\r
-UINTN\r
-ArmGetCpuCountPerCluster (\r
-  VOID\r
-  );\r
-\r
 ARM_CORE_INFO mVersatileExpressMpCoreInfoTable[] = {\r
   {\r
     // Cluster 0, Core 0\r
index 77561a3d05b3dcdafd2e8a27b6cdb87ec057afbf..fe3bc4bb8e6c7c4b99b12927e5db4dfa849f9397 100644 (file)
@@ -40,6 +40,19 @@ typedef struct {
   UINT64                       NumberOfBytes;\r
 } ARM_SYSTEM_MEMORY_REGION_DESCRIPTOR;\r
 \r
+/**\r
+  Return the core per cluster. The method may differ per core type\r
+\r
+  This function might be called from assembler before any stack is set.\r
+\r
+  @return   Return the core count per cluster\r
+\r
+**/\r
+UINTN\r
+ArmGetCpuCountPerCluster (\r
+  VOID\r
+  );\r
+\r
 /**\r
   Return the core position from the value of its MpId register\r
 \r