diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2010-08-25 19:10:41 -0500 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2010-08-25 19:10:41 -0500 |
commit | f4f6b31df1a8787a12d71108eac24543bdf541e3 (patch) | |
tree | 3815c4cf0aa815075a8c4f9cf97e01f52862b221 | |
parent | 75955d6c42db8508c831d1a650f452f28b4db66d (diff) | |
download | gem5-f4f6b31df1a8787a12d71108eac24543bdf541e3.tar.xz |
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.
-rw-r--r-- | src/arch/arm/utility.hh | 20 |
1 files changed, 19 insertions, 1 deletions
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 @@ -123,9 +123,27 @@ 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); |