From d782f6c1acb389d3fa43fd678cff1a8f68ee6c51 Mon Sep 17 00:00:00 2001 From: qinwei1 Date: Mon, 30 Oct 2023 17:44:57 +0800 Subject: [PATCH] arm64: add arm64_current_el to obtain current EL Summary Add a macro to obtain current execute level Signed-off-by: qinwei1 --- arch/arm64/src/common/arm64_arch.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/src/common/arm64_arch.h b/arch/arm64/src/common/arm64_arch.h index 06935472fb..7429a39ea3 100644 --- a/arch/arm64/src/common/arm64_arch.h +++ b/arch/arm64/src/common/arm64_arch.h @@ -391,6 +391,26 @@ static inline void arch_nop(void) __asm__ volatile ("nop"); } +/**************************************************************************** + * Name: + * arm64_current_el() + * + * Description: + * + * Get current execution level + * + ****************************************************************************/ + +#define arm64_current_el() \ + ({ \ + uint64_t __el; \ + int __ret; \ + __asm__ volatile ("mrs %0, CurrentEL" \ + : "=r" (__el)); \ + __ret = GET_EL(__el); \ + __ret; \ + }) + /**************************************************************************** * Name: * read_/write_/zero_ sysreg