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