Line data Source code
1 0 : /* 2 : * Copyright 2020 NXP 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : #ifndef ZEPHYR_INCLUDE_ARCH_ARM64_ARCH_INLINES_H 8 : #define ZEPHYR_INCLUDE_ARCH_ARM64_ARCH_INLINES_H 9 : 10 : #ifndef _ASMLANGUAGE 11 : 12 : #include <zephyr/kernel_structs.h> 13 : #include <zephyr/arch/arm64/lib_helpers.h> 14 : #include <zephyr/arch/arm64/tpidrro_el0.h> 15 : #include <zephyr/sys/__assert.h> 16 : 17 : /* Note: keep in sync with `get_cpu` in arch/arm64/core/macro_priv.inc */ 18 0 : static ALWAYS_INLINE _cpu_t *arch_curr_cpu(void) 19 : { 20 : return (_cpu_t *)(read_tpidrro_el0() & TPIDRROEL0_CURR_CPU); 21 : } 22 : 23 0 : static ALWAYS_INLINE int arch_exception_depth(void) 24 : { 25 : return (read_tpidrro_el0() & TPIDRROEL0_EXC_DEPTH) / TPIDRROEL0_EXC_UNIT; 26 : } 27 : 28 0 : static ALWAYS_INLINE uint32_t arch_proc_id(void) 29 : { 30 : uint64_t cpu_mpid = read_mpidr_el1(); 31 : 32 : __ASSERT(cpu_mpid == (uint32_t)cpu_mpid, "mpid extends past 32 bits"); 33 : 34 : return (uint32_t)cpu_mpid; 35 : } 36 : 37 0 : static ALWAYS_INLINE unsigned int arch_num_cpus(void) 38 : { 39 : return CONFIG_MP_MAX_NUM_CPUS; 40 : } 41 : 42 : #endif /* !_ASMLANGUAGE */ 43 : #endif /* ZEPHYR_INCLUDE_ARCH_ARM64_ARCH_INLINES_H */