From f4f6b31df1a8787a12d71108eac24543bdf541e3 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 25 Aug 2010 19:10:41 -0500 Subject: ARM: Expand the mode checking utility functions. inUserMode now can take either a threadcontext or a CPSR value directly. If given a thread context it just extracts the CPSR and calls the other version. An inPrivelegedMode function was also implemented which just returns the opposite of inUserMode. --- src/arch/arm/utility.hh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/arch') diff --git a/src/arch/arm/utility.hh b/src/arch/arm/utility.hh index 076468e0d..65c94926e 100644 --- a/src/arch/arm/utility.hh +++ b/src/arch/arm/utility.hh @@ -122,10 +122,28 @@ namespace ArmISA { void initCPU(ThreadContext *tc, int cpuId); + static inline bool + inUserMode(CPSR cpsr) + { + return cpsr.mode == MODE_USER; + } + static inline bool inUserMode(ThreadContext *tc) { - return (tc->readMiscRegNoEffect(MISCREG_CPSR) & 0x1f) == MODE_USER; + return inUserMode(tc->readMiscRegNoEffect(MISCREG_CPSR)); + } + + static inline bool + inPrivilegedMode(CPSR cpsr) + { + return !inUserMode(cpsr); + } + + static inline bool + inPrivilegedMode(ThreadContext *tc) + { + return !inUserMode(tc); } uint64_t getArgument(ThreadContext *tc, int number, bool fp); -- cgit v1.2.3