arm-trusted-firmware/include/arch/aarch64
Masahiro Yamada fd092be239 Add get_current_el_maybe_constant()
There are some cases where we want to run EL-dependent code in the
shared code.

We could use #ifdef, but it leaves slight possibility where we do not
know the exception level at the build-time (e.g. library code).

The counter approach is to use get_current_el(), but it is run-time
detection, so all EL code is linked, some of which might be unneeded.

This commit adds get_current_el_maybe_constant(). This is a static
inline function that returns a constant value if we know the exception
level at build-time. This is mostly the case.

    if (get_current_el_maybe_constant() == 1) {
            /* do something for EL1 */
    } else if (get_current_el_maybe_constant() == 3) {
            /* do something for EL3 */
    }

If get_current_el_maybe_constant() is build-time constant, the compiler
will optimize out the unreachable code.

If such code is included from the library code, it is not built-time
constant. In this case, it falls back to get_current_el(), so it still
works.

Change-Id: Idb03c20342a5b5173fe2d6b40e1fac7998675ad3
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2020-03-31 11:51:56 +09:00
..
arch.h Fix crash dump for lower EL 2020-03-06 14:17:35 +00:00
arch_features.h Refactor ARMv8.3 Pointer Authentication support code 2019-09-13 14:11:59 +01:00
arch_helpers.h Add get_current_el_maybe_constant() 2020-03-31 11:51:56 +09:00
asm_macros.S Use Speculation Barrier instruction for v8.5 cores 2020-03-11 11:11:05 -05:00
assert_macros.S Reorganize architecture-dependent header files 2019-01-04 10:43:16 +00:00
console_macros.S Console: remove deprecated finish_console_register 2019-04-03 14:55:18 +01:00
el3_common_macros.S bl31: Split into two separate memory regions 2019-12-29 12:00:40 -06:00
smccc_helpers.h Replace __ASSEMBLY__ with compiler-builtin __ASSEMBLER__ 2019-08-01 13:14:12 -07:00