1962958d3SRohit Mathew/* 2962958d3SRohit Mathew * Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. 3962958d3SRohit Mathew * 4962958d3SRohit Mathew * SPDX-License-Identifier: BSD-3-Clause 5962958d3SRohit Mathew */ 6962958d3SRohit Mathew 7962958d3SRohit Mathew#ifndef PER_CPU_MACROS_S 8962958d3SRohit Mathew#define PER_CPU_MACROS_S 9962958d3SRohit Mathew 10962958d3SRohit Mathew#include <arch.h> 11962958d3SRohit Mathew#include <asm_macros.S> 12962958d3SRohit Mathew#include <lib/per_cpu/per_cpu_defs.h> 13962958d3SRohit Mathew 14962958d3SRohit Mathew/* ----------------------------------------------------------------- 15962958d3SRohit Mathew * per_cpu_cur <label>, <dst>, <clobber> 16962958d3SRohit Mathew * Returns: <dst> = per-CPU address of <label> 17962958d3SRohit Mathew * Clobbers: <dst> and <clobber> 18962958d3SRohit Mathew * 19962958d3SRohit Mathew * Defaults: dst=x0, clobber=x1 20962958d3SRohit Mathew * ----------------------------------------------------------------- */ 21962958d3SRohit Mathew.macro per_cpu_cur label, dst=x0, clobber=x1 22962958d3SRohit Mathew /* Safety checks */ 23962958d3SRohit Mathew .ifc \dst,\clobber 24962958d3SRohit Mathew .error "per_cpu_cur: dst and clobber must be different" 25962958d3SRohit Mathew .endif 26962958d3SRohit Mathew 27962958d3SRohit Mathew /* dst = absolute address of label */ 28962958d3SRohit Mathew adr_l \dst, \label 29962958d3SRohit Mathew 30962958d3SRohit Mathew /* clobber = absolute address of __PER_CPU_START__ */ 31962958d3SRohit Mathew adr_l \clobber, __PER_CPU_START__ 32962958d3SRohit Mathew 33962958d3SRohit Mathew /* dst = (label - __PER_CPU_START__) */ 34962958d3SRohit Mathew sub \dst, \dst, \clobber 35962958d3SRohit Mathew 36962958d3SRohit Mathew /* clobber = per-cpu base (TPIDR_EL3) */ 37962958d3SRohit Mathew mrs \clobber, tpidr_el3 38962958d3SRohit Mathew 39962958d3SRohit Mathew /* dst = base + offset */ 40962958d3SRohit Mathew add \dst, \clobber, \dst 41962958d3SRohit Mathew.endm 42962958d3SRohit Mathew 43*98859b99SSammit Joshi/* ----------------------------------------------------------------- 44*98859b99SSammit Joshi * Populates tpidr_el3 with cpu specific per cpu section's 45*98859b99SSammit Joshi * offset address. 46*98859b99SSammit Joshi * Clobbers: x0 - x3 47*98859b99SSammit Joshi * ----------------------------------------------------------------- 48*98859b99SSammit Joshi */ 49*98859b99SSammit Joshi.macro per_cpu_init 50*98859b99SSammit Joshi bl plat_my_core_pos 51*98859b99SSammit Joshi bl per_cpu_base 52*98859b99SSammit Joshi /* Update tpidr_el3 with offset */ 53*98859b99SSammit Joshi msr tpidr_el3, x0 54*98859b99SSammit Joshi.endm 55*98859b99SSammit Joshi 56962958d3SRohit Mathew#endif /* PER_CPU_MACROS_S */ 57