57                                 uint32_t 
type, uint32_t cfval)
 const 
   74             return (base >> 31) | -((base & (1 << 31)) >> 31);
 
   76             return (base >> shamt) | -((base & (1 << 31)) >> shamt);
 
   79             return (cfval << 31) | (base >> 1); 
 
   81             return (base << (32 - shamt)) | (base >> shamt);
 
   83         ccprintf(std::cerr, 
"Unhandled shift type\n");
 
   94     shiftAmt = shiftAmt % 
width;
 
  101         return base << shiftAmt;
 
  106             return (base & 
mask(width)) >> shiftAmt;
 
  113             base = sign_bit ? (base | ~
mask(
intWidth - shiftAmt)) : base;
 
  120             return (base << (width - shiftAmt)) | (base >> shiftAmt);
 
  122         ccprintf(std::cerr, 
"Unhandled shift type\n");
 
  131                            uint64_t shiftAmt, uint8_t 
width)
 const 
  133     bool sign_extend = 
false;
 
  165     len = len <= width - shiftAmt ? len : width - shiftAmt;
 
  166     uint64_t tmp = (uint64_t) 
bits(base, len - 1, 0) << shiftAmt;
 
  168         int sign_bit = 
bits(tmp, len + shiftAmt - 1);
 
  169         tmp = sign_bit ? (tmp | ~
mask(len + shiftAmt)) : tmp;
 
  171     return tmp & 
mask(width);
 
  177                                uint32_t 
type, uint32_t cfval)
 const 
  188             return base << shamt;
 
  193             return base >> shamt;
 
  196             return (base >> 31) | -((base & (1 << 31)) >> 31);
 
  198             return (base >> shamt) | -((base & (1 << 31)) >> shamt);
 
  200         shamt = shamt & 0x1f;
 
  204             return (base << (32 - shamt)) | (base >> shamt);
 
  206         ccprintf(std::cerr, 
"Unhandled shift type\n");
 
  217                                    uint32_t 
type, uint32_t cfval)
 const 
  228             return (base >> (32 - shamt)) & 1;
 
  233             return (base >> (shamt - 1)) & 1;
 
  238             return (base >> (shamt - 1)) & 1;
 
  240         shamt = shamt & 0x1f;
 
  244             return (base >> (shamt - 1)) & 1;
 
  246         ccprintf(std::cerr, 
"Unhandled shift type\n");
 
  257                                   uint32_t 
type, uint32_t cfval)
 const 
  271             return (base >> (32 - shamt)) & 1;
 
  276             return (base >> (shamt - 1)) & 1;
 
  280         return (base >> (shamt - 1)) & 1;
 
  282         shamt = shamt & 0x1f;
 
  285         return (base >> (shamt - 1)) & 1;
 
  287         ccprintf(std::cerr, 
"Unhandled shift type\n");
 
  346                              const std::string &suffix,
 
  355     } 
else if (withCond64) {
 
  374         if (symbolAddr != target)
 
  375             ccprintf(os, 
"+%d>", target - symbolAddr);
 
  386                               bool noImplicit)
 const 
  442         panic(
"Unrecognized condition code %d.\n", code);
 
  449                               const std::string &prefix,
 
  451                               const std::string &suffix)
 const 
  456         ccprintf(os, 
"%s%s", prefix, symbol);
 
  457         if (symbolAddr != addr)
 
  458             ccprintf(os, 
"+%d", addr - symbolAddr);
 
  471     bool firstOp = 
false;
 
  479     if ((type == 
LSR || type == 
ASR) && immShift && shiftAmt == 0)
 
  484         if (immShift && shiftAmt == 0) {
 
  503         if (immShift && shiftAmt == 0) {
 
  515         panic(
"Tried to disassemble unrecognized shift type.\n");
 
  521             os << 
"#" << shiftAmt;
 
  530                                   int64_t shiftAmt)
 const 
  535     if (type == 
UXTX && shiftAmt == 0)
 
  555     if (type == 
UXTX || shiftAmt)
 
  595     std::stringstream 
ss;
 
  606         return std::make_shared<SupervisorTrap>(
machInst, 0x1E00000,
 
  609         return std::make_shared<HypervisorTrap>(
machInst, 0x1E00000,
 
  612         return std::make_shared<SecureMonitorTrap>(
machInst, 0x1E00000,
 
  616         panic(
"Illegal EL in advSIMDFPAccessTrap64\n");
 
  643                                        CPSR cpsr, CPACR cpacr)
 const 
  646     if ((el == 
EL0 && cpacr.fpen != 0x3) ||
 
  647         (el == 
EL1 && !(cpacr.fpen & 0x1)))
 
  655                                          CPSR cpsr, CPACR cpacr,
 
  656                                          NSACR nsacr, FPEXC fpexc,
 
  657                                          bool fpexc_check, 
bool advsimd)
 const 
  667     uint8_t cpacr_cp10 = cpacr.cp10;
 
  668     bool cpacr_asedis = cpacr.asedis;
 
  670     if (have_security && !
ELIs64(tc, 
EL3) && !is_secure) {
 
  678         if (advsimd && cpacr_asedis)
 
  681         if ((cur_el == 
EL0 && cpacr_cp10 != 0x3) ||
 
  682             (cur_el != 
EL0 && !(cpacr_cp10 & 0x1)))
 
  686     if (fpexc_check && !fpexc.en)
 
  691     if (have_virtualization && !is_secure && 
ELIs64(tc, 
EL2))
 
  694     if (have_virtualization && !is_secure) {
 
  696         bool hcptr_cp10 = hcptr.tcp10;
 
  697         bool hcptr_tase = hcptr.tase;
 
  699         if (have_security && !
ELIs64(tc, 
EL3) && !is_secure) {
 
  706         if ((advsimd && hcptr_tase) || hcptr_cp10) {
 
  707             const uint32_t iss = advsimd ? (1 << 5) : 0xA;
 
  709                 return std::make_shared<UndefinedInstruction>(
 
  713                 return std::make_shared<HypervisorTrap>(
 
  737     const uint8_t it = 
itState(spsr);
 
  739     if (!spsr.t || spsr.il)
 
  744     if (
bits(it, 7, 4) != 0 && 
bits(it, 3, 0) == 0)
 
  747     const bool itd = el == 
EL2 ?
 
  754     if (itd && 
bits(it, 2, 0) != 0)
 
  785         if (target_el == 
EL0 && spsr.sp)
 
  808         new_cpsr.il = spsr.il;
 
  811         } 
else if (spsr.width) {
 
  812             new_cpsr.mode = spsr.mode;
 
  814             new_cpsr.el = spsr.el;
 
  815             new_cpsr.sp = spsr.sp;
 
  819     new_cpsr.nz = spsr.nz;
 
  822     if (new_cpsr.width) {
 
  826         new_cpsr.ge = spsr.ge;
 
  828         new_cpsr.aif = spsr.aif;
 
  830         new_cpsr.it2 = it.top6;
 
  831         new_cpsr.it1 = it.bottom2;
 
  834         new_cpsr.daif = spsr.daif;
 
void ccprintf(cp::Print &print)
 
void printExtendOperand(bool firstOperand, std::ostream &os, IntRegIndex rm, ArmExtendType type, int64_t shiftAmt) const 
 
decltype(nullptr) constexpr NoFault
 
void printShiftOperand(std::ostream &os, IntRegIndex rm, bool immShift, uint32_t shiftAmt, IntRegIndex rs, ArmShiftType type) const 
 
void printDataInst(std::ostream &os, bool withImm) const 
 
void printCondition(std::ostream &os, unsigned code, bool noImplicit=false) const 
 
void printMnemonic(std::ostream &os, const std::string &suffix="", bool withPred=true, bool withCond64=false, ConditionCode cond64=COND_UC) const 
 
void printReg(std::ostream &os, int reg) const 
Print a register name for disassembly given the unique dependence tag number (FP or int)...
 
static uint8_t itState(CPSR psr)
 
const char * mnemonic
Base mnemonic (e.g., "add"). 
 
void printMemSymbol(std::ostream &os, const SymbolTable *symtab, const std::string &prefix, const Addr addr, const std::string &suffix) const 
 
void printTarget(std::ostream &os, Addr target, const SymbolTable *symtab) const 
 
TheISA::RegIndex RegIndex
Logical register index type. 
 
const char *const miscRegName[]
 
ThreadContext is the external interface to all thread state for anything outside of the CPU...
 
Fault checkAdvSIMDOrFPEnabled32(ThreadContext *tc, CPSR cpsr, CPACR cpacr, NSACR nsacr, FPEXC fpexc, bool fpexc_check, bool advsimd) const 
Check if a VFP/SIMD access from aarch32 should be allowed. 
 
bool ELIs64(ThreadContext *tc, ExceptionLevel el)
 
static bool badMode32(OperatingMode mode)
 
const ExtMachInst machInst
The binary machine instruction. 
 
Fault advSIMDFPAccessTrap64(ExceptionLevel el) const 
Trap an access to Advanced SIMD or FP registers due to access control bits. 
 
static OperatingMode currOpMode(ThreadContext *tc)
 
Fault checkFPAdvSIMDTrap64(ThreadContext *tc, CPSR cpsr) const 
Check an Advaned SIMD access against CPTR_EL2 and CPTR_EL3. 
 
const int ReturnAddressReg
 
const char *const ccRegName[NUM_CCREGS]
 
const int StackPointerReg
 
const int FramePointerReg
 
static ExceptionLevel opModeToEL(OperatingMode mode)
 
int32_t shift_rm_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
bool highestELIs64() const 
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8) ...
 
static bool illegalExceptionReturn(ThreadContext *tc, CPSR cpsr, CPSR spsr)
 
bool haveSecurity() const 
Returns true if this system implements the Security Extensions. 
 
uint64_t Addr
Address type This will probably be moved somewhere else in the near future. 
 
bool shift_carry_rs(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
bool shift_carry_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
int64_t extendReg64(uint64_t base, ArmExtendType type, uint64_t shiftAmt, uint8_t width) const 
 
virtual MiscReg readMiscReg(int misc_reg)=0
 
Fault checkFPAdvSIMDEnabled64(ThreadContext *tc, CPSR cpsr, CPACR cpacr) const 
Check an Advaned SIMD access against CPACR_EL1, CPTR_EL2, and CPTR_EL3. 
 
bool haveVirtualization() const 
Returns true if this system implements the virtualization Extensions. 
 
int32_t shift_rm_imm(uint32_t base, uint32_t shamt, uint32_t type, uint32_t cfval) const 
 
int64_t shiftReg64(uint64_t base, uint64_t shiftAmt, ArmShiftType type, uint8_t width) const 
 
std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const 
Internal function to generate disassembly string. 
 
Fault disabledFault() const 
 
bool findNearestSymbol(Addr addr, std::string &symbol, Addr &symaddr, Addr &nextaddr) const 
Find the nearest symbol equal to or less than the supplied address (e.g., the label for the enclosing...
 
static uint8_t getRestoredITBits(ThreadContext *tc, CPSR spsr)
 
CPSR getPSTATEFromPSR(ThreadContext *tc, CPSR cpsr, CPSR spsr) const 
Get the new PSTATE from a SPSR register in preparation for an exception return. 
 
RegClass regIdxToClass(TheISA::RegIndex reg_idx, TheISA::RegIndex *rel_reg_idx=NULL)
Map a 'unified' architectural register index to its register class. 
 
bool inSecureState(ThreadContext *tc)
 
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
 
static bool badMode(OperatingMode mode)
 
std::shared_ptr< FaultBase > Fault