47 #include "debug/Arm.hh"
48 #include "debug/MiscRegs.hh"
50 #include "params/ArmISA.hh"
68 ISA::MiscRegSwitch[] = {
211 _decoderFlavour(p->decoderFlavour),
230 highestELIs64 =
system->highestELIs64();
232 haveLPAE =
system->haveLPAE();
233 haveVirtualization =
system->haveVirtualization();
237 highestELIs64 =
true;
244 for (
auto sw : MiscRegSwitch) {
245 lookUpMiscReg[
sw.index] =
sw.entry;
286 sctlr.te = (bool) sctlr_rst.te;
287 sctlr.nmfi = (
bool) sctlr_rst.nmfi;
288 sctlr.v = (bool) sctlr_rst.v;
307 mvfr0.advSimdRegisters = 2;
308 mvfr0.singlePrecision = 2;
309 mvfr0.doublePrecision = 2;
310 mvfr0.vfpExceptionTrapping = 0;
312 mvfr0.squareRoot = 1;
313 mvfr0.shortVectors = 1;
314 mvfr0.roundingModes = 1;
318 mvfr1.flushToZero = 1;
319 mvfr1.defaultNaN = 1;
320 mvfr1.advSimdLoadStore = 1;
321 mvfr1.advSimdInteger = 1;
322 mvfr1.advSimdSinglePrecision = 1;
323 mvfr1.advSimdHalfPrecision = 1;
324 mvfr1.vfpHalfPrecision = 1;
418 panic(
"Invalid highest implemented exception level");
448 (p->id_aa64dfr0_el1 & 0xfffffffffffff0ff
ULL) |
449 (p->pmu ? 0x0000000000000100ULL : 0);
458 (p->pmu ? 0x03000000
ULL : 0);
470 miscRegs[MISCREG_ID_AA64PFR0_EL1], 11, 8,
478 miscRegs[MISCREG_ID_AA64MMFR0_EL1], 3, 0,
488 int lower = regs.first, upper = regs.second;
504 cpsr.j = pc.jazelle() ? 1 : 0;
505 cpsr.t = pc.thumb() ? 1 : 0;
512 warn(
"Unimplemented system register %s read.\n",
515 panic(
"Unimplemented system register %s read.\n",
530 const uint32_t ones = (uint32_t)(-1);
534 cpacrMask.cp10 = ones;
535 cpacrMask.cp11 = ones;
536 cpacrMask.asedis = ones;
542 if (scr.ns && (cpsr.mode !=
MODE_MON)) {
545 if (!nsacr.cp10) cpacrMask.cp10 = 0;
546 if (!nsacr.cp11) cpacrMask.cp11 = 0;
551 DPRINTF(MiscRegs,
"Reading misc reg %s: %#x\n",
589 warn_once(
"The clidr register always reports 0 caches.\n");
590 warn_once(
"clidr LoUIS field of 0b001 to match current "
591 "ARM implementations.\n");
594 warn_once(
"The ccsidr register isn't implemented and "
595 "always reads as 0.\n");
602 unsigned lineSizeWords =
604 unsigned log2LineSizeWords = 0;
606 while (lineSizeWords >>= 1) {
612 ctr.iCacheLineSize = log2LineSizeWords;
614 ctr.l1IndexPolicy = 0x3;
616 ctr.dCacheLineSize = log2LineSizeWords;
618 ctr.erg = log2LineSizeWords;
620 ctr.cwg = log2LineSizeWords;
627 warn(
"Not doing anything for miscreg ACTLR\n");
637 panic(
"shouldn't be reading this register seperately\n");
644 const uint32_t ones = (uint32_t)(-1);
646 fpscrMask.ioc = ones;
647 fpscrMask.dzc = ones;
648 fpscrMask.ofc = ones;
649 fpscrMask.ufc = ones;
650 fpscrMask.ixc = ones;
651 fpscrMask.idc = ones;
661 const uint32_t ones = (uint32_t)(-1);
663 fpscrMask.ioe = ones;
664 fpscrMask.dze = ones;
665 fpscrMask.ofe = ones;
666 fpscrMask.ufe = ones;
667 fpscrMask.ixe = ones;
668 fpscrMask.ide = ones;
669 fpscrMask.len = ones;
670 fpscrMask.stride = ones;
671 fpscrMask.rMode = ones;
674 fpscrMask.ahp = ones;
748 if (!secure_lookup) {
750 val |= (mask ^ 0x7FFF) & 0xBFFF;
780 | (haveTimer ? 0x00010000 : 0x0);
783 return 0x0000000000000002
810 int lower = regs.first, upper = regs.second;
814 DPRINTF(MiscRegs,
"Writing to misc reg %d (%d:%d) : %#x\n",
815 misc_reg, lower, upper, val);
818 DPRINTF(MiscRegs,
"Writing to misc reg %d (%d) : %#x\n",
819 misc_reg, lower, val);
842 int old_mode = old_cpsr.mode;
844 if (old_mode != cpsr.mode) {
849 DPRINTF(Arm,
"Updating CPSR from %#x to %#x f:%d i:%d a:%d mode:%#x\n",
850 miscRegs[misc_reg], cpsr, cpsr.f, cpsr.i, cpsr.a, cpsr.mode);
852 pc.nextThumb(cpsr.t);
853 pc.nextJazelle(cpsr.j);
867 warn(
"Unimplemented system register %s write with %#x.\n",
870 panic(
"Unimplemented system register %s write with %#x.\n",
878 const uint32_t ones = (uint32_t)(-1);
882 cpacrMask.cp10 = ones;
883 cpacrMask.cp11 = ones;
884 cpacrMask.asedis = ones;
890 if (scr.ns && (cpsr.mode !=
MODE_MON)) {
893 if (!nsacr.cp10) cpacrMask.cp10 = 0;
894 if (!nsacr.cp11) cpacrMask.cp11 = 0;
900 newVal |= old_val & ~cpacrMask;
901 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
907 const uint32_t ones = (uint32_t)(-1);
909 cpacrMask.tta = ones;
910 cpacrMask.fpen = ones;
912 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
918 const uint32_t ones = (uint32_t)(-1);
920 cptrMask.tcpac = ones;
925 cptrMask.res1_13_12_el2 = ones;
926 cptrMask.res1_9_0_el2 = ones;
928 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
934 const uint32_t ones = (uint32_t)(-1);
936 cptrMask.tcpac = ones;
940 DPRINTF(MiscRegs,
"Writing misc reg %s: %#x\n",
945 warn_once(
"The csselr register isn't implemented.\n");
949 warn(
"Calling DC ZVA! Not Implemeted! Expect WEIRD results\n");
954 const uint32_t ones = (uint32_t)(-1);
956 fpscrMask.ioc = ones;
957 fpscrMask.dzc = ones;
958 fpscrMask.ofc = ones;
959 fpscrMask.ufc = ones;
960 fpscrMask.ixc = ones;
961 fpscrMask.idc = ones;
962 fpscrMask.ioe = ones;
963 fpscrMask.dze = ones;
964 fpscrMask.ofe = ones;
965 fpscrMask.ufe = ones;
966 fpscrMask.ixe = ones;
967 fpscrMask.ide = ones;
968 fpscrMask.len = ones;
969 fpscrMask.stride = ones;
970 fpscrMask.rMode = ones;
973 fpscrMask.ahp = ones;
979 newVal = (newVal & (uint32_t)fpscrMask) |
981 ~(uint32_t)fpscrMask);
987 const uint32_t ones = (uint32_t)(-1);
989 fpscrMask.ioc = ones;
990 fpscrMask.dzc = ones;
991 fpscrMask.ofc = ones;
992 fpscrMask.ufc = ones;
993 fpscrMask.ixc = ones;
994 fpscrMask.idc = ones;
1000 newVal = (newVal & (uint32_t)fpscrMask) |
1002 ~(uint32_t)fpscrMask);
1008 const uint32_t ones = (uint32_t)(-1);
1009 FPSCR fpscrMask = 0;
1010 fpscrMask.ioe = ones;
1011 fpscrMask.dze = ones;
1012 fpscrMask.ofe = ones;
1013 fpscrMask.ufe = ones;
1014 fpscrMask.ixe = ones;
1015 fpscrMask.ide = ones;
1016 fpscrMask.len = ones;
1017 fpscrMask.stride = ones;
1018 fpscrMask.rMode = ones;
1019 fpscrMask.fz = ones;
1020 fpscrMask.dn = ones;
1021 fpscrMask.ahp = ones;
1022 newVal = (newVal & (uint32_t)fpscrMask) |
1024 ~(uint32_t)fpscrMask);
1053 const uint32_t fpexcMask = 0x60000000;
1054 newVal = (newVal & fpexcMask) |
1067 const uint32_t ifsrMask =
1069 newVal = newVal & ~ifsrMask;
1075 const uint32_t dfsrMask =
mask(31, 14) |
mask(8, 8);
1076 newVal = newVal & ~dfsrMask;
1086 DPRINTF(MiscRegs,
"Writing AMAIR: %#x\n", newVal);
1095 DPRINTF(MiscRegs,
"Writing SCTLR: %#x\n", newVal);
1100 SCTLR new_sctlr = newVal;
1151 oc->
getITBPtr()->flushAllSecurity(secure_lookup, target_el);
1152 oc->
getDTBPtr()->flushAllSecurity(secure_lookup, target_el);
1157 checker->
getITBPtr()->flushAllSecurity(secure_lookup,
1159 checker->
getDTBPtr()->flushAllSecurity(secure_lookup,
1170 tc->
getITBPtr()->flushAllSecurity(secure_lookup, target_el);
1178 tc->
getDTBPtr()->flushAllSecurity(secure_lookup, target_el);
1193 secure_lookup, target_el);
1196 secure_lookup, target_el);
1201 bits(newVal, 7,0), secure_lookup, target_el);
1203 bits(newVal, 7,0), secure_lookup, target_el);
1219 secure_lookup, target_el);
1221 secure_lookup, target_el);
1225 secure_lookup, target_el);
1227 secure_lookup, target_el);
1239 tlbiMVA(tc, newVal, secure_lookup, hyp, target_el);
1249 tlbiMVA(tc, newVal, secure_lookup, hyp, target_el);
1258 bits(newVal, 7,0), secure_lookup, target_el);
1267 bits(newVal, 7,0), secure_lookup, target_el);
1275 tc->
getITBPtr()->flushAsid(
bits(newVal, 7,0), secure_lookup,
1284 tc->
getDTBPtr()->flushAsid(
bits(newVal, 7,0), secure_lookup,
1308 secure_lookup =
true;
1309 tlbiALL(tc, secure_lookup, target_el);
1328 tlbiALL(tc, secure_lookup, target_el);
1343 secure_lookup =
true;
1344 tlbiVA(tc, newVal, asid, secure_lookup, target_el);
1357 tlbiVA(tc, newVal, asid, secure_lookup, target_el);
1365 asid =
bits(newVal, 63, 48);
1369 tlbiVA(tc, newVal, asid, secure_lookup, target_el);
1383 asid =
bits(newVal, 63, 48);
1386 oc->
getITBPtr()->flushAsid(asid, secure_lookup, target_el);
1387 oc->
getDTBPtr()->flushAsid(asid, secure_lookup, target_el);
1391 secure_lookup, target_el);
1393 secure_lookup, target_el);
1416 secure_lookup,
false, target_el);
1418 secure_lookup,
false, target_el);
1423 secure_lookup,
false, target_el);
1425 secure_lookup,
false, target_el);
1444 secure_lookup,
false, target_el);
1446 secure_lookup,
false, target_el);
1451 secure_lookup,
false, target_el);
1453 secure_lookup,
false, target_el);
1458 warn(
"Not doing anything for write of miscreg ACTLR\n");
1473 newVal &= ~((uint32_t) hstrMask);
1483 if (!secure_lookup) {
1486 newVal = (newVal & ~mask) | (oldValue & mask);
1534 panic(
"Security Extensions required for ATS12NSOPR");
1541 panic(
"Security Extensions required for ATS12NSOPW");
1548 panic(
"Security Extensions required for ATS12NSOUR");
1555 panic(
"Security Extensions required for ATS12NSOUW");
1577 warn(
"Translating via MISCREG(%d) in functional mode! Fix Me!\n", misc_reg);
1580 fault = tc->
getDTBPtr()->translateFunctional(&req, tc, mode, tranType);
1586 Addr paddr = req.getPaddr();
1589 newVal = (paddr &
mask(39, 12)) |
1592 newVal = (paddr & 0xfffff000) |
1596 "MISCREG: Translated addr 0x%08x: PAR: 0x%08x\n",
1601 FSR fsr = armFault->
getFsr(tc);
1603 newVal = ((fsr >> 9) & 1) << 11;
1606 newVal |= ((fsr >> 0) & 0x3f) << 1;
1609 newVal |= ((fsr >> 0) & 0xf) << 1;
1610 newVal |= ((fsr >> 10) & 0x1) << 5;
1611 newVal |= ((fsr >> 12) & 0x1) << 6;
1614 newVal |= ((armFault->
iss() >> 7) & 0x1) << 8;
1615 newVal |= armFault->
isStage2() ? 0x200 : 0;
1617 "MISCREG: Translated addr 0x%08x fault fsr %#x: PAR: 0x%08x\n",
1626 const uint32_t ones = (uint32_t)(-1);
1627 TTBCR ttbcrMask = 0;
1628 TTBCR ttbcrNew = newVal;
1633 ttbcrMask.pd0 = ones;
1634 ttbcrMask.pd1 = ones;
1636 ttbcrMask.epd0 = ones;
1637 ttbcrMask.irgn0 = ones;
1638 ttbcrMask.orgn0 = ones;
1639 ttbcrMask.sh0 = ones;
1640 ttbcrMask.ps = ones;
1641 ttbcrMask.a1 = ones;
1642 ttbcrMask.epd1 = ones;
1643 ttbcrMask.irgn1 = ones;
1644 ttbcrMask.orgn1 = ones;
1645 ttbcrMask.sh1 = ones;
1647 ttbcrMask.eae = ones;
1650 newVal = newVal & ttbcrMask;
1652 newVal = (newVal & ttbcrMask) | (ttbcr & (~ttbcrMask));
1663 uint64_t ttbrMask =
mask(63,56) |
mask(47,40);
1664 newVal = (newVal & (~ttbrMask));
1708 cpsr.daif = (uint8_t) ((CPSR) newVal).
daif;
1725 cpsr.sp = (uint8_t) ((CPSR) newVal).
sp;
1733 cpsr.el = (uint8_t) ((CPSR) newVal).
el;
1824 warn(
"Translating via MISCREG(%d) in functional mode! Fix Me!\n", misc_reg);
1828 fault = tc->
getDTBPtr()->translateFunctional(req, tc, mode,
1835 uint64_t attr1 = attr >> 56;
1836 if (!attr1 || attr1 ==0x44) {
1838 attr &= ~ uint64_t(0x80);
1840 newVal = (paddr &
mask(47, 12)) | attr;
1842 "MISCREG: Translated addr %#x: PAR_EL1: %#xx\n",
1847 FSR fsr = armFault->
getFsr(tc);
1851 newVal = ((fsr >> 9) & 1) << 11;
1853 newVal |= ((fsr >> 0) & 0x3f) << 1;
1855 newVal |= ((armFault->
iss() >> 7) & 0x1) << 8;
1856 newVal |= armFault->
isStage2() ? 0x200 : 0;
1861 newVal |= armFault->
isStage2() ? 1 << 8 : 0;
1862 newVal |= armFault->
isStage2() ? 1 << 9 : 0;
1866 "MISCREG: Translated addr %#x fault fsr %#x: PAR: %#x\n",
1877 newVal = val & ~(0x7 << 21);
1880 warn(
"miscreg L2CTLR (%s) written with %#x. ignored...\n",
1898 bool secure_lookup, uint8_t target_el)
1908 secure_lookup, target_el);
1910 secure_lookup, target_el);
1915 va, asid, secure_lookup, target_el);
1917 va, asid, secure_lookup, target_el);
1929 oc->
getITBPtr()->flushAllSecurity(secure_lookup, target_el);
1930 oc->
getDTBPtr()->flushAllSecurity(secure_lookup, target_el);
1935 checker->
getITBPtr()->flushAllSecurity(secure_lookup,
1937 checker->
getDTBPtr()->flushAllSecurity(secure_lookup,
1950 oc->
getITBPtr()->flushAllNs(hyp, target_el);
1951 oc->
getDTBPtr()->flushAllNs(hyp, target_el);
1955 checker->
getITBPtr()->flushAllNs(hyp, target_el);
1956 checker->
getDTBPtr()->flushAllNs(hyp, target_el);
1970 secure_lookup, hyp, target_el);
1972 secure_lookup, hyp, target_el);
1977 secure_lookup, hyp, target_el);
1979 secure_lookup, hyp, target_el);
1990 return *
timer.get();
1994 if (!generic_timer) {
1995 panic(
"Trying to get a generic timer from a system that hasn't "
1996 "been configured to use a generic timer.\n");
2000 return *
timer.get();
2006 ArmISAParams::create()
This master id is used for functional requests that don't come from a particular device.
virtual System * getSystemPtr()=0
void tlbiALLN(ThreadContext *tc, bool hyp, uint8_t target_el)
bitset< NUM_MISCREG_INFOS > miscRegInfo[NUM_MISCREGS]
decltype(nullptr) constexpr NoFault
virtual TheISA::Decoder * getDecoderPtr()=0
This module implements the global system counter and the local per-CPU architected timers as specifie...
virtual CCReg readCCReg(int reg_idx)=0
virtual MiscReg readMiscReg(int misc_reg)=0
Read a system register belonging to this device.
ExceptionLevel highestEL() const
Returns the highest implemented exception level.
void setMiscReg(int misc_reg, const MiscReg &val, ThreadContext *tc)
std::pair< int, int > getMiscIndices(int misc_reg) const
MiscReg readMiscReg(int misc_reg, ThreadContext *tc)
virtual FSR getFsr(ThreadContext *tc)
Base class for devices that use the MiscReg interfaces.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
void setContext(ContextID context_id)
Set up Context numbers.
Some registers alias with others, and therefore need to be translated.
virtual void setIntReg(int reg_idx, uint64_t val)=0
void assert64(ThreadContext *tc)
virtual BaseCPU * getCpuPtr()=0
const char *const miscRegName[]
void tlbiVA(ThreadContext *tc, MiscReg newVal, uint16_t asid, bool secure_lookup, uint8_t target_el)
virtual TheISA::PCState pcState()=0
TheISA::TLB * getITBPtr()
MiscReg miscRegs[NumMiscRegs]
ThreadContext is the external interface to all thread state for anything outside of the CPU...
unsigned int cacheLineSize() const
Get the cache line size of the system.
void tlbiALL(ThreadContext *tc, bool secure_lookup, uint8_t target_el)
void updateRegMap(CPSR cpsr)
virtual void setCCReg(int reg_idx, CCReg val)=0
uint8_t encodePhysAddrRange64(int pa_size)
Returns the encoding corresponding to the specified n.
virtual uint64_t readIntReg(int reg_idx)=0
int unflattenMiscReg(int reg)
virtual void pcStateNoRecord(const TheISA::PCState &val)=0
virtual TheISA::TLB * getDTBPtr()=0
std::unique_ptr< BaseISADevice > timer
static const uint32_t CpsrMaskQ
bool highestELIs64() const
Returns true if the register width of the highest implemented exception level is 64 bits (ARMv8) ...
T insertBits(T val, int first, int last, B bit_val)
Return val with bits first to last set to bit_val.
void tlbiMVA(ThreadContext *tc, MiscReg newVal, bool secure_lookup, bool hyp, uint8_t target_el)
ThreadContext * getThreadContext(ContextID tid)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
#define ULL(N)
uint64_t constant
void assert32(ThreadContext *tc)
virtual MiscReg readMiscReg(int misc_reg)=0
virtual bool isStage2() const
virtual uint32_t iss() const =0
virtual CheckerCPU * getCheckerCpuPtr()=0
TheISA::TLB * getDTBPtr()
GenericISA::SimplePCState< MachInst > PCState
virtual int threadId() const =0
virtual int contextId() const =0
void setVirt(int asid, Addr vaddr, unsigned size, Flags flags, MasterID mid, Addr pc)
Set up a virtual (e.g., CPU) request in a previously allocated Request object.
const SimObjectParams * _params
Cached copy of the object parameters.
void clear64(const ArmISAParams *p)
const Params * params() const
virtual void setMiscReg(int misc_reg, MiscReg val)=0
Write to a system register belonging to this device.
static const uint32_t FpscrExcMask
uint32_t getMPIDR(ArmSystem *arm_sys, ThreadContext *tc)
bool inSecureState(ThreadContext *tc)
T mbits(T val, int first, int last)
Mask off the given bits in place like bits() but without shifting.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
std::shared_ptr< FaultBase > Fault
void setMiscRegNoEffect(int misc_reg, const MiscReg &val)
BaseISADevice & getGenericTimer(ThreadContext *tc)
Abstract superclass for simulation objects.
MiscReg readMiscRegNoEffect(int misc_reg) const
virtual TheISA::TLB * getITBPtr()=0
static const uint32_t FpscrQcMask
GenericTimer * getGenericTimer() const
Get a pointer to the system's generic timer model.
Addr resetAddr64() const
Returns the reset address if the highest implemented exception level is 64 bits (ARMv8) ...