7#ifndef ZEPHYR_INCLUDE_ARCH_ARM64_LIB_HELPERS_H_
8#define ZEPHYR_INCLUDE_ARCH_ARM64_LIB_HELPERS_H_
17#define read_sysreg(reg) \
20 __asm__ volatile ("mrs %0, " STRINGIFY(reg) \
21 : "=r" (reg_val) :: "memory"); \
25#define write_sysreg(val, reg) \
27 __asm__ volatile ("msr " STRINGIFY(reg) ", %0" \
28 :: "r" (val) : "memory"); \
31#define zero_sysreg(reg) \
33 __asm__ volatile ("msr " STRINGIFY(reg) ", xzr" \
37#define MAKE_REG_HELPER(reg) \
38 static ALWAYS_INLINE uint64_t read_##reg(void) \
40 return read_sysreg(reg); \
42 static ALWAYS_INLINE void write_##reg(uint64_t val) \
44 write_sysreg(val, reg); \
46 static ALWAYS_INLINE void zero_##reg(void) \
51#define MAKE_REG_HELPER_EL123(reg) \
52 MAKE_REG_HELPER(reg##_el1) \
53 MAKE_REG_HELPER(reg##_el2) \
54 MAKE_REG_HELPER(reg##_el3)
92#if defined(CONFIG_ARM_MPU)
94#define mpuir_el1 S3_0_c0_c0_4
95#define prselr_el1 S3_0_c6_c2_1
96#define prbar_el1 S3_0_c6_c8_0
97#define prlar_el1 S3_0_c6_c8_1
107 __asm__
volatile (
"msr DAIFClr, %0"
113 __asm__
volatile (
"msr DAIFSet, %0"
119 __asm__
volatile (
"msr DAIFClr, %0"
125 __asm__
volatile (
"msr DAIFSet, %0"
131 __asm__
volatile (
"msr DAIFClr, %0"
137 __asm__
volatile (
"msr DAIFSet, %0"
143 __asm__
volatile (
"msr DAIFClr, %0"
149 __asm__
volatile (
"msr DAIFSet, %0"
153#define sev() __asm__ volatile("sev" : : : "memory")
154#define wfe() __asm__ volatile("wfe" : : : "memory")
155#define wfi() __asm__ volatile("wfi" : : : "memory")
176 el_highest = (31U - __builtin_clz(el_highest)) / 4;
180 if (curr_el < el_highest)
static ALWAYS_INLINE void disable_serror_exceptions(void)
Definition: lib_helpers.h:123
static ALWAYS_INLINE uint64_t read_id_aa64pfr0_el1(void)
Definition: lib_helpers.h:70
static ALWAYS_INLINE void disable_debug_exceptions(void)
Definition: lib_helpers.h:111
static bool is_el_implemented(unsigned int el)
Definition: lib_helpers.h:157
static bool is_el_highest_implemented(void)
Definition: lib_helpers.h:170
static ALWAYS_INLINE void disable_irq(void)
Definition: lib_helpers.h:135
static ALWAYS_INLINE void enable_irq(void)
Definition: lib_helpers.h:129
static ALWAYS_INLINE void disable_fiq(void)
Definition: lib_helpers.h:147
static ALWAYS_INLINE void enable_debug_exceptions(void)
Definition: lib_helpers.h:105
#define MAKE_REG_HELPER_EL123(reg)
Definition: lib_helpers.h:51
static ALWAYS_INLINE void enable_serror_exceptions(void)
Definition: lib_helpers.h:117
static ALWAYS_INLINE uint64_t read_currentel(void)
Definition: lib_helpers.h:66
static ALWAYS_INLINE void enable_fiq(void)
Definition: lib_helpers.h:141
static bool is_in_secure_state(void)
Definition: lib_helpers.h:192
static bool is_el2_sec_supported(void)
Definition: lib_helpers.h:186
#define ALWAYS_INLINE
Definition: common.h:129
#define MAKE_REG_HELPER(reg, op1, CRn, CRm, op2)
Definition: lib_helpers.h:45
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:124
#define GET_EL(_mode)
Definition: cpu.h:95
#define DAIFCLR_ABT_BIT
Definition: cpu.h:20
#define DAIFSET_IRQ_BIT
Definition: cpu.h:14
#define ID_AA64PFR0_SEL2_MASK
Definition: cpu.h:117
#define DAIFSET_ABT_BIT
Definition: cpu.h:15
#define DAIFSET_FIQ_BIT
Definition: cpu.h:13
#define DAIFCLR_IRQ_BIT
Definition: cpu.h:19
#define ID_AA64PFR0_SEL2_SHIFT
Definition: cpu.h:116
#define ID_AA64PFR0_EL1_SHIFT
Definition: cpu.h:112
#define DAIFCLR_FIQ_BIT
Definition: cpu.h:18
#define ID_AA64PFR0_ELX_MASK
Definition: cpu.h:115
#define DAIFSET_DBG_BIT
Definition: cpu.h:16
#define DAIFCLR_DBG_BIT
Definition: cpu.h:21
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90