From: Gabe Black Date: Thu, 26 Aug 2010 00:10:41 +0000 (-0500) Subject: ARM: Expand the mode checking utility functions. X-Git-Tag: stable_2012_02_02~857 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f4f6b31df1a8787a12d71108eac24543bdf541e3;p=gem5.git 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. --- 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);