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_MACROS_S 8#define PER_CPU_MACROS_S 9 10#include <arch.h> 11#include <asm_macros.S> 12#include <lib/per_cpu/per_cpu_defs.h> 13 14/* ----------------------------------------------------------------- 15 * per_cpu_cur <label>, <dst>, <clobber> 16 * Returns: <dst> = per-CPU address of <label> 17 * Clobbers: <dst> and <clobber> 18 * 19 * Defaults: dst=x0, clobber=x1 20 * ----------------------------------------------------------------- */ 21.macro per_cpu_cur label, dst=x0, clobber=x1 22 /* Safety checks */ 23 .ifc \dst,\clobber 24 .error "per_cpu_cur: dst and clobber must be different" 25 .endif 26 27 /* dst = absolute address of label */ 28 adr_l \dst, \label 29 30 /* clobber = absolute address of __PER_CPU_START__ */ 31 adr_l \clobber, __PER_CPU_START__ 32 33 /* dst = (label - __PER_CPU_START__) */ 34 sub \dst, \dst, \clobber 35 36 /* clobber = per-cpu base (TPIDR_EL3) */ 37 mrs \clobber, tpidr_el3 38 39 /* dst = base + offset */ 40 add \dst, \clobber, \dst 41.endm 42 43/* ----------------------------------------------------------------- 44 * Populates tpidr_el3 with cpu specific per cpu section's 45 * offset address. 46 * Clobbers: x0 - x3 47 * ----------------------------------------------------------------- 48 */ 49.macro per_cpu_init 50 bl plat_my_core_pos 51 bl per_cpu_base 52 /* Update tpidr_el3 with offset */ 53 msr tpidr_el3, x0 54.endm 55 56#endif /* PER_CPU_MACROS_S */ 57