1/* 2 * Copyright (c) 2019 Carlo Caione <ccaione@baylibre.com> 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7#ifndef _MACRO_PRIV_INC_ 8#define _MACRO_PRIV_INC_ 9 10#include <zephyr/arch/arm64/tpidrro_el0.h> 11 12#ifdef _ASMLANGUAGE 13 14/* 15 * Get CPU id 16 */ 17 18.macro get_cpu_id xreg0 19 mrs \xreg0, mpidr_el1 20 /* FIMXME: aff3 not taken into consideration */ 21 ubfx \xreg0, \xreg0, #0, #24 22.endm 23 24/* 25 * Get CPU logic id by looking up cpu_node_list 26 * returns 27 * xreg0: MPID 28 * xreg1: logic id (0 ~ CONFIG_MP_MAX_NUM_CPUS - 1) 29 * clobbers: xreg0, xreg1, xreg2, xreg3 30 */ 31.macro get_cpu_logic_id xreg0, xreg1, xreg2, xreg3 32 get_cpu_id \xreg0 33 ldr \xreg3, =cpu_node_list 34 mov \xreg1, 0 351: ldr \xreg2, [\xreg3, \xreg1, lsl 3] 36 cmp \xreg2, \xreg0 37 beq 2f 38 add \xreg1, \xreg1, 1 39 cmp \xreg1, #CONFIG_MP_MAX_NUM_CPUS 40 bne 1b 41 b . 422: 43.endm 44 45/* 46 * Get CPU pointer 47 * Note: keep in sync with `arch_curr_cpu` in include/zephyr/arch/arm64/arch_inlines.h 48 */ 49 50.macro get_cpu xreg0 51 mrs \xreg0, tpidrro_el0 52 and \xreg0, \xreg0, #TPIDRROEL0_CURR_CPU 53.endm 54 55#endif /* _ASMLANGUAGE */ 56 57#endif /* _MACRO_PRIV_INC_ */ 58