--- /dev/null
+/** @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
--- /dev/null
+/** @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
\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
\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
\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
\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
--- /dev/null
+/** @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
--- /dev/null
+/** @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
\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
\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
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