1 /* 2 * Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <arch_helpers.h> 8 #include <lib/per_cpu/per_cpu.h> 9 10 __pure void *per_cpu_by_index_compute(uint32_t cpu, const void *addr) 11 { 12 const char *cpu_base; 13 #ifndef __aarch64__ 14 cpu_base = ((const char *)PER_CPU_START + 15 ((cpu) * (PER_CPU_UNIT_SIZE))); 16 17 #else 18 cpu_base = per_cpu_base(cpu); 19 #endif 20 return (void *)(cpu_base + PER_CPU_OFFSET(addr)); 21 } 22 23 __pure void *per_cpu_cur_compute(const void *addr) 24 { 25 #ifndef __aarch64__ 26 return (per_cpu_by_index_compute(plat_my_core_pos(), addr)); 27 #else 28 return (void *)((read_tpidr_el3() + PER_CPU_OFFSET(addr))); 29 #endif 30 } 31 32