Some additional type checking to avoid future issues.
}
int
-flattenMiscRegNsBanked(int reg, ThreadContext *tc)
+flattenMiscRegNsBanked(MiscRegIndex reg, ThreadContext *tc)
{
+ int reg_as_int = static_cast<int>(reg);
if (miscRegInfo[reg][MISCREG_BANKED]) {
SCR scr = tc->readMiscReg(MISCREG_SCR);
- reg += (ArmSystem::haveSecurity(tc) && !scr.ns) ? 2 : 1;
+ reg_as_int += (ArmSystem::haveSecurity(tc) && !scr.ns) ? 2 : 1;
}
- return reg;
+ return reg_as_int;
}
int
-flattenMiscRegNsBanked(int reg, ThreadContext *tc, bool ns)
+flattenMiscRegNsBanked(MiscRegIndex reg, ThreadContext *tc, bool ns)
{
+ int reg_as_int = static_cast<int>(reg);
if (miscRegInfo[reg][MISCREG_BANKED]) {
- reg += (ArmSystem::haveSecurity(tc) && !ns) ? 2 : 1;
+ reg_as_int += (ArmSystem::haveSecurity(tc) && !ns) ? 2 : 1;
}
- return reg;
+ return reg_as_int;
}
// Uses just the scr.ns bit to pre flatten the misc regs. This is useful
// for MCR/MRC instructions
int
- flattenMiscRegNsBanked(int reg, ThreadContext *tc);
+ flattenMiscRegNsBanked(MiscRegIndex reg, ThreadContext *tc);
// Flattens a misc reg index using the specified security state. This is
// used for opperations (eg address translations) where the security
// state of the register access may differ from the current state of the
// processor
int
- flattenMiscRegNsBanked(int reg, ThreadContext *tc, bool ns);
+ flattenMiscRegNsBanked(MiscRegIndex reg, ThreadContext *tc, bool ns);
// Takes a misc reg index and returns the root reg if its one of a set of
// banked registers
// LPAE always uses remapping of memory attributes, irrespective of the
// value of SCTLR.TRE
- int reg = attrIndx & 0x4 ? MISCREG_MAIR1 : MISCREG_MAIR0;
- reg = flattenMiscRegNsBanked(reg, currState->tc, !currState->isSecure);
- uint32_t mair = currState->tc->readMiscReg(reg);
+ MiscRegIndex reg = attrIndx & 0x4 ? MISCREG_MAIR1 : MISCREG_MAIR0;
+ int reg_as_int = flattenMiscRegNsBanked(reg, currState->tc,
+ !currState->isSecure);
+ uint32_t mair = currState->tc->readMiscReg(reg_as_int);
attr = (mair >> (8 * (attrIndx % 4))) & 0xff;
uint8_t attr_7_4 = bits(attr, 7, 4);
uint8_t attr_3_0 = bits(attr, 3, 0);