blob: 7283b205f7679203420947c70e653c83fd6779e9 [file] [log] [blame]
/*
* Copyright (c) 2010-2013, 2015-2019 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Gabe Black
* Ali Saidi
* Giacomo Gabrielli
*/
#include "arch/arm/miscregs.hh"
#include <tuple>
#include "arch/arm/isa.hh"
#include "base/logging.hh"
#include "cpu/thread_context.hh"
#include "sim/full_system.hh"
namespace ArmISA
{
MiscRegIndex
decodeCP14Reg(unsigned crn, unsigned opc1, unsigned crm, unsigned opc2)
{
switch(crn) {
case 0:
switch (opc1) {
case 0:
switch (opc2) {
case 0:
switch (crm) {
case 0:
return MISCREG_DBGDIDR;
case 1:
return MISCREG_DBGDSCRint;
}
break;
}
break;
case 7:
switch (opc2) {
case 0:
switch (crm) {
case 0:
return MISCREG_JIDR;
}
break;
}
break;
}
break;
case 1:
switch (opc1) {
case 6:
switch (crm) {
case 0:
switch (opc2) {
case 0:
return MISCREG_TEEHBR;
}
break;
}
break;
case 7:
switch (crm) {
case 0:
switch (opc2) {
case 0:
return MISCREG_JOSCR;
}
break;
}
break;
}
break;
case 2:
switch (opc1) {
case 7:
switch (crm) {
case 0:
switch (opc2) {
case 0:
return MISCREG_JMCR;
}
break;
}
break;
}
break;
}
// If we get here then it must be a register that we haven't implemented
warn("CP14 unimplemented crn[%d], opc1[%d], crm[%d], opc2[%d]",
crn, opc1, crm, opc2);
return MISCREG_CP14_UNIMPL;
}
using namespace std;
MiscRegIndex
decodeCP15Reg(unsigned crn, unsigned opc1, unsigned crm, unsigned opc2)
{
switch (crn) {
case 0:
switch (opc1) {
case 0:
switch (crm) {
case 0:
switch (opc2) {
case 1:
return MISCREG_CTR;
case 2:
return MISCREG_TCMTR;
case 3:
return MISCREG_TLBTR;
case 5:
return MISCREG_MPIDR;
case 6:
return MISCREG_REVIDR;
default:
return MISCREG_MIDR;
}
break;
case 1:
switch (opc2) {
case 0:
return MISCREG_ID_PFR0;
case 1:
return MISCREG_ID_PFR1;
case 2:
return MISCREG_ID_DFR0;
case 3:
return MISCREG_ID_AFR0;
case 4:
return MISCREG_ID_MMFR0;
case 5:
return MISCREG_ID_MMFR1;
case 6:
return MISCREG_ID_MMFR2;
case 7:
return MISCREG_ID_MMFR3;
}
break;
case 2:
switch (opc2) {
case 0:
return MISCREG_ID_ISAR0;
case 1:
return MISCREG_ID_ISAR1;
case 2:
return MISCREG_ID_ISAR2;
case 3:
return MISCREG_ID_ISAR3;
case 4:
return MISCREG_ID_ISAR4;
case 5:
return MISCREG_ID_ISAR5;
case 6:
case 7:
return MISCREG_RAZ; // read as zero
}
break;
default:
return MISCREG_RAZ; // read as zero
}
break;
case 1:
if (crm == 0) {
switch (opc2) {
case 0:
return MISCREG_CCSIDR;
case 1:
return MISCREG_CLIDR;
case 7:
return MISCREG_AIDR;
}
}
break;
case 2:
if (crm == 0 && opc2 == 0) {
return MISCREG_CSSELR;
}
break;
case 4:
if (crm == 0) {
if (opc2 == 0)
return MISCREG_VPIDR;
else if (opc2 == 5)
return MISCREG_VMPIDR;
}
break;
}
break;
case 1:
if (opc1 == 0) {
if (crm == 0) {
switch (opc2) {
case 0:
return MISCREG_SCTLR;
case 1:
return MISCREG_ACTLR;
case 0x2:
return MISCREG_CPACR;
}
} else if (crm == 1) {
switch (opc2) {
case 0:
return MISCREG_SCR;
case 1:
return MISCREG_SDER;
case 2:
return MISCREG_NSACR;
}
}
} else if (opc1 == 4) {
if (crm == 0) {
if (opc2 == 0)
return MISCREG_HSCTLR;
else if (opc2 == 1)
return MISCREG_HACTLR;
} else if (crm == 1) {
switch (opc2) {
case 0:
return MISCREG_HCR;
case 1:
return MISCREG_HDCR;
case 2:
return MISCREG_HCPTR;
case 3:
return MISCREG_HSTR;
case 7:
return MISCREG_HACR;
}
}
}
break;
case 2:
if (opc1 == 0 && crm == 0) {
switch (opc2) {
case 0:
return MISCREG_TTBR0;
case 1:
return MISCREG_TTBR1;
case 2:
return MISCREG_TTBCR;
}
} else if (opc1 == 4) {
if (crm == 0 && opc2 == 2)
return MISCREG_HTCR;
else if (crm == 1 && opc2 == 2)
return MISCREG_VTCR;
}
break;
case 3:
if (opc1 == 0 && crm == 0 && opc2 == 0) {
return MISCREG_DACR;
}
break;
case 4:
if (opc1 == 0 && crm == 6 && opc2 == 0) {
return MISCREG_ICC_PMR;
}
break;
case 5:
if (opc1 == 0) {
if (crm == 0) {
if (opc2 == 0) {
return MISCREG_DFSR;
} else if (opc2 == 1) {
return MISCREG_IFSR;
}
} else if (crm == 1) {
if (opc2 == 0) {
return MISCREG_ADFSR;
} else if (opc2 == 1) {
return MISCREG_AIFSR;
}
}
} else if (opc1 == 4) {
if (crm == 1) {
if (opc2 == 0)
return MISCREG_HADFSR;
else if (opc2 == 1)
return MISCREG_HAIFSR;
} else if (crm == 2 && opc2 == 0) {
return MISCREG_HSR;
}
}
break;
case 6:
if (opc1 == 0 && crm == 0) {
switch (opc2) {
case 0:
return MISCREG_DFAR;
case 2:
return MISCREG_IFAR;
}
} else if (opc1 == 4 && crm == 0) {
switch (opc2) {
case 0:
return MISCREG_HDFAR;
case 2:
return MISCREG_HIFAR;
case 4:
return MISCREG_HPFAR;
}
}
break;
case 7:
if (opc1 == 0) {
switch (crm) {
case 0:
if (opc2 == 4) {
return MISCREG_NOP;
}
break;
case 1:
switch (opc2) {
case 0:
return MISCREG_ICIALLUIS;
case 6:
return MISCREG_BPIALLIS;
}
break;
case 4:
if (opc2 == 0) {
return MISCREG_PAR;
}
break;
case 5:
switch (opc2) {
case 0:
return MISCREG_ICIALLU;
case 1:
return MISCREG_ICIMVAU;
case 4:
return MISCREG_CP15ISB;
case 6:
return MISCREG_BPIALL;
case 7:
return MISCREG_BPIMVA;
}
break;
case 6:
if (opc2 == 1) {
return MISCREG_DCIMVAC;
} else if (opc2 == 2) {
return MISCREG_DCISW;
}
break;
case 8:
switch (opc2) {
case 0:
return MISCREG_ATS1CPR;
case 1:
return MISCREG_ATS1CPW;
case 2:
return MISCREG_ATS1CUR;
case 3:
return MISCREG_ATS1CUW;
case 4:
return MISCREG_ATS12NSOPR;
case 5:
return MISCREG_ATS12NSOPW;
case 6:
return MISCREG_ATS12NSOUR;
case 7:
return MISCREG_ATS12NSOUW;
}
break;
case 10:
switch (opc2) {
case 1:
return MISCREG_DCCMVAC;
case 2:
return MISCREG_DCCSW;
case 4:
return MISCREG_CP15DSB;
case 5:
return MISCREG_CP15DMB;
}
break;
case 11:
if (opc2 == 1) {
return MISCREG_DCCMVAU;
}
break;
case 13:
if (opc2 == 1) {
return MISCREG_NOP;
}
break;
case 14:
if (opc2 == 1) {
return MISCREG_DCCIMVAC;
} else if (opc2 == 2) {
return MISCREG_DCCISW;
}
break;
}
} else if (opc1 == 4 && crm == 8) {
if (opc2 == 0)
return MISCREG_ATS1HR;
else if (opc2 == 1)
return MISCREG_ATS1HW;
}
break;
case 8:
if (opc1 == 0) {
switch (crm) {
case 3:
switch (opc2) {
case 0:
return MISCREG_TLBIALLIS;
case 1:
return MISCREG_TLBIMVAIS;
case 2:
return MISCREG_TLBIASIDIS;
case 3:
return MISCREG_TLBIMVAAIS;
case 5:
return MISCREG_TLBIMVALIS;
case 7:
return MISCREG_TLBIMVAALIS;
}
break;
case 5:
switch (opc2) {
case 0:
return MISCREG_ITLBIALL;
case 1:
return MISCREG_ITLBIMVA;
case 2:
return MISCREG_ITLBIASID;
}
break;
case 6:
switch (opc2) {
case 0:
return MISCREG_DTLBIALL;
case 1:
return MISCREG_DTLBIMVA;
case 2:
return MISCREG_DTLBIASID;
}
break;
case 7:
switch (opc2) {
case 0:
return MISCREG_TLBIALL;
case 1:
return MISCREG_TLBIMVA;
case 2:
return MISCREG_TLBIASID;
case 3:
return MISCREG_TLBIMVAA;
case 5:
return MISCREG_TLBIMVAL;
case 7:
return MISCREG_TLBIMVAAL;
}
break;
}
} else if (opc1 == 4) {
if (crm == 0) {
switch (opc2) {
case 1:
return MISCREG_TLBIIPAS2IS;
case 5:
return MISCREG_TLBIIPAS2LIS;
}
} else if (crm == 3) {
switch (opc2) {
case 0:
return MISCREG_TLBIALLHIS;
case 1:
return MISCREG_TLBIMVAHIS;
case 4:
return MISCREG_TLBIALLNSNHIS;
case 5:
return MISCREG_TLBIMVALHIS;
}
} else if (crm == 4) {
switch (opc2) {
case 1:
return MISCREG_TLBIIPAS2;
case 5:
return MISCREG_TLBIIPAS2L;
}
} else if (crm == 7) {
switch (opc2) {
case 0:
return MISCREG_TLBIALLH;
case 1:
return MISCREG_TLBIMVAH;
case 4:
return MISCREG_TLBIALLNSNH;
case 5:
return MISCREG_TLBIMVALH;
}
}
}
break;
case 9:
// Every cop register with CRn = 9 and CRm in
// {0-2}, {5-8} is implementation defined regardless
// of opc1 and opc2.
switch (crm) {
case 0:
case 1:
case 2:
case 5:
case 6:
case 7:
case 8:
return MISCREG_IMPDEF_UNIMPL;
}
if (opc1 == 0) {
switch (crm) {
case 12:
switch (opc2) {
case 0:
return MISCREG_PMCR;
case 1:
return MISCREG_PMCNTENSET;
case 2:
return MISCREG_PMCNTENCLR;
case 3:
return MISCREG_PMOVSR;
case 4:
return MISCREG_PMSWINC;
case 5:
return MISCREG_PMSELR;
case 6:
return MISCREG_PMCEID0;
case 7:
return MISCREG_PMCEID1;
}
break;
case 13:
switch (opc2) {
case 0:
return MISCREG_PMCCNTR;
case 1:
// Selector is PMSELR.SEL
return MISCREG_PMXEVTYPER_PMCCFILTR;
case 2:
return MISCREG_PMXEVCNTR;
}
break;
case 14:
switch (opc2) {
case 0:
return MISCREG_PMUSERENR;
case 1:
return MISCREG_PMINTENSET;
case 2:
return MISCREG_PMINTENCLR;
case 3:
return MISCREG_PMOVSSET;
}
break;
}
} else if (opc1 == 1) {
switch (crm) {
case 0:
switch (opc2) {
case 2: // L2CTLR, L2 Control Register
return MISCREG_L2CTLR;
case 3:
return MISCREG_L2ECTLR;
}
break;
break;
}
}
break;
case 10:
if (opc1 == 0) {
// crm 0, 1, 4, and 8, with op2 0 - 7, reserved for TLB lockdown
if (crm < 2) {
return MISCREG_IMPDEF_UNIMPL;
} else if (crm == 2) { // TEX Remap Registers
if (opc2 == 0) {
// Selector is TTBCR.EAE
return MISCREG_PRRR_MAIR0;
} else if (opc2 == 1) {
// Selector is TTBCR.EAE
return MISCREG_NMRR_MAIR1;
}
} else if (crm == 3) {
if (opc2 == 0) {
return MISCREG_AMAIR0;
} else if (opc2 == 1) {
return MISCREG_AMAIR1;
}
}
} else if (opc1 == 4) {
// crm 0, 1, 4, and 8, with op2 0 - 7, reserved for TLB lockdown
if (crm == 2) {
if (opc2 == 0)
return MISCREG_HMAIR0;
else if (opc2 == 1)
return MISCREG_HMAIR1;
} else if (crm == 3) {
if (opc2 == 0)
return MISCREG_HAMAIR0;
else if (opc2 == 1)
return MISCREG_HAMAIR1;
}
}
break;
case 11:
if (opc1 <=7) {
switch (crm) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 15:
// Reserved for DMA operations for TCM access
return MISCREG_IMPDEF_UNIMPL;
default:
break;
}
}
break;
case 12:
if (opc1 == 0) {
if (crm == 0) {
if (opc2 == 0) {
return MISCREG_VBAR;
} else if (opc2 == 1) {
return MISCREG_MVBAR;
}
} else if (crm == 1) {
if (opc2 == 0) {
return MISCREG_ISR;
}
} else if (crm == 8) {
switch (opc2) {
case 0:
return MISCREG_ICC_IAR0;
case 1:
return MISCREG_ICC_EOIR0;
case 2:
return MISCREG_ICC_HPPIR0;
case 3:
return MISCREG_ICC_BPR0;
case 4:
return MISCREG_ICC_AP0R0;
case 5:
return MISCREG_ICC_AP0R1;
case 6:
return MISCREG_ICC_AP0R2;
case 7:
return MISCREG_ICC_AP0R3;
}
} else if (crm == 9) {
switch (opc2) {
case 0:
return MISCREG_ICC_AP1R0;
case 1:
return MISCREG_ICC_AP1R1;
case 2:
return MISCREG_ICC_AP1R2;
case 3:
return MISCREG_ICC_AP1R3;
}
} else if (crm == 11) {
switch (opc2) {
case 1:
return MISCREG_ICC_DIR;
case 3:
return MISCREG_ICC_RPR;
}
} else if (crm == 12) {
switch (opc2) {
case 0:
return MISCREG_ICC_IAR1;
case 1:
return MISCREG_ICC_EOIR1;
case 2:
return MISCREG_ICC_HPPIR1;
case 3:
return MISCREG_ICC_BPR1;
case 4:
return MISCREG_ICC_CTLR;
case 5:
return MISCREG_ICC_SRE;
case 6:
return MISCREG_ICC_IGRPEN0;
case 7:
return MISCREG_ICC_IGRPEN1;
}
}
} else if (opc1 == 4) {
if (crm == 0 && opc2 == 0) {
return MISCREG_HVBAR;
} else if (crm == 8) {
switch (opc2) {
case 0:
return MISCREG_ICH_AP0R0;
case 1:
return MISCREG_ICH_AP0R1;
case 2:
return MISCREG_ICH_AP0R2;
case 3:
return MISCREG_ICH_AP0R3;
}
} else if (crm == 9) {
switch (opc2) {
case 0:
return MISCREG_ICH_AP1R0;
case 1:
return MISCREG_ICH_AP1R1;
case 2:
return MISCREG_ICH_AP1R2;
case 3:
return MISCREG_ICH_AP1R3;
case 5:
return MISCREG_ICC_HSRE;
}
} else if (crm == 11) {
switch (opc2) {
case 0:
return MISCREG_ICH_HCR;
case 1:
return MISCREG_ICH_VTR;
case 2:
return MISCREG_ICH_MISR;
case 3:
return MISCREG_ICH_EISR;
case 5:
return MISCREG_ICH_ELRSR;
case 7:
return MISCREG_ICH_VMCR;
}
} else if (crm == 12) {
switch (opc2) {
case 0:
return MISCREG_ICH_LR0;
case 1:
return MISCREG_ICH_LR1;
case 2:
return MISCREG_ICH_LR2;
case 3:
return MISCREG_ICH_LR3;
case 4:
return MISCREG_ICH_LR4;
case 5:
return MISCREG_ICH_LR5;
case 6:
return MISCREG_ICH_LR6;
case 7:
return MISCREG_ICH_LR7;
}
} else if (crm == 13) {
switch (opc2) {
case 0:
return MISCREG_ICH_LR8;
case 1:
return MISCREG_ICH_LR9;
case 2:
return MISCREG_ICH_LR10;
case 3:
return MISCREG_ICH_LR11;
case 4:
return MISCREG_ICH_LR12;
case 5:
return MISCREG_ICH_LR13;
case 6:
return MISCREG_ICH_LR14;
case 7:
return MISCREG_ICH_LR15;
}
} else if (crm == 14) {
switch (opc2) {
case 0:
return MISCREG_ICH_LRC0;
case 1:
return MISCREG_ICH_LRC1;
case 2:
return MISCREG_ICH_LRC2;
case 3:
return MISCREG_ICH_LRC3;
case 4:
return MISCREG_ICH_LRC4;
case 5:
return MISCREG_ICH_LRC5;
case 6:
return MISCREG_ICH_LRC6;
case 7:
return MISCREG_ICH_LRC7;
}
} else if (crm == 15) {
switch (opc2) {
case 0:
return MISCREG_ICH_LRC8;
case 1:
return MISCREG_ICH_LRC9;
case 2:
return MISCREG_ICH_LRC10;
case 3:
return MISCREG_ICH_LRC11;
case 4:
return MISCREG_ICH_LRC12;
case 5:
return MISCREG_ICH_LRC13;
case 6:
return MISCREG_ICH_LRC14;
case 7:
return MISCREG_ICH_LRC15;
}
}
} else if (opc1 == 6) {
if (crm == 12) {
switch (opc2) {
case 4:
return MISCREG_ICC_MCTLR;
case 5:
return MISCREG_ICC_MSRE;
case 7:
return MISCREG_ICC_MGRPEN1;
}
}
}
break;
case 13:
if (opc1 == 0) {
if (crm == 0) {
switch (opc2) {
case 0:
return MISCREG_FCSEIDR;
case 1:
return MISCREG_CONTEXTIDR;
case 2:
return MISCREG_TPIDRURW;
case 3:
return MISCREG_TPIDRURO;
case 4:
return MISCREG_TPIDRPRW;
}
}
} else if (opc1 == 4) {
if (crm == 0 && opc2 == 2)
return MISCREG_HTPIDR;
}
break;
case 14:
if (opc1 == 0) {
switch (crm) {
case 0:
if (opc2 == 0)
return MISCREG_CNTFRQ;
break;
case 1:
if (opc2 == 0)
return MISCREG_CNTKCTL;
break;
case 2:
if (opc2 == 0)
return MISCREG_CNTP_TVAL;
else if (opc2 == 1)
return MISCREG_CNTP_CTL;
break;
case 3:
if (opc2 == 0)
return MISCREG_CNTV_TVAL;
else if (opc2 == 1)
return MISCREG_CNTV_CTL;
break;
}
} else if (opc1 == 4) {
if (crm == 1 && opc2 == 0) {
return MISCREG_CNTHCTL;
} else if (crm == 2) {
if (opc2 == 0)
return MISCREG_CNTHP_TVAL;
else if (opc2 == 1)
return MISCREG_CNTHP_CTL;
}
}
break;
case 15:
// Implementation defined
return MISCREG_IMPDEF_UNIMPL;
}
// Unrecognized register
return MISCREG_CP15_UNIMPL;
}
MiscRegIndex
decodeCP15Reg64(unsigned crm, unsigned opc1)
{
switch (crm) {
case 2:
switch (opc1) {
case 0:
return MISCREG_TTBR0;
case 1:
return MISCREG_TTBR1;
case 4:
return MISCREG_HTTBR;
case 6:
return MISCREG_VTTBR;
}
break;
case 7:
if (opc1 == 0)
return MISCREG_PAR;
break;
case 14:
switch (opc1) {
case 0:
return MISCREG_CNTPCT;
case 1:
return MISCREG_CNTVCT;
case 2:
return MISCREG_CNTP_CVAL;
case 3:
return MISCREG_CNTV_CVAL;
case 4:
return MISCREG_CNTVOFF;
case 6:
return MISCREG_CNTHP_CVAL;
}
break;
case 15:
if (opc1 == 0)
return MISCREG_CPUMERRSR;
else if (opc1 == 1)
return MISCREG_L2MERRSR;
break;
}
// Unrecognized register
return MISCREG_CP15_UNIMPL;
}
std::tuple<bool, bool>
canReadCoprocReg(MiscRegIndex reg, SCR scr, CPSR cpsr)
{
bool secure = !scr.ns;
bool canRead = false;
bool undefined = false;
switch (cpsr.mode) {
case MODE_USER:
canRead = secure ? miscRegInfo[reg][MISCREG_USR_S_RD] :
miscRegInfo[reg][MISCREG_USR_NS_RD];
break;
case MODE_FIQ:
case MODE_IRQ:
case MODE_SVC:
case MODE_ABORT:
case MODE_UNDEFINED:
case MODE_SYSTEM:
canRead = secure ? miscRegInfo[reg][MISCREG_PRI_S_RD] :
miscRegInfo[reg][MISCREG_PRI_NS_RD];
break;
case MODE_MON:
canRead = secure ? miscRegInfo[reg][MISCREG_MON_NS0_RD] :
miscRegInfo[reg][MISCREG_MON_NS1_RD];
break;
case MODE_HYP:
canRead = miscRegInfo[reg][MISCREG_HYP_RD];
break;
default:
undefined = true;
}
// can't do permissions checkes on the root of a banked pair of regs
assert(!miscRegInfo[reg][MISCREG_BANKED]);
return std::make_tuple(canRead, undefined);
}
std::tuple<bool, bool>
canWriteCoprocReg(MiscRegIndex reg, SCR scr, CPSR cpsr)
{
bool secure = !scr.ns;
bool canWrite = false;
bool undefined = false;
switch (cpsr.mode) {
case MODE_USER:
canWrite = secure ? miscRegInfo[reg][MISCREG_USR_S_WR] :
miscRegInfo[reg][MISCREG_USR_NS_WR];
break;
case MODE_FIQ:
case MODE_IRQ:
case MODE_SVC:
case MODE_ABORT:
case MODE_UNDEFINED:
case MODE_SYSTEM:
canWrite = secure ? miscRegInfo[reg][MISCREG_PRI_S_WR] :
miscRegInfo[reg][MISCREG_PRI_NS_WR];
break;
case MODE_MON:
canWrite = secure ? miscRegInfo[reg][MISCREG_MON_NS0_WR] :
miscRegInfo[reg][MISCREG_MON_NS1_WR];
break;
case MODE_HYP:
canWrite = miscRegInfo[reg][MISCREG_HYP_WR];
break;
default:
undefined = true;
}
// can't do permissions checkes on the root of a banked pair of regs
assert(!miscRegInfo[reg][MISCREG_BANKED]);
return std::make_tuple(canWrite, undefined);
}
int
snsBankedIndex(MiscRegIndex reg, ThreadContext *tc)
{
SCR scr = tc->readMiscReg(MISCREG_SCR);
return snsBankedIndex(reg, tc, scr.ns);
}
int
snsBankedIndex(MiscRegIndex reg, ThreadContext *tc, bool ns)
{
int reg_as_int = static_cast<int>(reg);
if (miscRegInfo[reg][MISCREG_BANKED]) {
reg_as_int += (ArmSystem::haveSecurity(tc) &&
!ArmSystem::highestELIs64(tc) && !ns) ? 2 : 1;
}
return reg_as_int;
}
/**
* If the reg is a child reg of a banked set, then the parent is the last
* banked one in the list. This is messy, and the wish is to eventually have
* the bitmap replaced with a better data structure. the preUnflatten function
* initializes a lookup table to speed up the search for these banked
* registers.
*/
int unflattenResultMiscReg[NUM_MISCREGS];
void
preUnflattenMiscReg()
{
int reg = -1;
for (int i = 0 ; i < NUM_MISCREGS; i++){
if (miscRegInfo[i][MISCREG_BANKED])
reg = i;
if (miscRegInfo[i][MISCREG_BANKED_CHILD])
unflattenResultMiscReg[i] = reg;
else
unflattenResultMiscReg[i] = i;
// if this assert fails, no parent was found, and something is broken
assert(unflattenResultMiscReg[i] > -1);
}
}
int
unflattenMiscReg(int reg)
{
return unflattenResultMiscReg[reg];
}
bool
canReadAArch64SysReg(MiscRegIndex reg, SCR scr, CPSR cpsr, ThreadContext *tc)
{
// Check for SP_EL0 access while SPSEL == 0
if ((reg == MISCREG_SP_EL0) && (tc->readMiscReg(MISCREG_SPSEL) == 0))
return false;
// Check for RVBAR access
if (reg == MISCREG_RVBAR_EL1) {
ExceptionLevel highest_el = ArmSystem::highestEL(tc);
if (highest_el == EL2 || highest_el == EL3)
return false;
}
if (reg == MISCREG_RVBAR_EL2) {
ExceptionLevel highest_el = ArmSystem::highestEL(tc);
if (highest_el == EL3)
return false;
}
bool secure = ArmSystem::haveSecurity(tc) && !scr.ns;
switch (opModeToEL((OperatingMode) (uint8_t) cpsr.mode)) {
case EL0:
return secure ? miscRegInfo[reg][MISCREG_USR_S_RD] :
miscRegInfo[reg][MISCREG_USR_NS_RD];
case EL1:
return secure ? miscRegInfo[reg][MISCREG_PRI_S_RD] :
miscRegInfo[reg][MISCREG_PRI_NS_RD];
case EL2:
return miscRegInfo[reg][MISCREG_HYP_RD];
case EL3:
return secure ? miscRegInfo[reg][MISCREG_MON_NS0_RD] :
miscRegInfo[reg][MISCREG_MON_NS1_RD];
default:
panic("Invalid exception level");
}
}
bool
canWriteAArch64SysReg(MiscRegIndex reg, SCR scr, CPSR cpsr, ThreadContext *tc)
{
// Check for SP_EL0 access while SPSEL == 0
if ((reg == MISCREG_SP_EL0) && (tc->readMiscReg(MISCREG_SPSEL) == 0))
return false;
ExceptionLevel el = opModeToEL((OperatingMode) (uint8_t) cpsr.mode);
if (reg == MISCREG_DAIF) {
SCTLR sctlr = tc->readMiscReg(MISCREG_SCTLR_EL1);
if (el == EL0 && !sctlr.uma)
return false;
}
if (FullSystem && reg == MISCREG_DC_ZVA_Xt) {
// In syscall-emulation mode, this test is skipped and DCZVA is always
// allowed at EL0
SCTLR sctlr = tc->readMiscReg(MISCREG_SCTLR_EL1);
if (el == EL0 && !sctlr.dze)
return false;
}
if (reg == MISCREG_DC_CVAC_Xt || reg == MISCREG_DC_CIVAC_Xt) {
SCTLR sctlr = tc->readMiscReg(MISCREG_SCTLR_EL1);
if (el == EL0 && !sctlr.uci)
return false;
}
bool secure = ArmSystem::haveSecurity(tc) && !scr.ns;
switch (el) {
case EL0:
return secure ? miscRegInfo[reg][MISCREG_USR_S_WR] :
miscRegInfo[reg][MISCREG_USR_NS_WR];
case EL1:
return secure ? miscRegInfo[reg][MISCREG_PRI_S_WR] :
miscRegInfo[reg][MISCREG_PRI_NS_WR];
case EL2:
return miscRegInfo[reg][MISCREG_HYP_WR];
case EL3:
return secure ? miscRegInfo[reg][MISCREG_MON_NS0_WR] :
miscRegInfo[reg][MISCREG_MON_NS1_WR];
default:
panic("Invalid exception level");
}
}
MiscRegIndex
decodeAArch64SysReg(unsigned op0, unsigned op1,
unsigned crn, unsigned crm,
unsigned op2)
{
switch (op0) {
case 1:
switch (crn) {
case 7:
switch (op1) {
case 0:
switch (crm) {
case 1:
switch (op2) {
case 0:
return MISCREG_IC_IALLUIS;
}
break;
case 5:
switch (op2) {
case 0:
return MISCREG_IC_IALLU;
}
break;
case 6:
switch (op2) {
case 1:
return MISCREG_DC_IVAC_Xt;
case 2:
return MISCREG_DC_ISW_Xt;
}
break;
case 8:
switch (op2) {
case 0:
return MISCREG_AT_S1E1R_Xt;
case 1:
return MISCREG_AT_S1E1W_Xt;
case 2:
return MISCREG_AT_S1E0R_Xt;
case 3:
return MISCREG_AT_S1E0W_Xt;
}
break;
case 10:
switch (op2) {
case 2:
return MISCREG_DC_CSW_Xt;
}
break;
case 14:
switch (op2) {
case 2:
return MISCREG_DC_CISW_Xt;
}
break;
}
break;
case 3:
switch (crm) {
case 4:
switch (op2) {
case 1:
return MISCREG_DC_ZVA_Xt;
}
break;
case 5:
switch (op2) {
case 1:
return MISCREG_IC_IVAU_Xt;
}
break;
case 10:
switch (op2) {
case 1:
return MISCREG_DC_CVAC_Xt;
}
break;
case 11:
switch (op2) {
case 1:
return MISCREG_DC_CVAU_Xt;
}
break;
case 14:
switch (op2) {
case 1:
return MISCREG_DC_CIVAC_Xt;
}
break;
}
break;
case 4:
switch (crm) {
case 8:
switch (op2) {
case 0:
return MISCREG_AT_S1E2R_Xt;
case 1:
return MISCREG_AT_S1E2W_Xt;
case 4:
return MISCREG_AT_S12E1R_Xt;
case 5:
return MISCREG_AT_S12E1W_Xt;
case 6:
return MISCREG_AT_S12E0R_Xt;
case 7:
return MISCREG_AT_S12E0W_Xt;
}
break;
}
break;
case 6:
switch (crm) {
case 8:
switch (op2) {
case 0:
return MISCREG_AT_S1E3R_Xt;
case 1:
return MISCREG_AT_S1E3W_Xt;
}
break;
}
break;
}
break;
case 8:
switch (op1) {
case 0:
switch (crm) {
case 3:
switch (op2) {
case 0:
return MISCREG_TLBI_VMALLE1IS;
case 1:
return MISCREG_TLBI_VAE1IS_Xt;
case 2:
return MISCREG_TLBI_ASIDE1IS_Xt;
case 3:
return MISCREG_TLBI_VAAE1IS_Xt;
case 5:
return MISCREG_TLBI_VALE1IS_Xt;
case 7:
return MISCREG_TLBI_VAALE1IS_Xt;
}
break;
case 7:
switch (op2) {
case 0:
return MISCREG_TLBI_VMALLE1;
case 1:
return MISCREG_TLBI_VAE1_Xt;
case 2:
return MISCREG_TLBI_ASIDE1_Xt;
case 3:
return MISCREG_TLBI_VAAE1_Xt;
case 5:
return MISCREG_TLBI_VALE1_Xt;
case 7:
return MISCREG_TLBI_VAALE1_Xt;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 1:
return MISCREG_TLBI_IPAS2E1IS_Xt;
case 5:
return MISCREG_TLBI_IPAS2LE1IS_Xt;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_TLBI_ALLE2IS;
case 1:
return MISCREG_TLBI_VAE2IS_Xt;
case 4:
return MISCREG_TLBI_ALLE1IS;
case 5:
return MISCREG_TLBI_VALE2IS_Xt;
case 6:
return MISCREG_TLBI_VMALLS12E1IS;
}
break;
case 4:
switch (op2) {
case 1:
return MISCREG_TLBI_IPAS2E1_Xt;
case 5:
return MISCREG_TLBI_IPAS2LE1_Xt;
}
break;
case 7:
switch (op2) {
case 0:
return MISCREG_TLBI_ALLE2;
case 1:
return MISCREG_TLBI_VAE2_Xt;
case 4:
return MISCREG_TLBI_ALLE1;
case 5:
return MISCREG_TLBI_VALE2_Xt;
case 6:
return MISCREG_TLBI_VMALLS12E1;
}
break;
}
break;
case 6:
switch (crm) {
case 3:
switch (op2) {
case 0:
return MISCREG_TLBI_ALLE3IS;
case 1:
return MISCREG_TLBI_VAE3IS_Xt;
case 5:
return MISCREG_TLBI_VALE3IS_Xt;
}
break;
case 7:
switch (op2) {
case 0:
return MISCREG_TLBI_ALLE3;
case 1:
return MISCREG_TLBI_VAE3_Xt;
case 5:
return MISCREG_TLBI_VALE3_Xt;
}
break;
}
break;
}
break;
case 11:
case 15:
// SYS Instruction with CRn = { 11, 15 }
// (Trappable by HCR_EL2.TIDCP)
return MISCREG_IMPDEF_UNIMPL;
}
break;
case 2:
switch (crn) {
case 0:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 2:
return MISCREG_OSDTRRX_EL1;
case 4:
return MISCREG_DBGBVR0_EL1;
case 5:
return MISCREG_DBGBCR0_EL1;
case 6:
return MISCREG_DBGWVR0_EL1;
case 7:
return MISCREG_DBGWCR0_EL1;
}
break;
case 1:
switch (op2) {
case 4:
return MISCREG_DBGBVR1_EL1;
case 5:
return MISCREG_DBGBCR1_EL1;
case 6:
return MISCREG_DBGWVR1_EL1;
case 7:
return MISCREG_DBGWCR1_EL1;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_MDCCINT_EL1;
case 2:
return MISCREG_MDSCR_EL1;
case 4:
return MISCREG_DBGBVR2_EL1;
case 5:
return MISCREG_DBGBCR2_EL1;
case 6:
return MISCREG_DBGWVR2_EL1;
case 7:
return MISCREG_DBGWCR2_EL1;
}
break;
case 3:
switch (op2) {
case 2:
return MISCREG_OSDTRTX_EL1;
case 4:
return MISCREG_DBGBVR3_EL1;
case 5:
return MISCREG_DBGBCR3_EL1;
case 6:
return MISCREG_DBGWVR3_EL1;
case 7:
return MISCREG_DBGWCR3_EL1;
}
break;
case 4:
switch (op2) {
case 4:
return MISCREG_DBGBVR4_EL1;
case 5:
return MISCREG_DBGBCR4_EL1;
}
break;
case 5:
switch (op2) {
case 4:
return MISCREG_DBGBVR5_EL1;
case 5:
return MISCREG_DBGBCR5_EL1;
}
break;
case 6:
switch (op2) {
case 2:
return MISCREG_OSECCR_EL1;
}
break;
}
break;
case 2:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_TEECR32_EL1;
}
break;
}
break;
case 3:
switch (crm) {
case 1:
switch (op2) {
case 0:
return MISCREG_MDCCSR_EL0;
}
break;
case 4:
switch (op2) {
case 0:
return MISCREG_MDDTR_EL0;
}
break;
case 5:
switch (op2) {
case 0:
return MISCREG_MDDTRRX_EL0;
}
break;
}
break;
case 4:
switch (crm) {
case 7:
switch (op2) {
case 0:
return MISCREG_DBGVCR32_EL2;
}
break;
}
break;
}
break;
case 1:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_MDRAR_EL1;
case 4:
return MISCREG_OSLAR_EL1;
}
break;
case 1:
switch (op2) {
case 4:
return MISCREG_OSLSR_EL1;
}
break;
case 3:
switch (op2) {
case 4:
return MISCREG_OSDLR_EL1;
}
break;
case 4:
switch (op2) {
case 4:
return MISCREG_DBGPRCR_EL1;
}
break;
}
break;
case 2:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_TEEHBR32_EL1;
}
break;
}
break;
}
break;
case 7:
switch (op1) {
case 0:
switch (crm) {
case 8:
switch (op2) {
case 6:
return MISCREG_DBGCLAIMSET_EL1;
}
break;
case 9:
switch (op2) {
case 6:
return MISCREG_DBGCLAIMCLR_EL1;
}
break;
case 14:
switch (op2) {
case 6:
return MISCREG_DBGAUTHSTATUS_EL1;
}
break;
}
break;
}
break;
}
break;
case 3:
switch (crn) {
case 0:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_MIDR_EL1;
case 5:
return MISCREG_MPIDR_EL1;
case 6:
return MISCREG_REVIDR_EL1;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_ID_PFR0_EL1;
case 1:
return MISCREG_ID_PFR1_EL1;
case 2:
return MISCREG_ID_DFR0_EL1;
case 3:
return MISCREG_ID_AFR0_EL1;
case 4:
return MISCREG_ID_MMFR0_EL1;
case 5:
return MISCREG_ID_MMFR1_EL1;
case 6:
return MISCREG_ID_MMFR2_EL1;
case 7:
return MISCREG_ID_MMFR3_EL1;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_ID_ISAR0_EL1;
case 1:
return MISCREG_ID_ISAR1_EL1;
case 2:
return MISCREG_ID_ISAR2_EL1;
case 3:
return MISCREG_ID_ISAR3_EL1;
case 4:
return MISCREG_ID_ISAR4_EL1;
case 5:
return MISCREG_ID_ISAR5_EL1;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_MVFR0_EL1;
case 1:
return MISCREG_MVFR1_EL1;
case 2:
return MISCREG_MVFR2_EL1;
case 3 ... 7:
return MISCREG_RAZ;
}
break;
case 4:
switch (op2) {
case 0:
return MISCREG_ID_AA64PFR0_EL1;
case 1:
return MISCREG_ID_AA64PFR1_EL1;
case 2 ... 3:
return MISCREG_RAZ;
case 4:
return MISCREG_ID_AA64ZFR0_EL1;
case 5 ... 7:
return MISCREG_RAZ;
}
break;
case 5:
switch (op2) {
case 0:
return MISCREG_ID_AA64DFR0_EL1;
case 1:
return MISCREG_ID_AA64DFR1_EL1;
case 4:
return MISCREG_ID_AA64AFR0_EL1;
case 5:
return MISCREG_ID_AA64AFR1_EL1;
case 2:
case 3:
case 6:
case 7:
return MISCREG_RAZ;
}
break;
case 6:
switch (op2) {
case 0:
return MISCREG_ID_AA64ISAR0_EL1;
case 1:
return MISCREG_ID_AA64ISAR1_EL1;
case 2 ... 7:
return MISCREG_RAZ;
}
break;
case 7:
switch (op2) {
case 0:
return MISCREG_ID_AA64MMFR0_EL1;
case 1:
return MISCREG_ID_AA64MMFR1_EL1;
case 2:
return MISCREG_ID_AA64MMFR2_EL1;
case 3 ... 7:
return MISCREG_RAZ;
}
break;
}
break;
case 1:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_CCSIDR_EL1;
case 1:
return MISCREG_CLIDR_EL1;
case 7:
return MISCREG_AIDR_EL1;
}
break;
}
break;
case 2:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_CSSELR_EL1;
}
break;
}
break;
case 3:
switch (crm) {
case 0:
switch (op2) {
case 1:
return MISCREG_CTR_EL0;
case 7:
return MISCREG_DCZID_EL0;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_VPIDR_EL2;
case 5:
return MISCREG_VMPIDR_EL2;
}
break;
}
break;
}
break;
case 1:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_SCTLR_EL1;
case 1:
return MISCREG_ACTLR_EL1;
case 2:
return MISCREG_CPACR_EL1;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_ZCR_EL1;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_SCTLR_EL2;
case 1:
return MISCREG_ACTLR_EL2;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_HCR_EL2;
case 1:
return MISCREG_MDCR_EL2;
case 2:
return MISCREG_CPTR_EL2;
case 3:
return MISCREG_HSTR_EL2;
case 7:
return MISCREG_HACR_EL2;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_ZCR_EL2;
}
break;
}
break;
case 5:
switch (crm) {
case 2:
switch (op2) {
case 0:
return MISCREG_ZCR_EL12;
}
break;
}
break;
case 6:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_SCTLR_EL3;
case 1:
return MISCREG_ACTLR_EL3;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_SCR_EL3;
case 1:
return MISCREG_SDER32_EL3;
case 2:
return MISCREG_CPTR_EL3;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_ZCR_EL3;
}
break;
case 3:
switch (op2) {
case 1:
return MISCREG_MDCR_EL3;
}
break;
}
break;
}
break;
case 2:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_TTBR0_EL1;
case 1:
return MISCREG_TTBR1_EL1;
case 2:
return MISCREG_TCR_EL1;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_TTBR0_EL2;
case 1:
return MISCREG_TTBR1_EL2;
case 2:
return MISCREG_TCR_EL2;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_VTTBR_EL2;
case 2:
return MISCREG_VTCR_EL2;
}
break;
}
break;
case 6:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_TTBR0_EL3;
case 2:
return MISCREG_TCR_EL3;
}
break;
}
break;
}
break;
case 3:
switch (op1) {
case 4:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_DACR32_EL2;
}
break;
}
break;
}
break;
case 4:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_SPSR_EL1;
case 1:
return MISCREG_ELR_EL1;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_SP_EL0;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_SPSEL;
case 2:
return MISCREG_CURRENTEL;
case 3:
return MISCREG_PAN;
}
break;
case 6:
switch (op2) {
case 0:
return MISCREG_ICC_PMR_EL1;
}
break;
}
break;
case 3:
switch (crm) {
case 2:
switch (op2) {
case 0:
return MISCREG_NZCV;
case 1:
return MISCREG_DAIF;
}
break;
case 4:
switch (op2) {
case 0:
return MISCREG_FPCR;
case 1:
return MISCREG_FPSR;
}
break;
case 5:
switch (op2) {
case 0:
return MISCREG_DSPSR_EL0;
case 1:
return MISCREG_DLR_EL0;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_SPSR_EL2;
case 1:
return MISCREG_ELR_EL2;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_SP_EL1;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_SPSR_IRQ_AA64;
case 1:
return MISCREG_SPSR_ABT_AA64;
case 2:
return MISCREG_SPSR_UND_AA64;
case 3:
return MISCREG_SPSR_FIQ_AA64;
}
break;
}
break;
case 6:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_SPSR_EL3;
case 1:
return MISCREG_ELR_EL3;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_SP_EL2;
}
break;
}
break;
}
break;
case 5:
switch (op1) {
case 0:
switch (crm) {
case 1:
switch (op2) {
case 0:
return MISCREG_AFSR0_EL1;
case 1:
return MISCREG_AFSR1_EL1;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_ESR_EL1;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_ERRIDR_EL1;
case 1:
return MISCREG_ERRSELR_EL1;
}
break;
case 4:
switch (op2) {
case 0:
return MISCREG_ERXFR_EL1;
case 1:
return MISCREG_ERXCTLR_EL1;
case 2:
return MISCREG_ERXSTATUS_EL1;
case 3:
return MISCREG_ERXADDR_EL1;
}
break;
case 5:
switch (op2) {
case 0:
return MISCREG_ERXMISC0_EL1;
case 1:
return MISCREG_ERXMISC1_EL1;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 1:
return MISCREG_IFSR32_EL2;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_AFSR0_EL2;
case 1:
return MISCREG_AFSR1_EL2;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_ESR_EL2;
case 3:
return MISCREG_VSESR_EL2;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_FPEXC32_EL2;
}
break;
}
break;
case 6:
switch (crm) {
case 1:
switch (op2) {
case 0:
return MISCREG_AFSR0_EL3;
case 1:
return MISCREG_AFSR1_EL3;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_ESR_EL3;
}
break;
}
break;
}
break;
case 6:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_FAR_EL1;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_FAR_EL2;
case 4:
return MISCREG_HPFAR_EL2;
}
break;
}
break;
case 6:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_FAR_EL3;
}
break;
}
break;
}
break;
case 7:
switch (op1) {
case 0:
switch (crm) {
case 4:
switch (op2) {
case 0:
return MISCREG_PAR_EL1;
}
break;
}
break;
}
break;
case 9:
switch (op1) {
case 0:
switch (crm) {
case 14:
switch (op2) {
case 1:
return MISCREG_PMINTENSET_EL1;
case 2:
return MISCREG_PMINTENCLR_EL1;
}
break;
}
break;
case 3:
switch (crm) {
case 12:
switch (op2) {
case 0:
return MISCREG_PMCR_EL0;
case 1:
return MISCREG_PMCNTENSET_EL0;
case 2:
return MISCREG_PMCNTENCLR_EL0;
case 3:
return MISCREG_PMOVSCLR_EL0;
case 4:
return MISCREG_PMSWINC_EL0;
case 5:
return MISCREG_PMSELR_EL0;
case 6:
return MISCREG_PMCEID0_EL0;
case 7:
return MISCREG_PMCEID1_EL0;
}
break;
case 13:
switch (op2) {
case 0:
return MISCREG_PMCCNTR_EL0;
case 1:
return MISCREG_PMXEVTYPER_EL0;
case 2:
return MISCREG_PMXEVCNTR_EL0;
}
break;
case 14:
switch (op2) {
case 0:
return MISCREG_PMUSERENR_EL0;
case 3:
return MISCREG_PMOVSSET_EL0;
}
break;
}
break;
}
break;
case 10:
switch (op1) {
case 0:
switch (crm) {
case 2:
switch (op2) {
case 0:
return MISCREG_MAIR_EL1;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_AMAIR_EL1;
}
break;
}
break;
case 4:
switch (crm) {
case 2:
switch (op2) {
case 0:
return MISCREG_MAIR_EL2;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_AMAIR_EL2;
}
break;
}
break;
case 6:
switch (crm) {
case 2:
switch (op2) {
case 0:
return MISCREG_MAIR_EL3;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_AMAIR_EL3;
}
break;
}
break;
}
break;
case 11:
switch (op1) {
case 1:
switch (crm) {
case 0:
switch (op2) {
case 2:
return MISCREG_L2CTLR_EL1;
case 3:
return MISCREG_L2ECTLR_EL1;
}
break;
}
M5_FALLTHROUGH;
default:
// S3_<op1>_11_<Cm>_<op2>
return MISCREG_IMPDEF_UNIMPL;
}
M5_UNREACHABLE;
case 12:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_VBAR_EL1;
case 1:
return MISCREG_RVBAR_EL1;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_ISR_EL1;
case 1:
return MISCREG_DISR_EL1;
}
break;
case 8:
switch (op2) {
case 0:
return MISCREG_ICC_IAR0_EL1;
case 1:
return MISCREG_ICC_EOIR0_EL1;
case 2:
return MISCREG_ICC_HPPIR0_EL1;
case 3:
return MISCREG_ICC_BPR0_EL1;
case 4:
return MISCREG_ICC_AP0R0_EL1;
case 5:
return MISCREG_ICC_AP0R1_EL1;
case 6:
return MISCREG_ICC_AP0R2_EL1;
case 7:
return MISCREG_ICC_AP0R3_EL1;
}
break;
case 9:
switch (op2) {
case 0:
return MISCREG_ICC_AP1R0_EL1;
case 1:
return MISCREG_ICC_AP1R1_EL1;
case 2:
return MISCREG_ICC_AP1R2_EL1;
case 3:
return MISCREG_ICC_AP1R3_EL1;
}
break;
case 11:
switch (op2) {
case 1:
return MISCREG_ICC_DIR_EL1;
case 3:
return MISCREG_ICC_RPR_EL1;
case 5:
return MISCREG_ICC_SGI1R_EL1;
case 6:
return MISCREG_ICC_ASGI1R_EL1;
case 7:
return MISCREG_ICC_SGI0R_EL1;
}
break;
case 12:
switch (op2) {
case 0:
return MISCREG_ICC_IAR1_EL1;
case 1:
return MISCREG_ICC_EOIR1_EL1;
case 2:
return MISCREG_ICC_HPPIR1_EL1;
case 3:
return MISCREG_ICC_BPR1_EL1;
case 4:
return MISCREG_ICC_CTLR_EL1;
case 5:
return MISCREG_ICC_SRE_EL1;
case 6:
return MISCREG_ICC_IGRPEN0_EL1;
case 7:
return MISCREG_ICC_IGRPEN1_EL1;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_VBAR_EL2;
case 1:
return MISCREG_RVBAR_EL2;
}
break;
case 1:
switch (op2) {
case 1:
return MISCREG_VDISR_EL2;
}
break;
case 8:
switch (op2) {
case 0:
return MISCREG_ICH_AP0R0_EL2;
case 1:
return MISCREG_ICH_AP0R1_EL2;
case 2:
return MISCREG_ICH_AP0R2_EL2;
case 3:
return MISCREG_ICH_AP0R3_EL2;
}
break;
case 9:
switch (op2) {
case 0:
return MISCREG_ICH_AP1R0_EL2;
case 1:
return MISCREG_ICH_AP1R1_EL2;
case 2:
return MISCREG_ICH_AP1R2_EL2;
case 3:
return MISCREG_ICH_AP1R3_EL2;
case 5:
return MISCREG_ICC_SRE_EL2;
}
break;
case 11:
switch (op2) {
case 0:
return MISCREG_ICH_HCR_EL2;
case 1:
return MISCREG_ICH_VTR_EL2;
case 2:
return MISCREG_ICH_MISR_EL2;
case 3:
return MISCREG_ICH_EISR_EL2;
case 5:
return MISCREG_ICH_ELRSR_EL2;
case 7:
return MISCREG_ICH_VMCR_EL2;
}
break;
case 12:
switch (op2) {
case 0:
return MISCREG_ICH_LR0_EL2;
case 1:
return MISCREG_ICH_LR1_EL2;
case 2:
return MISCREG_ICH_LR2_EL2;
case 3:
return MISCREG_ICH_LR3_EL2;
case 4:
return MISCREG_ICH_LR4_EL2;
case 5:
return MISCREG_ICH_LR5_EL2;
case 6:
return MISCREG_ICH_LR6_EL2;
case 7:
return MISCREG_ICH_LR7_EL2;
}
break;
case 13:
switch (op2) {
case 0:
return MISCREG_ICH_LR8_EL2;
case 1:
return MISCREG_ICH_LR9_EL2;
case 2:
return MISCREG_ICH_LR10_EL2;
case 3:
return MISCREG_ICH_LR11_EL2;
case 4:
return MISCREG_ICH_LR12_EL2;
case 5:
return MISCREG_ICH_LR13_EL2;
case 6:
return MISCREG_ICH_LR14_EL2;
case 7:
return MISCREG_ICH_LR15_EL2;
}
break;
}
break;
case 6:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_VBAR_EL3;
case 1:
return MISCREG_RVBAR_EL3;
case 2:
return MISCREG_RMR_EL3;
}
break;
case 12:
switch (op2) {
case 4:
return MISCREG_ICC_CTLR_EL3;
case 5:
return MISCREG_ICC_SRE_EL3;
case 7:
return MISCREG_ICC_IGRPEN1_EL3;
}
break;
}
break;
}
break;
case 13:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 1:
return MISCREG_CONTEXTIDR_EL1;
case 4:
return MISCREG_TPIDR_EL1;
}
break;
}
break;
case 3:
switch (crm) {
case 0:
switch (op2) {
case 2:
return MISCREG_TPIDR_EL0;
case 3:
return MISCREG_TPIDRRO_EL0;
}
break;
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 1:
return MISCREG_CONTEXTIDR_EL2;
case 2:
return MISCREG_TPIDR_EL2;
}
break;
}
break;
case 6:
switch (crm) {
case 0:
switch (op2) {
case 2:
return MISCREG_TPIDR_EL3;
}
break;
}
break;
}
break;
case 14:
switch (op1) {
case 0:
switch (crm) {
case 1:
switch (op2) {
case 0:
return MISCREG_CNTKCTL_EL1;
}
break;
}
break;
case 3:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_CNTFRQ_EL0;
case 1:
return MISCREG_CNTPCT_EL0;
case 2:
return MISCREG_CNTVCT_EL0;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_CNTP_TVAL_EL0;
case 1:
return MISCREG_CNTP_CTL_EL0;
case 2:
return MISCREG_CNTP_CVAL_EL0;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_CNTV_TVAL_EL0;
case 1:
return MISCREG_CNTV_CTL_EL0;
case 2:
return MISCREG_CNTV_CVAL_EL0;
}
break;
case 8:
switch (op2) {
case 0:
return MISCREG_PMEVCNTR0_EL0;
case 1:
return MISCREG_PMEVCNTR1_EL0;
case 2:
return MISCREG_PMEVCNTR2_EL0;
case 3:
return MISCREG_PMEVCNTR3_EL0;
case 4:
return MISCREG_PMEVCNTR4_EL0;
case 5:
return MISCREG_PMEVCNTR5_EL0;
}
break;
case 12:
switch (op2) {
case 0:
return MISCREG_PMEVTYPER0_EL0;
case 1:
return MISCREG_PMEVTYPER1_EL0;
case 2:
return MISCREG_PMEVTYPER2_EL0;
case 3:
return MISCREG_PMEVTYPER3_EL0;
case 4:
return MISCREG_PMEVTYPER4_EL0;
case 5:
return MISCREG_PMEVTYPER5_EL0;
}
break;
case 15:
switch (op2) {
case 7:
return MISCREG_PMCCFILTR_EL0;
}
}
break;
case 4:
switch (crm) {
case 0:
switch (op2) {
case 3:
return MISCREG_CNTVOFF_EL2;
}
break;
case 1:
switch (op2) {
case 0:
return MISCREG_CNTHCTL_EL2;
}
break;
case 2:
switch (op2) {
case 0:
return MISCREG_CNTHP_TVAL_EL2;
case 1:
return MISCREG_CNTHP_CTL_EL2;
case 2:
return MISCREG_CNTHP_CVAL_EL2;
}
break;
case 3:
switch (op2) {
case 0:
return MISCREG_CNTHV_TVAL_EL2;
case 1:
return MISCREG_CNTHV_CTL_EL2;
case 2:
return MISCREG_CNTHV_CVAL_EL2;
}
break;
}
break;
case 7:
switch (crm) {
case 2:
switch (op2) {
case 0:
return MISCREG_CNTPS_TVAL_EL1;
case 1:
return MISCREG_CNTPS_CTL_EL1;
case 2:
return MISCREG_CNTPS_CVAL_EL1;
}
break;
}
break;
}
break;
case 15:
switch (op1) {
case 0:
switch (crm) {
case 0:
switch (op2) {
case 0:
return MISCREG_IL1DATA0_EL1;
case 1:
return MISCREG_IL1DATA1_EL1;
case 2:
return MISCR