1/* 2 * Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7#ifndef PER_CPU_ASM_S 8#define PER_CPU_ASM_S 9 10#include <arch.h> 11#include <asm_macros.S> 12#include <lib/per_cpu/per_cpu_defs.h> 13 14.globl per_cpu_base 15 16/* ----------------------------------------------------------------- 17 * Gets the per cpu base address for particular cpu. When NUMA awareness is 18 * enabled, it is the platforms responsibility to implement 19 * plat_per_cpu_base. 20 * 21 * This function would be called by asm and C routines. If NUMA awareness is 22 * enabled, care must be taken to preserve the clobber list. 23 * 24 * args - cpu in x0 25 * ret - per cpu base address in x0. 26 * ----------------------------------------------------------------- 27 */ 28func per_cpu_base 29#if PLATFORM_NODE_COUNT == 1 30 adr_l x1, __PER_CPU_START__ 31 /* x0 += r * __PER_CPU_UNIT_SECTION_SIZE__ */ 32 adr_l x2, __PER_CPU_UNIT_END__ 33 sub x2, x2, x1 34 madd x0, x2, x0, x1 35 ret 36#else 37 b plat_per_cpu_base 38 /* Intentionally using 'b' instead of 'bl' to avoid creating 39 * a return address. This saves the link register (LR) from being 40 * clobbered and reduces the clobber list in the calling context. 41 * Any future updates to append code after the branch would mean 42 * moving from the branch from "b" to "bl". 43 */ 44#endif 45endfunc per_cpu_base 46 47#endif /* PER_CPU_ASM_S*/ 48