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.
This commit is contained in:
Gabe Black 2010-08-25 19:10:41 -05:00
parent 75955d6c42
commit f4f6b31df1

View file

@ -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);