1/* 2 * Copyright (c) 2024, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7#include <arch.h> 8#include <asm_macros.S> 9#include <platform_def.h> 10 11 .globl plat_arm_calc_core_pos 12 13 /* --------------------------------------------------------------------- 14 * unsigned int plat_arm_calc_core_pos(u_register_t mpidr) 15 * 16 * Function to calculate the core position on rd1ae. 17 * 18 * (ClusterId * PLAT_MAX_CPUS_PER_CLUSTER * PLAT_MAX_PE_PER_CPU) + 19 * (CPUId * PLAT_MAX_PE_PER_CPU) + 20 * ThreadId 21 * 22 * which can be simplified as: 23 * 24 * ((ClusterId * PLAT_MAX_CPUS_PER_CLUSTER + CPUId) * PLAT_MAX_PE_PER_CPU) 25 * + ThreadId 26 * --------------------------------------------------------------------- 27 */ 28func plat_arm_calc_core_pos 29 mov x4, x0 30 31 /* Extract individual affinity fields from MPIDR */ 32 ubfx x0, x4, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS 33 ubfx x1, x4, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS 34 ubfx x2, x4, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS 35 ubfx x3, x4, #MPIDR_AFF3_SHIFT, #MPIDR_AFFINITY_BITS 36 37 /* Compute linear position */ 38 mov x4, #PLAT_ARM_CLUSTER_COUNT 39 madd x2, x3, x4, x2 40 mov x4, #PLAT_MAX_CPUS_PER_CLUSTER 41 madd x1, x2, x4, x1 42 mov x4, #PLAT_MAX_PE_PER_CPU 43 madd x0, x1, x4, x0 44 ret 45endfunc plat_arm_calc_core_pos 46