3 Copyright (c) 2014-2015, ARM Ltd. All rights reserved.
5 This program and the accompanying materials are licensed and made available
6 under the terms and conditions of the BSD License which accompanies this
7 distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
11 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "ArmVExpressInternal.h"
16 #include <Library/ArmGicLib.h>
19 // Description of the AARCH64 model platforms :
20 // Platform ids are defined in ArmVExpressInternal.h for
21 // all "ArmVExpress-like" platforms (AARCH64 or ARM architecture,
22 // model or hardware platforms).
24 CONST ARM_VEXPRESS_PLATFORM ArmVExpressPlatforms
[] = {
25 { ARM_FVP_VEXPRESS_AEMv8x4
, FixedPcdGetPtr (PcdFdtFvpVExpressAEMv8x4
), L
"rtsm_ve-aemv8a.dtb" },
26 { ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2
, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4GicV2
), L
"fvp-base-gicv2-psci.dtb" },
27 { ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2_LEGACY
, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4GicV2Legacy
), L
"fvp-base-gicv2legacy-psci.dtb" },
28 { ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV3
, FixedPcdGetPtr (PcdFdtFvpBaseAEMv8x4GicV3
), L
"fvp-base-gicv3-psci.dtb" },
29 { ARM_FVP_FOUNDATION_GICV2
, FixedPcdGetPtr (PcdFdtFvpFoundationGicV2
), L
"fvp-foundation-gicv2-psci.dtb" },
30 { ARM_FVP_FOUNDATION_GICV2_LEGACY
, FixedPcdGetPtr (PcdFdtFvpFoundationGicV2Legacy
), L
"fvp-foundation-gicv2legacy-psci.dtb" },
31 { ARM_FVP_FOUNDATION_GICV3
, FixedPcdGetPtr (PcdFdtFvpFoundationGicV3
), L
"fvp-foundation-gicv3-psci.dtb" },
32 { ARM_FVP_VEXPRESS_UNKNOWN
}
36 Get information about the VExpress platform the firmware is running on.
38 @param[out] Platform Address where the pointer to the platform information
39 (type ARM_VEXPRESS_PLATFORM*) should be stored.
40 The returned pointer does not point to an allocated
43 @retval EFI_SUCCESS The platform information was returned.
44 @retval EFI_NOT_FOUND The platform was not recognised.
48 ArmVExpressGetPlatform (
49 OUT CONST ARM_VEXPRESS_PLATFORM
** Platform
56 ARM_GIC_ARCH_REVISION GicRevision
;
58 ASSERT (Platform
!= NULL
);
60 Status
= EFI_NOT_FOUND
;
62 SysId
= MmioRead32 (ARM_VE_SYS_ID_REG
);
63 if (SysId
!= ARM_RTSM_SYS_ID
) {
64 // Remove the GIC variant to identify if we are running on the FVP Base or
66 FvpSysId
= SysId
& (ARM_FVP_SYS_ID_HBI_MASK
|
67 ARM_FVP_SYS_ID_PLAT_MASK
);
68 // Extract the variant from the SysId
69 VariantSysId
= SysId
& ARM_FVP_SYS_ID_VARIANT_MASK
;
71 if (FvpSysId
== ARM_FVP_BASE_BOARD_SYS_ID
) {
72 if (VariantSysId
== ARM_FVP_GIC_VE_MMAP
) {
73 // FVP Base Model with legacy GIC memory map
74 Status
= ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2_LEGACY
, Platform
);
76 GicRevision
= ArmGicGetSupportedArchRevision ();
78 if (GicRevision
== ARM_GIC_ARCH_REVISION_2
) {
79 // FVP Base Model with GICv2 support
80 Status
= ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2
, Platform
);
82 // FVP Base Model with GICv3 support
83 Status
= ArmVExpressGetPlatformFromId (ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV3
, Platform
);
86 } else if (FvpSysId
== ARM_FVP_FOUNDATION_BOARD_SYS_ID
) {
87 if (VariantSysId
== ARM_FVP_GIC_VE_MMAP
) {
88 // FVP Foundation Model with legacy GIC memory map
89 Status
= ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION_GICV2_LEGACY
, Platform
);
91 GicRevision
= ArmGicGetSupportedArchRevision ();
93 if (GicRevision
== ARM_GIC_ARCH_REVISION_2
) {
94 // FVP Foundation Model with GICv2
95 Status
= ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION_GICV2
, Platform
);
97 // FVP Foundation Model with GICv3
98 Status
= ArmVExpressGetPlatformFromId (ARM_FVP_FOUNDATION_GICV3
, Platform
);
103 // FVP Versatile Express AEMv8
104 Status
= ArmVExpressGetPlatformFromId (ARM_FVP_VEXPRESS_AEMv8x4
, Platform
);
107 if (EFI_ERROR (Status
)) {
108 DEBUG ((EFI_D_ERROR
, "Unsupported AArch64 RTSM (SysId:0x%X).\n", SysId
));
109 ASSERT_EFI_ERROR (Status
);