summaryrefslogtreecommitdiffstats
path: root/target/arm/cpu.h
diff options
context:
space:
mode:
authorPeter Maydell2017-09-04 16:21:53 +0200
committerPeter Maydell2017-09-04 16:21:53 +0200
commit15b3f556bab4f961bf92141eb8521c8da3df5eb2 (patch)
treeabfae05454a9ca80faefd84248d2288b49682cd8 /target/arm/cpu.h
parenttarget/arm: Don't calculate lr in arm_v7m_cpu_do_interrupt() until needed (diff)
downloadqemu-15b3f556bab4f961bf92141eb8521c8da3df5eb2.tar.gz
qemu-15b3f556bab4f961bf92141eb8521c8da3df5eb2.tar.xz
qemu-15b3f556bab4f961bf92141eb8521c8da3df5eb2.zip
target/arm: Create and use new function arm_v7m_is_handler_mode()
Add a utility function for testing whether the CPU is in Handler mode; this is just a check whether v7m.exception is non-zero, but we do it in several places and it makes the code a bit easier to read to not have to mentally figure out what the test is testing. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 1501692241-23310-14-git-send-email-peter.maydell@linaro.org
Diffstat (limited to 'target/arm/cpu.h')
-rw-r--r--target/arm/cpu.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 8ef552a0a2..eabef00a34 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1629,13 +1629,19 @@ static inline int arm_highest_el(CPUARMState *env)
return 1;
}
+/* Return true if a v7M CPU is in Handler mode */
+static inline bool arm_v7m_is_handler_mode(CPUARMState *env)
+{
+ return env->v7m.exception != 0;
+}
+
/* Return the current Exception Level (as per ARMv8; note that this differs
* from the ARMv7 Privilege Level).
*/
static inline int arm_current_el(CPUARMState *env)
{
if (arm_feature(env, ARM_FEATURE_M)) {
- return !((env->v7m.exception == 0) && (env->v7m.control & 1));
+ return arm_v7m_is_handler_mode(env) || !(env->v7m.control & 1);
}
if (is_a64(env)) {
@@ -2635,7 +2641,7 @@ static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
}
*flags |= fp_exception_el(env) << ARM_TBFLAG_FPEXC_EL_SHIFT;
- if (env->v7m.exception != 0) {
+ if (arm_v7m_is_handler_mode(env)) {
*flags |= ARM_TBFLAG_HANDLER_MASK;
}