Searched hist:fd092be23982c160a3855f1e396b7311b5225bf9 (Results 1 – 1 of 1) sorted by relevance
| /rk3399_ARM-atf/include/arch/aarch64/ |
| H A D | arch_helpers.h | fd092be23982c160a3855f1e396b7311b5225bf9 Thu Mar 26 04:18:48 UTC 2020 Masahiro Yamada <yamada.masahiro@socionext.com> 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>
|