diff options
Diffstat (limited to 'plat/arm/common/arm_topology.c')
-rw-r--r-- | plat/arm/common/arm_topology.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/plat/arm/common/arm_topology.c b/plat/arm/common/arm_topology.c index 94faa9f2..cb0bb9c9 100644 --- a/plat/arm/common/arm_topology.c +++ b/plat/arm/common/arm_topology.c @@ -30,35 +30,49 @@ #include <arch.h> #include <psci.h> +#include <plat_arm.h> #include <platform_def.h> -/* - * Weak definitions use fixed topology. Strong definitions could make topology - * configurable - */ -#pragma weak plat_get_aff_count -#pragma weak plat_get_aff_state -#pragma weak plat_arm_topology_setup - +#define get_arm_cluster_core_count(mpidr)\ + (((mpidr) & 0x100) ? PLAT_ARM_CLUSTER1_CORE_COUNT :\ + PLAT_ARM_CLUSTER0_CORE_COUNT) -unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr) -{ - /* Report 1 (absent) instance at levels higher that the cluster level */ - if (aff_lvl > MPIDR_AFFLVL1) - return 1; - - if (aff_lvl == MPIDR_AFFLVL1) - return ARM_CLUSTER_COUNT; +/* The power domain tree descriptor which need to be exported by ARM platforms */ +extern const unsigned char arm_power_domain_tree_desc[]; - return mpidr & 0x100 ? PLAT_ARM_CLUSTER1_CORE_COUNT : - PLAT_ARM_CLUSTER0_CORE_COUNT; -} -unsigned int plat_get_aff_state(unsigned int aff_lvl, unsigned long mpidr) +/******************************************************************************* + * This function returns the ARM default topology tree information. + ******************************************************************************/ +const unsigned char *plat_get_power_domain_tree_desc(void) { - return aff_lvl <= MPIDR_AFFLVL1 ? PSCI_AFF_PRESENT : PSCI_AFF_ABSENT; + return arm_power_domain_tree_desc; } -void plat_arm_topology_setup(void) +/******************************************************************************* + * This function validates an MPIDR by checking whether it falls within the + * acceptable bounds. An error code (-1) is returned if an incorrect mpidr + * is passed. + ******************************************************************************/ +int arm_check_mpidr(u_register_t mpidr) { + unsigned int cluster_id, cpu_id; + + mpidr &= MPIDR_AFFINITY_MASK; + + if (mpidr & ~(MPIDR_CLUSTER_MASK | MPIDR_CPU_MASK)) + return -1; + + cluster_id = (mpidr >> MPIDR_AFF1_SHIFT) & MPIDR_AFFLVL_MASK; + cpu_id = (mpidr >> MPIDR_AFF0_SHIFT) & MPIDR_AFFLVL_MASK; + + if (cluster_id >= ARM_CLUSTER_COUNT) + return -1; + + /* Validate cpu_id by checking whether it represents a CPU in + one of the two clusters present on the platform. */ + if (cpu_id >= get_arm_cluster_core_count(mpidr)) + return -1; + + return 0; } |