isa.cc revision 10338
17405SAli.Saidi@ARM.com/* 210338SCurtis.Dunham@arm.com * Copyright (c) 2010-2014 ARM Limited 37405SAli.Saidi@ARM.com * All rights reserved 47405SAli.Saidi@ARM.com * 57405SAli.Saidi@ARM.com * The license below extends only to copyright in the software and shall 67405SAli.Saidi@ARM.com * not be construed as granting a license to any other intellectual 77405SAli.Saidi@ARM.com * property including but not limited to intellectual property relating 87405SAli.Saidi@ARM.com * to a hardware implementation of the functionality of the software 97405SAli.Saidi@ARM.com * licensed hereunder. You may use the software subject to the license 107405SAli.Saidi@ARM.com * terms below provided that you ensure that this notice is replicated 117405SAli.Saidi@ARM.com * unmodified and in its entirety in all distributions of the software, 127405SAli.Saidi@ARM.com * modified or unmodified, in source code or in binary form. 137405SAli.Saidi@ARM.com * 147405SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without 157405SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are 167405SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright 177405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer; 187405SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright 197405SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the 207405SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution; 217405SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its 227405SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from 237405SAli.Saidi@ARM.com * this software without specific prior written permission. 247405SAli.Saidi@ARM.com * 257405SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 267405SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 277405SAli.Saidi@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 287405SAli.Saidi@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 297405SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 307405SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 317405SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 327405SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 337405SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 347405SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 357405SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 367405SAli.Saidi@ARM.com * 377405SAli.Saidi@ARM.com * Authors: Gabe Black 387405SAli.Saidi@ARM.com * Ali Saidi 397405SAli.Saidi@ARM.com */ 407405SAli.Saidi@ARM.com 417405SAli.Saidi@ARM.com#include "arch/arm/isa.hh" 429050Schander.sudanthi@arm.com#include "arch/arm/system.hh" 438887Sgeoffrey.blake@arm.com#include "cpu/checker/cpu.hh" 448232Snate@binkert.org#include "debug/Arm.hh" 458232Snate@binkert.org#include "debug/MiscRegs.hh" 469384SAndreas.Sandberg@arm.com#include "params/ArmISA.hh" 477678Sgblack@eecs.umich.edu#include "sim/faults.hh" 488059SAli.Saidi@ARM.com#include "sim/stat_control.hh" 498284SAli.Saidi@ARM.com#include "sim/system.hh" 507405SAli.Saidi@ARM.com 517405SAli.Saidi@ARM.comnamespace ArmISA 527405SAli.Saidi@ARM.com{ 537405SAli.Saidi@ARM.com 5410037SARM gem5 Developers 5510037SARM gem5 Developers/** 5610037SARM gem5 Developers * Some registers aliase with others, and therefore need to be translated. 5710037SARM gem5 Developers * For each entry: 5810037SARM gem5 Developers * The first value is the misc register that is to be looked up 5910037SARM gem5 Developers * the second value is the lower part of the translation 6010037SARM gem5 Developers * the third the upper part 6110037SARM gem5 Developers */ 6210037SARM gem5 Developersconst struct ISA::MiscRegInitializerEntry 6310037SARM gem5 Developers ISA::MiscRegSwitch[miscRegTranslateMax] = { 6410037SARM gem5 Developers {MISCREG_CSSELR_EL1, {MISCREG_CSSELR, 0}}, 6510037SARM gem5 Developers {MISCREG_SCTLR_EL1, {MISCREG_SCTLR, 0}}, 6610037SARM gem5 Developers {MISCREG_SCTLR_EL2, {MISCREG_HSCTLR, 0}}, 6710037SARM gem5 Developers {MISCREG_ACTLR_EL1, {MISCREG_ACTLR, 0}}, 6810037SARM gem5 Developers {MISCREG_ACTLR_EL2, {MISCREG_HACTLR, 0}}, 6910037SARM gem5 Developers {MISCREG_CPACR_EL1, {MISCREG_CPACR, 0}}, 7010037SARM gem5 Developers {MISCREG_CPTR_EL2, {MISCREG_HCPTR, 0}}, 7110037SARM gem5 Developers {MISCREG_HCR_EL2, {MISCREG_HCR, 0}}, 7210037SARM gem5 Developers {MISCREG_MDCR_EL2, {MISCREG_HDCR, 0}}, 7310037SARM gem5 Developers {MISCREG_HSTR_EL2, {MISCREG_HSTR, 0}}, 7410037SARM gem5 Developers {MISCREG_HACR_EL2, {MISCREG_HACR, 0}}, 7510037SARM gem5 Developers {MISCREG_TTBR0_EL1, {MISCREG_TTBR0, 0}}, 7610037SARM gem5 Developers {MISCREG_TTBR1_EL1, {MISCREG_TTBR1, 0}}, 7710037SARM gem5 Developers {MISCREG_TTBR0_EL2, {MISCREG_HTTBR, 0}}, 7810037SARM gem5 Developers {MISCREG_VTTBR_EL2, {MISCREG_VTTBR, 0}}, 7910037SARM gem5 Developers {MISCREG_TCR_EL1, {MISCREG_TTBCR, 0}}, 8010037SARM gem5 Developers {MISCREG_TCR_EL2, {MISCREG_HTCR, 0}}, 8110037SARM gem5 Developers {MISCREG_VTCR_EL2, {MISCREG_VTCR, 0}}, 8210037SARM gem5 Developers {MISCREG_AFSR0_EL1, {MISCREG_ADFSR, 0}}, 8310037SARM gem5 Developers {MISCREG_AFSR1_EL1, {MISCREG_AIFSR, 0}}, 8410037SARM gem5 Developers {MISCREG_AFSR0_EL2, {MISCREG_HADFSR, 0}}, 8510037SARM gem5 Developers {MISCREG_AFSR1_EL2, {MISCREG_HAIFSR, 0}}, 8610037SARM gem5 Developers {MISCREG_ESR_EL2, {MISCREG_HSR, 0}}, 8710037SARM gem5 Developers {MISCREG_FAR_EL1, {MISCREG_DFAR, MISCREG_IFAR}}, 8810037SARM gem5 Developers {MISCREG_FAR_EL2, {MISCREG_HDFAR, MISCREG_HIFAR}}, 8910037SARM gem5 Developers {MISCREG_HPFAR_EL2, {MISCREG_HPFAR, 0}}, 9010037SARM gem5 Developers {MISCREG_PAR_EL1, {MISCREG_PAR, 0}}, 9110037SARM gem5 Developers {MISCREG_MAIR_EL1, {MISCREG_PRRR, MISCREG_NMRR}}, 9210037SARM gem5 Developers {MISCREG_MAIR_EL2, {MISCREG_HMAIR0, MISCREG_HMAIR1}}, 9310037SARM gem5 Developers {MISCREG_AMAIR_EL1, {MISCREG_AMAIR0, MISCREG_AMAIR1}}, 9410037SARM gem5 Developers {MISCREG_VBAR_EL1, {MISCREG_VBAR, 0}}, 9510037SARM gem5 Developers {MISCREG_VBAR_EL2, {MISCREG_HVBAR, 0}}, 9610037SARM gem5 Developers {MISCREG_CONTEXTIDR_EL1, {MISCREG_CONTEXTIDR, 0}}, 9710037SARM gem5 Developers {MISCREG_TPIDR_EL0, {MISCREG_TPIDRURW, 0}}, 9810037SARM gem5 Developers {MISCREG_TPIDRRO_EL0, {MISCREG_TPIDRURO, 0}}, 9910037SARM gem5 Developers {MISCREG_TPIDR_EL1, {MISCREG_TPIDRPRW, 0}}, 10010037SARM gem5 Developers {MISCREG_TPIDR_EL2, {MISCREG_HTPIDR, 0}}, 10110037SARM gem5 Developers {MISCREG_TEECR32_EL1, {MISCREG_TEECR, 0}}, 10210037SARM gem5 Developers {MISCREG_CNTFRQ_EL0, {MISCREG_CNTFRQ, 0}}, 10310037SARM gem5 Developers {MISCREG_CNTPCT_EL0, {MISCREG_CNTPCT, 0}}, 10410037SARM gem5 Developers {MISCREG_CNTVCT_EL0, {MISCREG_CNTVCT, 0}}, 10510037SARM gem5 Developers {MISCREG_CNTVOFF_EL2, {MISCREG_CNTVOFF, 0}}, 10610037SARM gem5 Developers {MISCREG_CNTKCTL_EL1, {MISCREG_CNTKCTL, 0}}, 10710037SARM gem5 Developers {MISCREG_CNTHCTL_EL2, {MISCREG_CNTHCTL, 0}}, 10810037SARM gem5 Developers {MISCREG_CNTP_TVAL_EL0, {MISCREG_CNTP_TVAL, 0}}, 10910037SARM gem5 Developers {MISCREG_CNTP_CTL_EL0, {MISCREG_CNTP_CTL, 0}}, 11010037SARM gem5 Developers {MISCREG_CNTP_CVAL_EL0, {MISCREG_CNTP_CVAL, 0}}, 11110037SARM gem5 Developers {MISCREG_CNTV_TVAL_EL0, {MISCREG_CNTV_TVAL, 0}}, 11210037SARM gem5 Developers {MISCREG_CNTV_CTL_EL0, {MISCREG_CNTV_CTL, 0}}, 11310037SARM gem5 Developers {MISCREG_CNTV_CVAL_EL0, {MISCREG_CNTV_CVAL, 0}}, 11410037SARM gem5 Developers {MISCREG_CNTHP_TVAL_EL2, {MISCREG_CNTHP_TVAL, 0}}, 11510037SARM gem5 Developers {MISCREG_CNTHP_CTL_EL2, {MISCREG_CNTHP_CTL, 0}}, 11610037SARM gem5 Developers {MISCREG_CNTHP_CVAL_EL2, {MISCREG_CNTHP_CVAL, 0}}, 11710037SARM gem5 Developers {MISCREG_DACR32_EL2, {MISCREG_DACR, 0}}, 11810037SARM gem5 Developers {MISCREG_IFSR32_EL2, {MISCREG_IFSR, 0}}, 11910037SARM gem5 Developers {MISCREG_TEEHBR32_EL1, {MISCREG_TEEHBR, 0}}, 12010037SARM gem5 Developers {MISCREG_SDER32_EL3, {MISCREG_SDER, 0}} 12110037SARM gem5 Developers}; 12210037SARM gem5 Developers 12310037SARM gem5 Developers 1249384SAndreas.Sandberg@arm.comISA::ISA(Params *p) 12510037SARM gem5 Developers : SimObject(p), system(NULL), lookUpMiscReg(NUM_MISCREGS, {0,0}) 1269384SAndreas.Sandberg@arm.com{ 1279384SAndreas.Sandberg@arm.com SCTLR sctlr; 1289384SAndreas.Sandberg@arm.com sctlr = 0; 1299384SAndreas.Sandberg@arm.com miscRegs[MISCREG_SCTLR_RST] = sctlr; 13010037SARM gem5 Developers 13110037SARM gem5 Developers system = dynamic_cast<ArmSystem *>(p->system); 13210037SARM gem5 Developers DPRINTFN("ISA system set to: %p %p\n", system, p->system); 13310037SARM gem5 Developers 13410037SARM gem5 Developers // Cache system-level properties 13510037SARM gem5 Developers if (FullSystem && system) { 13610037SARM gem5 Developers haveSecurity = system->haveSecurity(); 13710037SARM gem5 Developers haveLPAE = system->haveLPAE(); 13810037SARM gem5 Developers haveVirtualization = system->haveVirtualization(); 13910037SARM gem5 Developers haveLargeAsid64 = system->haveLargeAsid64(); 14010037SARM gem5 Developers physAddrRange64 = system->physAddrRange64(); 14110037SARM gem5 Developers } else { 14210037SARM gem5 Developers haveSecurity = haveLPAE = haveVirtualization = false; 14310037SARM gem5 Developers haveLargeAsid64 = false; 14410037SARM gem5 Developers physAddrRange64 = 32; // dummy value 14510037SARM gem5 Developers } 14610037SARM gem5 Developers 14710037SARM gem5 Developers /** Fill in the miscReg translation table */ 14810037SARM gem5 Developers for (uint32_t i = 0; i < miscRegTranslateMax; i++) { 14910037SARM gem5 Developers struct MiscRegLUTEntry new_entry; 15010037SARM gem5 Developers 15110037SARM gem5 Developers uint32_t select = MiscRegSwitch[i].index; 15210037SARM gem5 Developers new_entry = MiscRegSwitch[i].entry; 15310037SARM gem5 Developers 15410037SARM gem5 Developers lookUpMiscReg[select] = new_entry; 15510037SARM gem5 Developers } 15610037SARM gem5 Developers 15710037SARM gem5 Developers preUnflattenMiscReg(); 15810037SARM gem5 Developers 1599384SAndreas.Sandberg@arm.com clear(); 1609384SAndreas.Sandberg@arm.com} 1619384SAndreas.Sandberg@arm.com 1629384SAndreas.Sandberg@arm.comconst ArmISAParams * 1639384SAndreas.Sandberg@arm.comISA::params() const 1649384SAndreas.Sandberg@arm.com{ 1659384SAndreas.Sandberg@arm.com return dynamic_cast<const Params *>(_params); 1669384SAndreas.Sandberg@arm.com} 1679384SAndreas.Sandberg@arm.com 1687427Sgblack@eecs.umich.eduvoid 1697427Sgblack@eecs.umich.eduISA::clear() 1707427Sgblack@eecs.umich.edu{ 1719385SAndreas.Sandberg@arm.com const Params *p(params()); 1729385SAndreas.Sandberg@arm.com 1737427Sgblack@eecs.umich.edu SCTLR sctlr_rst = miscRegs[MISCREG_SCTLR_RST]; 1747427Sgblack@eecs.umich.edu memset(miscRegs, 0, sizeof(miscRegs)); 17510037SARM gem5 Developers 17610037SARM gem5 Developers // Initialize configurable default values 17710037SARM gem5 Developers miscRegs[MISCREG_MIDR] = p->midr; 17810037SARM gem5 Developers miscRegs[MISCREG_MIDR_EL1] = p->midr; 17910037SARM gem5 Developers miscRegs[MISCREG_VPIDR] = p->midr; 18010037SARM gem5 Developers 18110037SARM gem5 Developers if (FullSystem && system->highestELIs64()) { 18210037SARM gem5 Developers // Initialize AArch64 state 18310037SARM gem5 Developers clear64(p); 18410037SARM gem5 Developers return; 18510037SARM gem5 Developers } 18610037SARM gem5 Developers 18710037SARM gem5 Developers // Initialize AArch32 state... 18810037SARM gem5 Developers 1897427Sgblack@eecs.umich.edu CPSR cpsr = 0; 1907427Sgblack@eecs.umich.edu cpsr.mode = MODE_USER; 1917427Sgblack@eecs.umich.edu miscRegs[MISCREG_CPSR] = cpsr; 1927427Sgblack@eecs.umich.edu updateRegMap(cpsr); 1937427Sgblack@eecs.umich.edu 1947427Sgblack@eecs.umich.edu SCTLR sctlr = 0; 19510037SARM gem5 Developers sctlr.te = (bool) sctlr_rst.te; 19610037SARM gem5 Developers sctlr.nmfi = (bool) sctlr_rst.nmfi; 19710037SARM gem5 Developers sctlr.v = (bool) sctlr_rst.v; 19810037SARM gem5 Developers sctlr.u = 1; 1997427Sgblack@eecs.umich.edu sctlr.xp = 1; 2007427Sgblack@eecs.umich.edu sctlr.rao2 = 1; 2017427Sgblack@eecs.umich.edu sctlr.rao3 = 1; 20210037SARM gem5 Developers sctlr.rao4 = 0xf; // SCTLR[6:3] 20310204SAli.Saidi@ARM.com sctlr.uci = 1; 20410204SAli.Saidi@ARM.com sctlr.dze = 1; 20510037SARM gem5 Developers miscRegs[MISCREG_SCTLR_NS] = sctlr; 2067427Sgblack@eecs.umich.edu miscRegs[MISCREG_SCTLR_RST] = sctlr_rst; 20710037SARM gem5 Developers miscRegs[MISCREG_HCPTR] = 0; 2087427Sgblack@eecs.umich.edu 20910037SARM gem5 Developers // Start with an event in the mailbox 2107427Sgblack@eecs.umich.edu miscRegs[MISCREG_SEV_MAILBOX] = 1; 2117427Sgblack@eecs.umich.edu 21210037SARM gem5 Developers // Separate Instruction and Data TLBs 2137427Sgblack@eecs.umich.edu miscRegs[MISCREG_TLBTR] = 1; 2147427Sgblack@eecs.umich.edu 2157427Sgblack@eecs.umich.edu MVFR0 mvfr0 = 0; 2167427Sgblack@eecs.umich.edu mvfr0.advSimdRegisters = 2; 2177427Sgblack@eecs.umich.edu mvfr0.singlePrecision = 2; 2187427Sgblack@eecs.umich.edu mvfr0.doublePrecision = 2; 2197427Sgblack@eecs.umich.edu mvfr0.vfpExceptionTrapping = 0; 2207427Sgblack@eecs.umich.edu mvfr0.divide = 1; 2217427Sgblack@eecs.umich.edu mvfr0.squareRoot = 1; 2227427Sgblack@eecs.umich.edu mvfr0.shortVectors = 1; 2237427Sgblack@eecs.umich.edu mvfr0.roundingModes = 1; 2247427Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR0] = mvfr0; 2257427Sgblack@eecs.umich.edu 2267427Sgblack@eecs.umich.edu MVFR1 mvfr1 = 0; 2277427Sgblack@eecs.umich.edu mvfr1.flushToZero = 1; 2287427Sgblack@eecs.umich.edu mvfr1.defaultNaN = 1; 2297427Sgblack@eecs.umich.edu mvfr1.advSimdLoadStore = 1; 2307427Sgblack@eecs.umich.edu mvfr1.advSimdInteger = 1; 2317427Sgblack@eecs.umich.edu mvfr1.advSimdSinglePrecision = 1; 2327427Sgblack@eecs.umich.edu mvfr1.advSimdHalfPrecision = 1; 2337427Sgblack@eecs.umich.edu mvfr1.vfpHalfPrecision = 1; 2347427Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR1] = mvfr1; 2357427Sgblack@eecs.umich.edu 2367436Sdam.sunwoo@arm.com // Reset values of PRRR and NMRR are implementation dependent 2377436Sdam.sunwoo@arm.com 23810037SARM gem5 Developers // @todo: PRRR and NMRR in secure state? 23910037SARM gem5 Developers miscRegs[MISCREG_PRRR_NS] = 2407436Sdam.sunwoo@arm.com (1 << 19) | // 19 2417436Sdam.sunwoo@arm.com (0 << 18) | // 18 2427436Sdam.sunwoo@arm.com (0 << 17) | // 17 2437436Sdam.sunwoo@arm.com (1 << 16) | // 16 2447436Sdam.sunwoo@arm.com (2 << 14) | // 15:14 2457436Sdam.sunwoo@arm.com (0 << 12) | // 13:12 2467436Sdam.sunwoo@arm.com (2 << 10) | // 11:10 2477436Sdam.sunwoo@arm.com (2 << 8) | // 9:8 2487436Sdam.sunwoo@arm.com (2 << 6) | // 7:6 2497436Sdam.sunwoo@arm.com (2 << 4) | // 5:4 2507436Sdam.sunwoo@arm.com (1 << 2) | // 3:2 2517436Sdam.sunwoo@arm.com 0; // 1:0 25210037SARM gem5 Developers miscRegs[MISCREG_NMRR_NS] = 2537436Sdam.sunwoo@arm.com (1 << 30) | // 31:30 2547436Sdam.sunwoo@arm.com (0 << 26) | // 27:26 2557436Sdam.sunwoo@arm.com (0 << 24) | // 25:24 2567436Sdam.sunwoo@arm.com (3 << 22) | // 23:22 2577436Sdam.sunwoo@arm.com (2 << 20) | // 21:20 2587436Sdam.sunwoo@arm.com (0 << 18) | // 19:18 2597436Sdam.sunwoo@arm.com (0 << 16) | // 17:16 2607436Sdam.sunwoo@arm.com (1 << 14) | // 15:14 2617436Sdam.sunwoo@arm.com (0 << 12) | // 13:12 2627436Sdam.sunwoo@arm.com (2 << 10) | // 11:10 2637436Sdam.sunwoo@arm.com (0 << 8) | // 9:8 2647436Sdam.sunwoo@arm.com (3 << 6) | // 7:6 2657436Sdam.sunwoo@arm.com (2 << 4) | // 5:4 2667436Sdam.sunwoo@arm.com (0 << 2) | // 3:2 2677436Sdam.sunwoo@arm.com 0; // 1:0 2687436Sdam.sunwoo@arm.com 2697644Sali.saidi@arm.com miscRegs[MISCREG_CPACR] = 0; 2708147SAli.Saidi@ARM.com 2719385SAndreas.Sandberg@arm.com 2729385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_PFR0] = p->id_pfr0; 2739385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_PFR1] = p->id_pfr1; 2749385SAndreas.Sandberg@arm.com 2759385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_MMFR0] = p->id_mmfr0; 2769385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_MMFR1] = p->id_mmfr1; 2779385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_MMFR2] = p->id_mmfr2; 2789385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_MMFR3] = p->id_mmfr3; 2799385SAndreas.Sandberg@arm.com 2809385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_ISAR0] = p->id_isar0; 2819385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_ISAR1] = p->id_isar1; 2829385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_ISAR2] = p->id_isar2; 2839385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_ISAR3] = p->id_isar3; 2849385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_ISAR4] = p->id_isar4; 2859385SAndreas.Sandberg@arm.com miscRegs[MISCREG_ID_ISAR5] = p->id_isar5; 2869385SAndreas.Sandberg@arm.com 2879385SAndreas.Sandberg@arm.com miscRegs[MISCREG_FPSID] = p->fpsid; 2889385SAndreas.Sandberg@arm.com 28910037SARM gem5 Developers if (haveLPAE) { 29010037SARM gem5 Developers TTBCR ttbcr = miscRegs[MISCREG_TTBCR_NS]; 29110037SARM gem5 Developers ttbcr.eae = 0; 29210037SARM gem5 Developers miscRegs[MISCREG_TTBCR_NS] = ttbcr; 29310037SARM gem5 Developers // Enforce consistency with system-level settings 29410037SARM gem5 Developers miscRegs[MISCREG_ID_MMFR0] = (miscRegs[MISCREG_ID_MMFR0] & ~0xf) | 0x5; 29510037SARM gem5 Developers } 29610037SARM gem5 Developers 29710037SARM gem5 Developers if (haveSecurity) { 29810037SARM gem5 Developers miscRegs[MISCREG_SCTLR_S] = sctlr; 29910037SARM gem5 Developers miscRegs[MISCREG_SCR] = 0; 30010037SARM gem5 Developers miscRegs[MISCREG_VBAR_S] = 0; 30110037SARM gem5 Developers } else { 30210037SARM gem5 Developers // we're always non-secure 30310037SARM gem5 Developers miscRegs[MISCREG_SCR] = 1; 30410037SARM gem5 Developers } 3058147SAli.Saidi@ARM.com 3067427Sgblack@eecs.umich.edu //XXX We need to initialize the rest of the state. 3077427Sgblack@eecs.umich.edu} 3087427Sgblack@eecs.umich.edu 30910037SARM gem5 Developersvoid 31010037SARM gem5 DevelopersISA::clear64(const ArmISAParams *p) 31110037SARM gem5 Developers{ 31210037SARM gem5 Developers CPSR cpsr = 0; 31310037SARM gem5 Developers Addr rvbar = system->resetAddr64(); 31410037SARM gem5 Developers switch (system->highestEL()) { 31510037SARM gem5 Developers // Set initial EL to highest implemented EL using associated stack 31610037SARM gem5 Developers // pointer (SP_ELx); set RVBAR_ELx to implementation defined reset 31710037SARM gem5 Developers // value 31810037SARM gem5 Developers case EL3: 31910037SARM gem5 Developers cpsr.mode = MODE_EL3H; 32010037SARM gem5 Developers miscRegs[MISCREG_RVBAR_EL3] = rvbar; 32110037SARM gem5 Developers break; 32210037SARM gem5 Developers case EL2: 32310037SARM gem5 Developers cpsr.mode = MODE_EL2H; 32410037SARM gem5 Developers miscRegs[MISCREG_RVBAR_EL2] = rvbar; 32510037SARM gem5 Developers break; 32610037SARM gem5 Developers case EL1: 32710037SARM gem5 Developers cpsr.mode = MODE_EL1H; 32810037SARM gem5 Developers miscRegs[MISCREG_RVBAR_EL1] = rvbar; 32910037SARM gem5 Developers break; 33010037SARM gem5 Developers default: 33110037SARM gem5 Developers panic("Invalid highest implemented exception level"); 33210037SARM gem5 Developers break; 33310037SARM gem5 Developers } 33410037SARM gem5 Developers 33510037SARM gem5 Developers // Initialize rest of CPSR 33610037SARM gem5 Developers cpsr.daif = 0xf; // Mask all interrupts 33710037SARM gem5 Developers cpsr.ss = 0; 33810037SARM gem5 Developers cpsr.il = 0; 33910037SARM gem5 Developers miscRegs[MISCREG_CPSR] = cpsr; 34010037SARM gem5 Developers updateRegMap(cpsr); 34110037SARM gem5 Developers 34210037SARM gem5 Developers // Initialize other control registers 34310037SARM gem5 Developers miscRegs[MISCREG_MPIDR_EL1] = 0x80000000; 34410037SARM gem5 Developers if (haveSecurity) { 34510037SARM gem5 Developers miscRegs[MISCREG_SCTLR_EL3] = 0x30c50870; 34610037SARM gem5 Developers miscRegs[MISCREG_SCR_EL3] = 0x00000030; // RES1 fields 34710037SARM gem5 Developers // @todo: uncomment this to enable Virtualization 34810037SARM gem5 Developers // } else if (haveVirtualization) { 34910037SARM gem5 Developers // miscRegs[MISCREG_SCTLR_EL2] = 0x30c50870; 35010037SARM gem5 Developers } else { 35110037SARM gem5 Developers miscRegs[MISCREG_SCTLR_EL1] = 0x30c50870; 35210037SARM gem5 Developers // Always non-secure 35310037SARM gem5 Developers miscRegs[MISCREG_SCR_EL3] = 1; 35410037SARM gem5 Developers } 35510037SARM gem5 Developers 35610037SARM gem5 Developers // Initialize configurable id registers 35710037SARM gem5 Developers miscRegs[MISCREG_ID_AA64AFR0_EL1] = p->id_aa64afr0_el1; 35810037SARM gem5 Developers miscRegs[MISCREG_ID_AA64AFR1_EL1] = p->id_aa64afr1_el1; 35910037SARM gem5 Developers miscRegs[MISCREG_ID_AA64DFR0_EL1] = p->id_aa64dfr0_el1; 36010037SARM gem5 Developers miscRegs[MISCREG_ID_AA64DFR1_EL1] = p->id_aa64dfr1_el1; 36110037SARM gem5 Developers miscRegs[MISCREG_ID_AA64ISAR0_EL1] = p->id_aa64isar0_el1; 36210037SARM gem5 Developers miscRegs[MISCREG_ID_AA64ISAR1_EL1] = p->id_aa64isar1_el1; 36310037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1] = p->id_aa64mmfr0_el1; 36410037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR1_EL1] = p->id_aa64mmfr1_el1; 36510037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1] = p->id_aa64pfr0_el1; 36610037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR1_EL1] = p->id_aa64pfr1_el1; 36710037SARM gem5 Developers 36810037SARM gem5 Developers // Enforce consistency with system-level settings... 36910037SARM gem5 Developers 37010037SARM gem5 Developers // EL3 37110037SARM gem5 Developers // (no AArch32/64 interprocessing support for now) 37210037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1] = insertBits( 37310037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1], 15, 12, 37410037SARM gem5 Developers haveSecurity ? 0x1 : 0x0); 37510037SARM gem5 Developers // EL2 37610037SARM gem5 Developers // (no AArch32/64 interprocessing support for now) 37710037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1] = insertBits( 37810037SARM gem5 Developers miscRegs[MISCREG_ID_AA64PFR0_EL1], 11, 8, 37910037SARM gem5 Developers haveVirtualization ? 0x1 : 0x0); 38010037SARM gem5 Developers // Large ASID support 38110037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1] = insertBits( 38210037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1], 7, 4, 38310037SARM gem5 Developers haveLargeAsid64 ? 0x2 : 0x0); 38410037SARM gem5 Developers // Physical address size 38510037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1] = insertBits( 38610037SARM gem5 Developers miscRegs[MISCREG_ID_AA64MMFR0_EL1], 3, 0, 38710037SARM gem5 Developers encodePhysAddrRange64(physAddrRange64)); 38810037SARM gem5 Developers} 38910037SARM gem5 Developers 3907405SAli.Saidi@ARM.comMiscReg 39110035Sandreas.hansson@arm.comISA::readMiscRegNoEffect(int misc_reg) const 3927405SAli.Saidi@ARM.com{ 3937405SAli.Saidi@ARM.com assert(misc_reg < NumMiscRegs); 3947614Sminkyu.jeong@arm.com 39510037SARM gem5 Developers int flat_idx = flattenMiscIndex(misc_reg); // Note: indexes of AArch64 39610037SARM gem5 Developers // registers are left unchanged 39710037SARM gem5 Developers MiscReg val; 3987614Sminkyu.jeong@arm.com 39910037SARM gem5 Developers if (lookUpMiscReg[flat_idx].lower == 0 || flat_idx == MISCREG_SPSR 40010037SARM gem5 Developers || flat_idx == MISCREG_SCTLR_EL1) { 40110037SARM gem5 Developers if (flat_idx == MISCREG_SPSR) 40210037SARM gem5 Developers flat_idx = flattenMiscIndex(MISCREG_SPSR); 40310037SARM gem5 Developers if (flat_idx == MISCREG_SCTLR_EL1) 40410037SARM gem5 Developers flat_idx = flattenMiscIndex(MISCREG_SCTLR); 40510037SARM gem5 Developers val = miscRegs[flat_idx]; 40610037SARM gem5 Developers } else 40710037SARM gem5 Developers if (lookUpMiscReg[flat_idx].upper > 0) 40810037SARM gem5 Developers val = ((miscRegs[lookUpMiscReg[flat_idx].lower] & mask(32)) 40910037SARM gem5 Developers | (miscRegs[lookUpMiscReg[flat_idx].upper] << 32)); 41010037SARM gem5 Developers else 41110037SARM gem5 Developers val = miscRegs[lookUpMiscReg[flat_idx].lower]; 41210037SARM gem5 Developers 4137614Sminkyu.jeong@arm.com return val; 4147405SAli.Saidi@ARM.com} 4157405SAli.Saidi@ARM.com 4167405SAli.Saidi@ARM.com 4177405SAli.Saidi@ARM.comMiscReg 4187405SAli.Saidi@ARM.comISA::readMiscReg(int misc_reg, ThreadContext *tc) 4197405SAli.Saidi@ARM.com{ 42010037SARM gem5 Developers CPSR cpsr = 0; 42110037SARM gem5 Developers PCState pc = 0; 42210037SARM gem5 Developers SCR scr = 0; 4239050Schander.sudanthi@arm.com 4247405SAli.Saidi@ARM.com if (misc_reg == MISCREG_CPSR) { 42510037SARM gem5 Developers cpsr = miscRegs[misc_reg]; 42610037SARM gem5 Developers pc = tc->pcState(); 4277720Sgblack@eecs.umich.edu cpsr.j = pc.jazelle() ? 1 : 0; 4287720Sgblack@eecs.umich.edu cpsr.t = pc.thumb() ? 1 : 0; 4297405SAli.Saidi@ARM.com return cpsr; 4307405SAli.Saidi@ARM.com } 4317757SAli.Saidi@ARM.com 43210037SARM gem5 Developers#ifndef NDEBUG 43310037SARM gem5 Developers if (!miscRegInfo[misc_reg][MISCREG_IMPLEMENTED]) { 43410037SARM gem5 Developers if (miscRegInfo[misc_reg][MISCREG_WARN_NOT_FAIL]) 43510037SARM gem5 Developers warn("Unimplemented system register %s read.\n", 43610037SARM gem5 Developers miscRegName[misc_reg]); 43710037SARM gem5 Developers else 43810037SARM gem5 Developers panic("Unimplemented system register %s read.\n", 43910037SARM gem5 Developers miscRegName[misc_reg]); 44010037SARM gem5 Developers } 44110037SARM gem5 Developers#endif 44210037SARM gem5 Developers 44310037SARM gem5 Developers switch (unflattenMiscReg(misc_reg)) { 44410037SARM gem5 Developers case MISCREG_HCR: 44510037SARM gem5 Developers { 44610037SARM gem5 Developers if (!haveVirtualization) 44710037SARM gem5 Developers return 0; 44810037SARM gem5 Developers else 44910037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_HCR); 45010037SARM gem5 Developers } 45110037SARM gem5 Developers case MISCREG_CPACR: 45210037SARM gem5 Developers { 45310037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 45410037SARM gem5 Developers CPACR cpacrMask = 0; 45510037SARM gem5 Developers // Only cp10, cp11, and ase are implemented, nothing else should 45610037SARM gem5 Developers // be readable? (straight copy from the write code) 45710037SARM gem5 Developers cpacrMask.cp10 = ones; 45810037SARM gem5 Developers cpacrMask.cp11 = ones; 45910037SARM gem5 Developers cpacrMask.asedis = ones; 46010037SARM gem5 Developers 46110037SARM gem5 Developers // Security Extensions may limit the readability of CPACR 46210037SARM gem5 Developers if (haveSecurity) { 46310037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 46410037SARM gem5 Developers cpsr = readMiscRegNoEffect(MISCREG_CPSR); 46510037SARM gem5 Developers if (scr.ns && (cpsr.mode != MODE_MON)) { 46610037SARM gem5 Developers NSACR nsacr = readMiscRegNoEffect(MISCREG_NSACR); 46710037SARM gem5 Developers // NB: Skipping the full loop, here 46810037SARM gem5 Developers if (!nsacr.cp10) cpacrMask.cp10 = 0; 46910037SARM gem5 Developers if (!nsacr.cp11) cpacrMask.cp11 = 0; 47010037SARM gem5 Developers } 47110037SARM gem5 Developers } 47210037SARM gem5 Developers MiscReg val = readMiscRegNoEffect(MISCREG_CPACR); 47310037SARM gem5 Developers val &= cpacrMask; 47410037SARM gem5 Developers DPRINTF(MiscRegs, "Reading misc reg %s: %#x\n", 47510037SARM gem5 Developers miscRegName[misc_reg], val); 47610037SARM gem5 Developers return val; 47710037SARM gem5 Developers } 4788284SAli.Saidi@ARM.com case MISCREG_MPIDR: 47910037SARM gem5 Developers cpsr = readMiscRegNoEffect(MISCREG_CPSR); 48010037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 48110037SARM gem5 Developers if ((cpsr.mode == MODE_HYP) || inSecureState(scr, cpsr)) { 48210037SARM gem5 Developers return getMPIDR(system, tc); 4839050Schander.sudanthi@arm.com } else { 48410037SARM gem5 Developers return readMiscReg(MISCREG_VMPIDR, tc); 48510037SARM gem5 Developers } 48610037SARM gem5 Developers break; 48710037SARM gem5 Developers case MISCREG_MPIDR_EL1: 48810037SARM gem5 Developers // @todo in the absence of v8 virtualization support just return MPIDR_EL1 48910037SARM gem5 Developers return getMPIDR(system, tc) & 0xffffffff; 49010037SARM gem5 Developers case MISCREG_VMPIDR: 49110037SARM gem5 Developers // top bit defined as RES1 49210037SARM gem5 Developers return readMiscRegNoEffect(misc_reg) | 0x80000000; 49310037SARM gem5 Developers case MISCREG_ID_AFR0: // not implemented, so alias MIDR 49410037SARM gem5 Developers case MISCREG_ID_DFR0: // not implemented, so alias MIDR 49510037SARM gem5 Developers case MISCREG_REVIDR: // not implemented, so alias MIDR 49610037SARM gem5 Developers case MISCREG_MIDR: 49710037SARM gem5 Developers cpsr = readMiscRegNoEffect(MISCREG_CPSR); 49810037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 49910037SARM gem5 Developers if ((cpsr.mode == MODE_HYP) || inSecureState(scr, cpsr)) { 50010037SARM gem5 Developers return readMiscRegNoEffect(misc_reg); 50110037SARM gem5 Developers } else { 50210037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_VPIDR); 5039050Schander.sudanthi@arm.com } 5048284SAli.Saidi@ARM.com break; 50510037SARM gem5 Developers case MISCREG_JOSCR: // Jazelle trivial implementation, RAZ/WI 50610037SARM gem5 Developers case MISCREG_JMCR: // Jazelle trivial implementation, RAZ/WI 50710037SARM gem5 Developers case MISCREG_JIDR: // Jazelle trivial implementation, RAZ/WI 50810037SARM gem5 Developers case MISCREG_AIDR: // AUX ID set to 0 50910037SARM gem5 Developers case MISCREG_TCMTR: // No TCM's 51010037SARM gem5 Developers return 0; 51110037SARM gem5 Developers 5127405SAli.Saidi@ARM.com case MISCREG_CLIDR: 5137731SAli.Saidi@ARM.com warn_once("The clidr register always reports 0 caches.\n"); 5148468Swade.walker@arm.com warn_once("clidr LoUIS field of 0b001 to match current " 5158468Swade.walker@arm.com "ARM implementations.\n"); 5168468Swade.walker@arm.com return 0x00200000; 5177405SAli.Saidi@ARM.com case MISCREG_CCSIDR: 5187731SAli.Saidi@ARM.com warn_once("The ccsidr register isn't implemented and " 5197405SAli.Saidi@ARM.com "always reads as 0.\n"); 5207405SAli.Saidi@ARM.com break; 5217583SAli.Saidi@arm.com case MISCREG_CTR: 5229130Satgutier@umich.edu { 5239130Satgutier@umich.edu //all caches have the same line size in gem5 5249130Satgutier@umich.edu //4 byte words in ARM 5259130Satgutier@umich.edu unsigned lineSizeWords = 5269814Sandreas.hansson@arm.com tc->getSystemPtr()->cacheLineSize() / 4; 5279130Satgutier@umich.edu unsigned log2LineSizeWords = 0; 5289130Satgutier@umich.edu 5299130Satgutier@umich.edu while (lineSizeWords >>= 1) { 5309130Satgutier@umich.edu ++log2LineSizeWords; 5319130Satgutier@umich.edu } 5329130Satgutier@umich.edu 5339130Satgutier@umich.edu CTR ctr = 0; 5349130Satgutier@umich.edu //log2 of minimun i-cache line size (words) 5359130Satgutier@umich.edu ctr.iCacheLineSize = log2LineSizeWords; 5369130Satgutier@umich.edu //b11 - gem5 uses pipt 5379130Satgutier@umich.edu ctr.l1IndexPolicy = 0x3; 5389130Satgutier@umich.edu //log2 of minimum d-cache line size (words) 5399130Satgutier@umich.edu ctr.dCacheLineSize = log2LineSizeWords; 5409130Satgutier@umich.edu //log2 of max reservation size (words) 5419130Satgutier@umich.edu ctr.erg = log2LineSizeWords; 5429130Satgutier@umich.edu //log2 of max writeback size (words) 5439130Satgutier@umich.edu ctr.cwg = log2LineSizeWords; 5449130Satgutier@umich.edu //b100 - gem5 format is ARMv7 5459130Satgutier@umich.edu ctr.format = 0x4; 5469130Satgutier@umich.edu 5479130Satgutier@umich.edu return ctr; 5489130Satgutier@umich.edu } 5497583SAli.Saidi@arm.com case MISCREG_ACTLR: 5507583SAli.Saidi@arm.com warn("Not doing anything for miscreg ACTLR\n"); 5517583SAli.Saidi@arm.com break; 5527583SAli.Saidi@arm.com case MISCREG_PMCR: 5537583SAli.Saidi@arm.com case MISCREG_PMCCNTR: 5547583SAli.Saidi@arm.com case MISCREG_PMSELR: 5558299Schander.sudanthi@arm.com warn("Not doing anything for read to miscreg %s\n", 5567583SAli.Saidi@arm.com miscRegName[misc_reg]); 5577583SAli.Saidi@arm.com break; 5588302SAli.Saidi@ARM.com case MISCREG_CPSR_Q: 5598302SAli.Saidi@ARM.com panic("shouldn't be reading this register seperately\n"); 5607783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_QC: 5617783SGiacomo.Gabrielli@arm.com return readMiscRegNoEffect(MISCREG_FPSCR) & ~FpscrQcMask; 5627783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_EXC: 5637783SGiacomo.Gabrielli@arm.com return readMiscRegNoEffect(MISCREG_FPSCR) & ~FpscrExcMask; 56410037SARM gem5 Developers case MISCREG_FPSR: 56510037SARM gem5 Developers { 56610037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 56710037SARM gem5 Developers FPSCR fpscrMask = 0; 56810037SARM gem5 Developers fpscrMask.ioc = ones; 56910037SARM gem5 Developers fpscrMask.dzc = ones; 57010037SARM gem5 Developers fpscrMask.ofc = ones; 57110037SARM gem5 Developers fpscrMask.ufc = ones; 57210037SARM gem5 Developers fpscrMask.ixc = ones; 57310037SARM gem5 Developers fpscrMask.idc = ones; 57410037SARM gem5 Developers fpscrMask.qc = ones; 57510037SARM gem5 Developers fpscrMask.v = ones; 57610037SARM gem5 Developers fpscrMask.c = ones; 57710037SARM gem5 Developers fpscrMask.z = ones; 57810037SARM gem5 Developers fpscrMask.n = ones; 57910037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_FPSCR) & (uint32_t)fpscrMask; 58010037SARM gem5 Developers } 58110037SARM gem5 Developers case MISCREG_FPCR: 58210037SARM gem5 Developers { 58310037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 58410037SARM gem5 Developers FPSCR fpscrMask = 0; 58510037SARM gem5 Developers fpscrMask.ioe = ones; 58610037SARM gem5 Developers fpscrMask.dze = ones; 58710037SARM gem5 Developers fpscrMask.ofe = ones; 58810037SARM gem5 Developers fpscrMask.ufe = ones; 58910037SARM gem5 Developers fpscrMask.ixe = ones; 59010037SARM gem5 Developers fpscrMask.ide = ones; 59110037SARM gem5 Developers fpscrMask.len = ones; 59210037SARM gem5 Developers fpscrMask.stride = ones; 59310037SARM gem5 Developers fpscrMask.rMode = ones; 59410037SARM gem5 Developers fpscrMask.fz = ones; 59510037SARM gem5 Developers fpscrMask.dn = ones; 59610037SARM gem5 Developers fpscrMask.ahp = ones; 59710037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_FPSCR) & (uint32_t)fpscrMask; 59810037SARM gem5 Developers } 59910037SARM gem5 Developers case MISCREG_NZCV: 60010037SARM gem5 Developers { 60110037SARM gem5 Developers CPSR cpsr = 0; 60210338SCurtis.Dunham@arm.com cpsr.nz = tc->readCCReg(CCREG_NZ); 60310338SCurtis.Dunham@arm.com cpsr.c = tc->readCCReg(CCREG_C); 60410338SCurtis.Dunham@arm.com cpsr.v = tc->readCCReg(CCREG_V); 60510037SARM gem5 Developers return cpsr; 60610037SARM gem5 Developers } 60710037SARM gem5 Developers case MISCREG_DAIF: 60810037SARM gem5 Developers { 60910037SARM gem5 Developers CPSR cpsr = 0; 61010037SARM gem5 Developers cpsr.daif = (uint8_t) ((CPSR) miscRegs[MISCREG_CPSR]).daif; 61110037SARM gem5 Developers return cpsr; 61210037SARM gem5 Developers } 61310037SARM gem5 Developers case MISCREG_SP_EL0: 61410037SARM gem5 Developers { 61510037SARM gem5 Developers return tc->readIntReg(INTREG_SP0); 61610037SARM gem5 Developers } 61710037SARM gem5 Developers case MISCREG_SP_EL1: 61810037SARM gem5 Developers { 61910037SARM gem5 Developers return tc->readIntReg(INTREG_SP1); 62010037SARM gem5 Developers } 62110037SARM gem5 Developers case MISCREG_SP_EL2: 62210037SARM gem5 Developers { 62310037SARM gem5 Developers return tc->readIntReg(INTREG_SP2); 62410037SARM gem5 Developers } 62510037SARM gem5 Developers case MISCREG_SPSEL: 62610037SARM gem5 Developers { 62710037SARM gem5 Developers return miscRegs[MISCREG_CPSR] & 0x1; 62810037SARM gem5 Developers } 62910037SARM gem5 Developers case MISCREG_CURRENTEL: 63010037SARM gem5 Developers { 63110037SARM gem5 Developers return miscRegs[MISCREG_CPSR] & 0xc; 63210037SARM gem5 Developers } 6338549Sdaniel.johnson@arm.com case MISCREG_L2CTLR: 6348868SMatt.Horsnell@arm.com { 6358868SMatt.Horsnell@arm.com // mostly unimplemented, just set NumCPUs field from sim and return 6368868SMatt.Horsnell@arm.com L2CTLR l2ctlr = 0; 6378868SMatt.Horsnell@arm.com // b00:1CPU to b11:4CPUs 6388868SMatt.Horsnell@arm.com l2ctlr.numCPUs = tc->getSystemPtr()->numContexts() - 1; 6398868SMatt.Horsnell@arm.com return l2ctlr; 6408868SMatt.Horsnell@arm.com } 6418868SMatt.Horsnell@arm.com case MISCREG_DBGDIDR: 6428868SMatt.Horsnell@arm.com /* For now just implement the version number. 6438868SMatt.Horsnell@arm.com * Return 0 as we don't support debug architecture yet. 6448868SMatt.Horsnell@arm.com */ 6459130Satgutier@umich.edu return 0; 64610037SARM gem5 Developers case MISCREG_DBGDSCRint: 6478868SMatt.Horsnell@arm.com return 0; 64810037SARM gem5 Developers case MISCREG_ISR: 64910037SARM gem5 Developers return tc->getCpuPtr()->getInterruptController()->getISR( 65010037SARM gem5 Developers readMiscRegNoEffect(MISCREG_HCR), 65110037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR), 65210037SARM gem5 Developers readMiscRegNoEffect(MISCREG_SCR)); 65310037SARM gem5 Developers case MISCREG_ISR_EL1: 65410037SARM gem5 Developers return tc->getCpuPtr()->getInterruptController()->getISR( 65510037SARM gem5 Developers readMiscRegNoEffect(MISCREG_HCR_EL2), 65610037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR), 65710037SARM gem5 Developers readMiscRegNoEffect(MISCREG_SCR_EL3)); 65810037SARM gem5 Developers case MISCREG_DCZID_EL0: 65910037SARM gem5 Developers return 0x04; // DC ZVA clear 64-byte chunks 66010037SARM gem5 Developers case MISCREG_HCPTR: 66110037SARM gem5 Developers { 66210037SARM gem5 Developers MiscReg val = readMiscRegNoEffect(misc_reg); 66310037SARM gem5 Developers // The trap bit associated with CP14 is defined as RAZ 66410037SARM gem5 Developers val &= ~(1 << 14); 66510037SARM gem5 Developers // If a CP bit in NSACR is 0 then the corresponding bit in 66610037SARM gem5 Developers // HCPTR is RAO/WI 66710037SARM gem5 Developers bool secure_lookup = haveSecurity && 66810037SARM gem5 Developers inSecureState(readMiscRegNoEffect(MISCREG_SCR), 66910037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR)); 67010037SARM gem5 Developers if (!secure_lookup) { 67110037SARM gem5 Developers MiscReg mask = readMiscRegNoEffect(MISCREG_NSACR); 67210037SARM gem5 Developers val |= (mask ^ 0x7FFF) & 0xBFFF; 67310037SARM gem5 Developers } 67410037SARM gem5 Developers // Set the bits for unimplemented coprocessors to RAO/WI 67510037SARM gem5 Developers val |= 0x33FF; 67610037SARM gem5 Developers return (val); 67710037SARM gem5 Developers } 67810037SARM gem5 Developers case MISCREG_HDFAR: // alias for secure DFAR 67910037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_DFAR_S); 68010037SARM gem5 Developers case MISCREG_HIFAR: // alias for secure IFAR 68110037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_IFAR_S); 68210037SARM gem5 Developers case MISCREG_HVBAR: // bottom bits reserved 68310037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_HVBAR) & 0xFFFFFFE0; 68410037SARM gem5 Developers case MISCREG_SCTLR: // Some bits hardwired 68510037SARM gem5 Developers // The FI field (bit 21) is common between S/NS versions of the register 68610037SARM gem5 Developers return (readMiscRegNoEffect(MISCREG_SCTLR_S) & (1 << 21)) | 68710037SARM gem5 Developers (readMiscRegNoEffect(misc_reg) & 0x72DD39FF) | 0x00C00818; // V8 SCTLR 68810037SARM gem5 Developers case MISCREG_SCTLR_EL1: 68910037SARM gem5 Developers // The FI field (bit 21) is common between S/NS versions of the register 69010037SARM gem5 Developers return (readMiscRegNoEffect(MISCREG_SCTLR_S) & (1 << 21)) | 69110037SARM gem5 Developers (readMiscRegNoEffect(misc_reg) & 0x37DDDBFF) | 0x30D00800; // V8 SCTLR_EL1 69210037SARM gem5 Developers case MISCREG_SCTLR_EL3: 69310037SARM gem5 Developers // The FI field (bit 21) is common between S/NS versions of the register 69410037SARM gem5 Developers return (readMiscRegNoEffect(MISCREG_SCTLR_S) & (1 << 21)) | 69510037SARM gem5 Developers (readMiscRegNoEffect(misc_reg) & 0x32CD183F) | 0x30C50830; // V8 SCTLR_EL3 69610037SARM gem5 Developers case MISCREG_HSCTLR: // FI comes from SCTLR 69710037SARM gem5 Developers { 69810037SARM gem5 Developers uint32_t mask = 1 << 27; 69910037SARM gem5 Developers return (readMiscRegNoEffect(MISCREG_HSCTLR) & ~mask) | 70010037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_SCTLR) & mask); 70110037SARM gem5 Developers } 70210037SARM gem5 Developers case MISCREG_SCR: 70310037SARM gem5 Developers { 70410037SARM gem5 Developers CPSR cpsr = readMiscRegNoEffect(MISCREG_CPSR); 70510037SARM gem5 Developers if (cpsr.width) { 70610037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_SCR); 70710037SARM gem5 Developers } else { 70810037SARM gem5 Developers return readMiscRegNoEffect(MISCREG_SCR_EL3); 70910037SARM gem5 Developers } 71010037SARM gem5 Developers } 71110037SARM gem5 Developers // Generic Timer registers 71210037SARM gem5 Developers case MISCREG_CNTFRQ: 71310037SARM gem5 Developers case MISCREG_CNTFRQ_EL0: 71410037SARM gem5 Developers inform_once("Read CNTFREQ_EL0 frequency\n"); 71510037SARM gem5 Developers return getSystemCounter(tc)->freq(); 71610037SARM gem5 Developers case MISCREG_CNTPCT: 71710037SARM gem5 Developers case MISCREG_CNTPCT_EL0: 71810037SARM gem5 Developers return getSystemCounter(tc)->value(); 71910037SARM gem5 Developers case MISCREG_CNTVCT: 72010037SARM gem5 Developers return getSystemCounter(tc)->value(); 72110037SARM gem5 Developers case MISCREG_CNTVCT_EL0: 72210037SARM gem5 Developers return getSystemCounter(tc)->value(); 72310037SARM gem5 Developers case MISCREG_CNTP_CVAL: 72410037SARM gem5 Developers case MISCREG_CNTP_CVAL_EL0: 72510037SARM gem5 Developers return getArchTimer(tc, tc->cpuId())->compareValue(); 72610037SARM gem5 Developers case MISCREG_CNTP_TVAL: 72710037SARM gem5 Developers case MISCREG_CNTP_TVAL_EL0: 72810037SARM gem5 Developers return getArchTimer(tc, tc->cpuId())->timerValue(); 72910037SARM gem5 Developers case MISCREG_CNTP_CTL: 73010037SARM gem5 Developers case MISCREG_CNTP_CTL_EL0: 73110037SARM gem5 Developers return getArchTimer(tc, tc->cpuId())->control(); 73210037SARM gem5 Developers // PL1 phys. timer, secure 73310037SARM gem5 Developers // AArch64 73410188Sgeoffrey.blake@arm.com // case MISCREG_CNTPS_CVAL_EL1: 73510188Sgeoffrey.blake@arm.com // case MISCREG_CNTPS_TVAL_EL1: 73610188Sgeoffrey.blake@arm.com // case MISCREG_CNTPS_CTL_EL1: 73710037SARM gem5 Developers // PL2 phys. timer, non-secure 73810037SARM gem5 Developers // AArch32 73910188Sgeoffrey.blake@arm.com // case MISCREG_CNTHCTL: 74010188Sgeoffrey.blake@arm.com // case MISCREG_CNTHP_CVAL: 74110188Sgeoffrey.blake@arm.com // case MISCREG_CNTHP_TVAL: 74210188Sgeoffrey.blake@arm.com // case MISCREG_CNTHP_CTL: 74310037SARM gem5 Developers // AArch64 74410188Sgeoffrey.blake@arm.com // case MISCREG_CNTHCTL_EL2: 74510188Sgeoffrey.blake@arm.com // case MISCREG_CNTHP_CVAL_EL2: 74610188Sgeoffrey.blake@arm.com // case MISCREG_CNTHP_TVAL_EL2: 74710188Sgeoffrey.blake@arm.com // case MISCREG_CNTHP_CTL_EL2: 74810037SARM gem5 Developers // Virtual timer 74910037SARM gem5 Developers // AArch32 75010188Sgeoffrey.blake@arm.com // case MISCREG_CNTV_CVAL: 75110188Sgeoffrey.blake@arm.com // case MISCREG_CNTV_TVAL: 75210188Sgeoffrey.blake@arm.com // case MISCREG_CNTV_CTL: 75310037SARM gem5 Developers // AArch64 75410037SARM gem5 Developers // case MISCREG_CNTV_CVAL_EL2: 75510037SARM gem5 Developers // case MISCREG_CNTV_TVAL_EL2: 75610037SARM gem5 Developers // case MISCREG_CNTV_CTL_EL2: 75710188Sgeoffrey.blake@arm.com default: 75810037SARM gem5 Developers break; 75910037SARM gem5 Developers 7607405SAli.Saidi@ARM.com } 7617405SAli.Saidi@ARM.com return readMiscRegNoEffect(misc_reg); 7627405SAli.Saidi@ARM.com} 7637405SAli.Saidi@ARM.com 7647405SAli.Saidi@ARM.comvoid 7657405SAli.Saidi@ARM.comISA::setMiscRegNoEffect(int misc_reg, const MiscReg &val) 7667405SAli.Saidi@ARM.com{ 7677405SAli.Saidi@ARM.com assert(misc_reg < NumMiscRegs); 7687614Sminkyu.jeong@arm.com 76910037SARM gem5 Developers int flat_idx = flattenMiscIndex(misc_reg); // Note: indexes of AArch64 77010037SARM gem5 Developers // registers are left unchanged 7717614Sminkyu.jeong@arm.com 77210037SARM gem5 Developers int flat_idx2 = lookUpMiscReg[flat_idx].upper; 77310037SARM gem5 Developers 77410037SARM gem5 Developers if (flat_idx2 > 0) { 77510037SARM gem5 Developers miscRegs[lookUpMiscReg[flat_idx].lower] = bits(val, 31, 0); 77610037SARM gem5 Developers miscRegs[flat_idx2] = bits(val, 63, 32); 77710037SARM gem5 Developers DPRINTF(MiscRegs, "Writing to misc reg %d (%d:%d) : %#x\n", 77810037SARM gem5 Developers misc_reg, flat_idx, flat_idx2, val); 77910037SARM gem5 Developers } else { 78010037SARM gem5 Developers if (flat_idx == MISCREG_SPSR) 78110037SARM gem5 Developers flat_idx = flattenMiscIndex(MISCREG_SPSR); 78210037SARM gem5 Developers else if (flat_idx == MISCREG_SCTLR_EL1) 78310037SARM gem5 Developers flat_idx = flattenMiscIndex(MISCREG_SCTLR); 78410037SARM gem5 Developers else 78510037SARM gem5 Developers flat_idx = (lookUpMiscReg[flat_idx].lower > 0) ? 78610037SARM gem5 Developers lookUpMiscReg[flat_idx].lower : flat_idx; 78710037SARM gem5 Developers miscRegs[flat_idx] = val; 78810037SARM gem5 Developers DPRINTF(MiscRegs, "Writing to misc reg %d (%d) : %#x\n", 78910037SARM gem5 Developers misc_reg, flat_idx, val); 79010037SARM gem5 Developers } 7917405SAli.Saidi@ARM.com} 7927405SAli.Saidi@ARM.com 7937405SAli.Saidi@ARM.comvoid 7947405SAli.Saidi@ARM.comISA::setMiscReg(int misc_reg, const MiscReg &val, ThreadContext *tc) 7957405SAli.Saidi@ARM.com{ 7967749SAli.Saidi@ARM.com 7977405SAli.Saidi@ARM.com MiscReg newVal = val; 7988284SAli.Saidi@ARM.com int x; 79910037SARM gem5 Developers bool secure_lookup; 80010037SARM gem5 Developers bool hyp; 8018284SAli.Saidi@ARM.com System *sys; 8028284SAli.Saidi@ARM.com ThreadContext *oc; 80310037SARM gem5 Developers uint8_t target_el; 80410037SARM gem5 Developers uint16_t asid; 80510037SARM gem5 Developers SCR scr; 8068284SAli.Saidi@ARM.com 8077405SAli.Saidi@ARM.com if (misc_reg == MISCREG_CPSR) { 8087405SAli.Saidi@ARM.com updateRegMap(val); 8097749SAli.Saidi@ARM.com 8107749SAli.Saidi@ARM.com 8117749SAli.Saidi@ARM.com CPSR old_cpsr = miscRegs[MISCREG_CPSR]; 8127749SAli.Saidi@ARM.com int old_mode = old_cpsr.mode; 8137405SAli.Saidi@ARM.com CPSR cpsr = val; 8147749SAli.Saidi@ARM.com if (old_mode != cpsr.mode) { 8157749SAli.Saidi@ARM.com tc->getITBPtr()->invalidateMiscReg(); 8167749SAli.Saidi@ARM.com tc->getDTBPtr()->invalidateMiscReg(); 8177749SAli.Saidi@ARM.com } 8187749SAli.Saidi@ARM.com 8197614Sminkyu.jeong@arm.com DPRINTF(Arm, "Updating CPSR from %#x to %#x f:%d i:%d a:%d mode:%#x\n", 8207614Sminkyu.jeong@arm.com miscRegs[misc_reg], cpsr, cpsr.f, cpsr.i, cpsr.a, cpsr.mode); 8217720Sgblack@eecs.umich.edu PCState pc = tc->pcState(); 8227720Sgblack@eecs.umich.edu pc.nextThumb(cpsr.t); 8237720Sgblack@eecs.umich.edu pc.nextJazelle(cpsr.j); 8248887Sgeoffrey.blake@arm.com 8258887Sgeoffrey.blake@arm.com // Follow slightly different semantics if a CheckerCPU object 8268887Sgeoffrey.blake@arm.com // is connected 8278887Sgeoffrey.blake@arm.com CheckerCPU *checker = tc->getCheckerCpuPtr(); 8288887Sgeoffrey.blake@arm.com if (checker) { 8298887Sgeoffrey.blake@arm.com tc->pcStateNoRecord(pc); 8308887Sgeoffrey.blake@arm.com } else { 8318887Sgeoffrey.blake@arm.com tc->pcState(pc); 8328887Sgeoffrey.blake@arm.com } 8337408Sgblack@eecs.umich.edu } else { 83410037SARM gem5 Developers#ifndef NDEBUG 83510037SARM gem5 Developers if (!miscRegInfo[misc_reg][MISCREG_IMPLEMENTED]) { 83610037SARM gem5 Developers if (miscRegInfo[misc_reg][MISCREG_WARN_NOT_FAIL]) 83710037SARM gem5 Developers warn("Unimplemented system register %s write with %#x.\n", 83810037SARM gem5 Developers miscRegName[misc_reg], val); 83910037SARM gem5 Developers else 84010037SARM gem5 Developers panic("Unimplemented system register %s write with %#x.\n", 84110037SARM gem5 Developers miscRegName[misc_reg], val); 84210037SARM gem5 Developers } 84310037SARM gem5 Developers#endif 84410037SARM gem5 Developers switch (unflattenMiscReg(misc_reg)) { 8457408Sgblack@eecs.umich.edu case MISCREG_CPACR: 8467408Sgblack@eecs.umich.edu { 8478206SWilliam.Wang@arm.com 8488206SWilliam.Wang@arm.com const uint32_t ones = (uint32_t)(-1); 8498206SWilliam.Wang@arm.com CPACR cpacrMask = 0; 8508206SWilliam.Wang@arm.com // Only cp10, cp11, and ase are implemented, nothing else should 8518206SWilliam.Wang@arm.com // be writable 8528206SWilliam.Wang@arm.com cpacrMask.cp10 = ones; 8538206SWilliam.Wang@arm.com cpacrMask.cp11 = ones; 8548206SWilliam.Wang@arm.com cpacrMask.asedis = ones; 85510037SARM gem5 Developers 85610037SARM gem5 Developers // Security Extensions may limit the writability of CPACR 85710037SARM gem5 Developers if (haveSecurity) { 85810037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 85910037SARM gem5 Developers CPSR cpsr = readMiscRegNoEffect(MISCREG_CPSR); 86010037SARM gem5 Developers if (scr.ns && (cpsr.mode != MODE_MON)) { 86110037SARM gem5 Developers NSACR nsacr = readMiscRegNoEffect(MISCREG_NSACR); 86210037SARM gem5 Developers // NB: Skipping the full loop, here 86310037SARM gem5 Developers if (!nsacr.cp10) cpacrMask.cp10 = 0; 86410037SARM gem5 Developers if (!nsacr.cp11) cpacrMask.cp11 = 0; 86510037SARM gem5 Developers } 86610037SARM gem5 Developers } 86710037SARM gem5 Developers 86810037SARM gem5 Developers MiscReg old_val = readMiscRegNoEffect(MISCREG_CPACR); 8698206SWilliam.Wang@arm.com newVal &= cpacrMask; 87010037SARM gem5 Developers newVal |= old_val & ~cpacrMask; 87110037SARM gem5 Developers DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 87210037SARM gem5 Developers miscRegName[misc_reg], newVal); 87310037SARM gem5 Developers } 87410037SARM gem5 Developers break; 87510037SARM gem5 Developers case MISCREG_CPACR_EL1: 87610037SARM gem5 Developers { 87710037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 87810037SARM gem5 Developers CPACR cpacrMask = 0; 87910037SARM gem5 Developers cpacrMask.tta = ones; 88010037SARM gem5 Developers cpacrMask.fpen = ones; 88110037SARM gem5 Developers newVal &= cpacrMask; 88210037SARM gem5 Developers DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 88310037SARM gem5 Developers miscRegName[misc_reg], newVal); 88410037SARM gem5 Developers } 88510037SARM gem5 Developers break; 88610037SARM gem5 Developers case MISCREG_CPTR_EL2: 88710037SARM gem5 Developers { 88810037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 88910037SARM gem5 Developers CPTR cptrMask = 0; 89010037SARM gem5 Developers cptrMask.tcpac = ones; 89110037SARM gem5 Developers cptrMask.tta = ones; 89210037SARM gem5 Developers cptrMask.tfp = ones; 89310037SARM gem5 Developers newVal &= cptrMask; 89410037SARM gem5 Developers cptrMask = 0; 89510037SARM gem5 Developers cptrMask.res1_13_12_el2 = ones; 89610037SARM gem5 Developers cptrMask.res1_9_0_el2 = ones; 89710037SARM gem5 Developers newVal |= cptrMask; 89810037SARM gem5 Developers DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 89910037SARM gem5 Developers miscRegName[misc_reg], newVal); 90010037SARM gem5 Developers } 90110037SARM gem5 Developers break; 90210037SARM gem5 Developers case MISCREG_CPTR_EL3: 90310037SARM gem5 Developers { 90410037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 90510037SARM gem5 Developers CPTR cptrMask = 0; 90610037SARM gem5 Developers cptrMask.tcpac = ones; 90710037SARM gem5 Developers cptrMask.tta = ones; 90810037SARM gem5 Developers cptrMask.tfp = ones; 90910037SARM gem5 Developers newVal &= cptrMask; 9108206SWilliam.Wang@arm.com DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 9118206SWilliam.Wang@arm.com miscRegName[misc_reg], newVal); 9127408Sgblack@eecs.umich.edu } 9137408Sgblack@eecs.umich.edu break; 9147408Sgblack@eecs.umich.edu case MISCREG_CSSELR: 9157731SAli.Saidi@ARM.com warn_once("The csselr register isn't implemented.\n"); 9168206SWilliam.Wang@arm.com return; 91710037SARM gem5 Developers 91810037SARM gem5 Developers case MISCREG_DC_ZVA_Xt: 91910037SARM gem5 Developers warn("Calling DC ZVA! Not Implemeted! Expect WEIRD results\n"); 92010037SARM gem5 Developers return; 92110037SARM gem5 Developers 9227408Sgblack@eecs.umich.edu case MISCREG_FPSCR: 9237408Sgblack@eecs.umich.edu { 9247408Sgblack@eecs.umich.edu const uint32_t ones = (uint32_t)(-1); 9257408Sgblack@eecs.umich.edu FPSCR fpscrMask = 0; 9267408Sgblack@eecs.umich.edu fpscrMask.ioc = ones; 9277408Sgblack@eecs.umich.edu fpscrMask.dzc = ones; 9287408Sgblack@eecs.umich.edu fpscrMask.ofc = ones; 9297408Sgblack@eecs.umich.edu fpscrMask.ufc = ones; 9307408Sgblack@eecs.umich.edu fpscrMask.ixc = ones; 9317408Sgblack@eecs.umich.edu fpscrMask.idc = ones; 93210037SARM gem5 Developers fpscrMask.ioe = ones; 93310037SARM gem5 Developers fpscrMask.dze = ones; 93410037SARM gem5 Developers fpscrMask.ofe = ones; 93510037SARM gem5 Developers fpscrMask.ufe = ones; 93610037SARM gem5 Developers fpscrMask.ixe = ones; 93710037SARM gem5 Developers fpscrMask.ide = ones; 9387408Sgblack@eecs.umich.edu fpscrMask.len = ones; 9397408Sgblack@eecs.umich.edu fpscrMask.stride = ones; 9407408Sgblack@eecs.umich.edu fpscrMask.rMode = ones; 9417408Sgblack@eecs.umich.edu fpscrMask.fz = ones; 9427408Sgblack@eecs.umich.edu fpscrMask.dn = ones; 9437408Sgblack@eecs.umich.edu fpscrMask.ahp = ones; 9447408Sgblack@eecs.umich.edu fpscrMask.qc = ones; 9457408Sgblack@eecs.umich.edu fpscrMask.v = ones; 9467408Sgblack@eecs.umich.edu fpscrMask.c = ones; 9477408Sgblack@eecs.umich.edu fpscrMask.z = ones; 9487408Sgblack@eecs.umich.edu fpscrMask.n = ones; 9497408Sgblack@eecs.umich.edu newVal = (newVal & (uint32_t)fpscrMask) | 95010037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPSCR) & 95110037SARM gem5 Developers ~(uint32_t)fpscrMask); 9529377Sgblack@eecs.umich.edu tc->getDecoderPtr()->setContext(newVal); 9537408Sgblack@eecs.umich.edu } 9547408Sgblack@eecs.umich.edu break; 95510037SARM gem5 Developers case MISCREG_FPSR: 95610037SARM gem5 Developers { 95710037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 95810037SARM gem5 Developers FPSCR fpscrMask = 0; 95910037SARM gem5 Developers fpscrMask.ioc = ones; 96010037SARM gem5 Developers fpscrMask.dzc = ones; 96110037SARM gem5 Developers fpscrMask.ofc = ones; 96210037SARM gem5 Developers fpscrMask.ufc = ones; 96310037SARM gem5 Developers fpscrMask.ixc = ones; 96410037SARM gem5 Developers fpscrMask.idc = ones; 96510037SARM gem5 Developers fpscrMask.qc = ones; 96610037SARM gem5 Developers fpscrMask.v = ones; 96710037SARM gem5 Developers fpscrMask.c = ones; 96810037SARM gem5 Developers fpscrMask.z = ones; 96910037SARM gem5 Developers fpscrMask.n = ones; 97010037SARM gem5 Developers newVal = (newVal & (uint32_t)fpscrMask) | 97110037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPSCR) & 97210037SARM gem5 Developers ~(uint32_t)fpscrMask); 97310037SARM gem5 Developers misc_reg = MISCREG_FPSCR; 97410037SARM gem5 Developers } 97510037SARM gem5 Developers break; 97610037SARM gem5 Developers case MISCREG_FPCR: 97710037SARM gem5 Developers { 97810037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 97910037SARM gem5 Developers FPSCR fpscrMask = 0; 98010037SARM gem5 Developers fpscrMask.ioe = ones; 98110037SARM gem5 Developers fpscrMask.dze = ones; 98210037SARM gem5 Developers fpscrMask.ofe = ones; 98310037SARM gem5 Developers fpscrMask.ufe = ones; 98410037SARM gem5 Developers fpscrMask.ixe = ones; 98510037SARM gem5 Developers fpscrMask.ide = ones; 98610037SARM gem5 Developers fpscrMask.len = ones; 98710037SARM gem5 Developers fpscrMask.stride = ones; 98810037SARM gem5 Developers fpscrMask.rMode = ones; 98910037SARM gem5 Developers fpscrMask.fz = ones; 99010037SARM gem5 Developers fpscrMask.dn = ones; 99110037SARM gem5 Developers fpscrMask.ahp = ones; 99210037SARM gem5 Developers newVal = (newVal & (uint32_t)fpscrMask) | 99310037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPSCR) & 99410037SARM gem5 Developers ~(uint32_t)fpscrMask); 99510037SARM gem5 Developers misc_reg = MISCREG_FPSCR; 99610037SARM gem5 Developers } 99710037SARM gem5 Developers break; 9988302SAli.Saidi@ARM.com case MISCREG_CPSR_Q: 9998302SAli.Saidi@ARM.com { 10008302SAli.Saidi@ARM.com assert(!(newVal & ~CpsrMaskQ)); 100110037SARM gem5 Developers newVal = readMiscRegNoEffect(MISCREG_CPSR) | newVal; 10028302SAli.Saidi@ARM.com misc_reg = MISCREG_CPSR; 10038302SAli.Saidi@ARM.com } 10048302SAli.Saidi@ARM.com break; 10057783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_QC: 10067783SGiacomo.Gabrielli@arm.com { 100710037SARM gem5 Developers newVal = readMiscRegNoEffect(MISCREG_FPSCR) | 100810037SARM gem5 Developers (newVal & FpscrQcMask); 10097783SGiacomo.Gabrielli@arm.com misc_reg = MISCREG_FPSCR; 10107783SGiacomo.Gabrielli@arm.com } 10117783SGiacomo.Gabrielli@arm.com break; 10127783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_EXC: 10137783SGiacomo.Gabrielli@arm.com { 101410037SARM gem5 Developers newVal = readMiscRegNoEffect(MISCREG_FPSCR) | 101510037SARM gem5 Developers (newVal & FpscrExcMask); 10167783SGiacomo.Gabrielli@arm.com misc_reg = MISCREG_FPSCR; 10177783SGiacomo.Gabrielli@arm.com } 10187783SGiacomo.Gabrielli@arm.com break; 10197408Sgblack@eecs.umich.edu case MISCREG_FPEXC: 10207408Sgblack@eecs.umich.edu { 10218206SWilliam.Wang@arm.com // vfpv3 architecture, section B.6.1 of DDI04068 10228206SWilliam.Wang@arm.com // bit 29 - valid only if fpexc[31] is 0 10237408Sgblack@eecs.umich.edu const uint32_t fpexcMask = 0x60000000; 10247408Sgblack@eecs.umich.edu newVal = (newVal & fpexcMask) | 102510037SARM gem5 Developers (readMiscRegNoEffect(MISCREG_FPEXC) & ~fpexcMask); 10267408Sgblack@eecs.umich.edu } 10277408Sgblack@eecs.umich.edu break; 102810037SARM gem5 Developers case MISCREG_HCR: 102910037SARM gem5 Developers { 103010037SARM gem5 Developers if (!haveVirtualization) 103110037SARM gem5 Developers return; 103210037SARM gem5 Developers } 103310037SARM gem5 Developers break; 103410037SARM gem5 Developers case MISCREG_IFSR: 103510037SARM gem5 Developers { 103610037SARM gem5 Developers // ARM ARM (ARM DDI 0406C.b) B4.1.96 103710037SARM gem5 Developers const uint32_t ifsrMask = 103810037SARM gem5 Developers mask(31, 13) | mask(11, 11) | mask(8, 6); 103910037SARM gem5 Developers newVal = newVal & ~ifsrMask; 104010037SARM gem5 Developers } 104110037SARM gem5 Developers break; 104210037SARM gem5 Developers case MISCREG_DFSR: 104310037SARM gem5 Developers { 104410037SARM gem5 Developers // ARM ARM (ARM DDI 0406C.b) B4.1.52 104510037SARM gem5 Developers const uint32_t dfsrMask = mask(31, 14) | mask(8, 8); 104610037SARM gem5 Developers newVal = newVal & ~dfsrMask; 104710037SARM gem5 Developers } 104810037SARM gem5 Developers break; 104910037SARM gem5 Developers case MISCREG_AMAIR0: 105010037SARM gem5 Developers case MISCREG_AMAIR1: 105110037SARM gem5 Developers { 105210037SARM gem5 Developers // ARM ARM (ARM DDI 0406C.b) B4.1.5 105310037SARM gem5 Developers // Valid only with LPAE 105410037SARM gem5 Developers if (!haveLPAE) 105510037SARM gem5 Developers return; 105610037SARM gem5 Developers DPRINTF(MiscRegs, "Writing AMAIR: %#x\n", newVal); 105710037SARM gem5 Developers } 105810037SARM gem5 Developers break; 105910037SARM gem5 Developers case MISCREG_SCR: 106010037SARM gem5 Developers tc->getITBPtr()->invalidateMiscReg(); 106110037SARM gem5 Developers tc->getDTBPtr()->invalidateMiscReg(); 106210037SARM gem5 Developers break; 10637408Sgblack@eecs.umich.edu case MISCREG_SCTLR: 10647408Sgblack@eecs.umich.edu { 10657408Sgblack@eecs.umich.edu DPRINTF(MiscRegs, "Writing SCTLR: %#x\n", newVal); 106610037SARM gem5 Developers MiscRegIndex sctlr_idx; 106710037SARM gem5 Developers scr = readMiscRegNoEffect(MISCREG_SCR); 106810037SARM gem5 Developers if (haveSecurity && !scr.ns) { 106910037SARM gem5 Developers sctlr_idx = MISCREG_SCTLR_S; 107010037SARM gem5 Developers } else { 107110037SARM gem5 Developers sctlr_idx = MISCREG_SCTLR_NS; 107210037SARM gem5 Developers // The FI field (bit 21) is common between S/NS versions 107310037SARM gem5 Developers // of the register, we store this in the secure copy of 107410037SARM gem5 Developers // the reg 107510037SARM gem5 Developers miscRegs[MISCREG_SCTLR_S] &= ~(1 << 21); 107610037SARM gem5 Developers miscRegs[MISCREG_SCTLR_S] |= newVal & (1 << 21); 107710037SARM gem5 Developers } 107810037SARM gem5 Developers SCTLR sctlr = miscRegs[sctlr_idx]; 10797408Sgblack@eecs.umich.edu SCTLR new_sctlr = newVal; 108010037SARM gem5 Developers new_sctlr.nmfi = ((bool)sctlr.nmfi) && !haveVirtualization; 108110037SARM gem5 Developers miscRegs[sctlr_idx] = (MiscReg)new_sctlr; 10827749SAli.Saidi@ARM.com tc->getITBPtr()->invalidateMiscReg(); 10837749SAli.Saidi@ARM.com tc->getDTBPtr()->invalidateMiscReg(); 10848527SAli.Saidi@ARM.com 10858527SAli.Saidi@ARM.com // Check if all CPUs are booted with caches enabled 10868527SAli.Saidi@ARM.com // so we can stop enforcing coherency of some kernel 10878527SAli.Saidi@ARM.com // structures manually. 10888527SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 10898527SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 10908527SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 109110037SARM gem5 Developers // @todo: double check this for security 10928527SAli.Saidi@ARM.com SCTLR other_sctlr = oc->readMiscRegNoEffect(MISCREG_SCTLR); 10938527SAli.Saidi@ARM.com if (!other_sctlr.c && oc->status() != ThreadContext::Halted) 10948527SAli.Saidi@ARM.com return; 10958527SAli.Saidi@ARM.com } 10968527SAli.Saidi@ARM.com 10978527SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 10988527SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 10998527SAli.Saidi@ARM.com oc->getDTBPtr()->allCpusCaching(); 11008527SAli.Saidi@ARM.com oc->getITBPtr()->allCpusCaching(); 11018887Sgeoffrey.blake@arm.com 11028887Sgeoffrey.blake@arm.com // If CheckerCPU is connected, need to notify it. 11038887Sgeoffrey.blake@arm.com CheckerCPU *checker = oc->getCheckerCpuPtr(); 11048733Sgeoffrey.blake@arm.com if (checker) { 11058733Sgeoffrey.blake@arm.com checker->getDTBPtr()->allCpusCaching(); 11068733Sgeoffrey.blake@arm.com checker->getITBPtr()->allCpusCaching(); 11078733Sgeoffrey.blake@arm.com } 11088527SAli.Saidi@ARM.com } 11097408Sgblack@eecs.umich.edu return; 11107408Sgblack@eecs.umich.edu } 11119385SAndreas.Sandberg@arm.com 11129385SAndreas.Sandberg@arm.com case MISCREG_MIDR: 11139385SAndreas.Sandberg@arm.com case MISCREG_ID_PFR0: 11149385SAndreas.Sandberg@arm.com case MISCREG_ID_PFR1: 11159385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR0: 11169385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR1: 11179385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR2: 11189385SAndreas.Sandberg@arm.com case MISCREG_ID_MMFR3: 11199385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR0: 11209385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR1: 11219385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR2: 11229385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR3: 11239385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR4: 11249385SAndreas.Sandberg@arm.com case MISCREG_ID_ISAR5: 11259385SAndreas.Sandberg@arm.com 11269385SAndreas.Sandberg@arm.com case MISCREG_MPIDR: 11279385SAndreas.Sandberg@arm.com case MISCREG_FPSID: 11287408Sgblack@eecs.umich.edu case MISCREG_TLBTR: 11297408Sgblack@eecs.umich.edu case MISCREG_MVFR0: 11307408Sgblack@eecs.umich.edu case MISCREG_MVFR1: 113110037SARM gem5 Developers 113210037SARM gem5 Developers case MISCREG_ID_AA64AFR0_EL1: 113310037SARM gem5 Developers case MISCREG_ID_AA64AFR1_EL1: 113410037SARM gem5 Developers case MISCREG_ID_AA64DFR0_EL1: 113510037SARM gem5 Developers case MISCREG_ID_AA64DFR1_EL1: 113610037SARM gem5 Developers case MISCREG_ID_AA64ISAR0_EL1: 113710037SARM gem5 Developers case MISCREG_ID_AA64ISAR1_EL1: 113810037SARM gem5 Developers case MISCREG_ID_AA64MMFR0_EL1: 113910037SARM gem5 Developers case MISCREG_ID_AA64MMFR1_EL1: 114010037SARM gem5 Developers case MISCREG_ID_AA64PFR0_EL1: 114110037SARM gem5 Developers case MISCREG_ID_AA64PFR1_EL1: 11429385SAndreas.Sandberg@arm.com // ID registers are constants. 11437408Sgblack@eecs.umich.edu return; 11449385SAndreas.Sandberg@arm.com 114510037SARM gem5 Developers // TLBI all entries, EL0&1 inner sharable (ignored) 11467408Sgblack@eecs.umich.edu case MISCREG_TLBIALLIS: 114710037SARM gem5 Developers case MISCREG_TLBIALL: // TLBI all entries, EL0&1, 114810037SARM gem5 Developers assert32(tc); 114910037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 115010037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 115110037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 11528284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 11538284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 11548284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 11558284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 115610037SARM gem5 Developers oc->getITBPtr()->flushAllSecurity(secure_lookup, target_el); 115710037SARM gem5 Developers oc->getDTBPtr()->flushAllSecurity(secure_lookup, target_el); 11588887Sgeoffrey.blake@arm.com 11598887Sgeoffrey.blake@arm.com // If CheckerCPU is connected, need to notify it of a flush 11608887Sgeoffrey.blake@arm.com CheckerCPU *checker = oc->getCheckerCpuPtr(); 11618733Sgeoffrey.blake@arm.com if (checker) { 116210037SARM gem5 Developers checker->getITBPtr()->flushAllSecurity(secure_lookup, 116310037SARM gem5 Developers target_el); 116410037SARM gem5 Developers checker->getDTBPtr()->flushAllSecurity(secure_lookup, 116510037SARM gem5 Developers target_el); 11668733Sgeoffrey.blake@arm.com } 11678284SAli.Saidi@ARM.com } 11687408Sgblack@eecs.umich.edu return; 116910037SARM gem5 Developers // TLBI all entries, EL0&1, instruction side 11707408Sgblack@eecs.umich.edu case MISCREG_ITLBIALL: 117110037SARM gem5 Developers assert32(tc); 117210037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 117310037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 117410037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 117510037SARM gem5 Developers tc->getITBPtr()->flushAllSecurity(secure_lookup, target_el); 11767408Sgblack@eecs.umich.edu return; 117710037SARM gem5 Developers // TLBI all entries, EL0&1, data side 11787408Sgblack@eecs.umich.edu case MISCREG_DTLBIALL: 117910037SARM gem5 Developers assert32(tc); 118010037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 118110037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 118210037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 118310037SARM gem5 Developers tc->getDTBPtr()->flushAllSecurity(secure_lookup, target_el); 11847408Sgblack@eecs.umich.edu return; 118510037SARM gem5 Developers // TLBI based on VA, EL0&1 inner sharable (ignored) 11867408Sgblack@eecs.umich.edu case MISCREG_TLBIMVAIS: 11877408Sgblack@eecs.umich.edu case MISCREG_TLBIMVA: 118810037SARM gem5 Developers assert32(tc); 118910037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 119010037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 119110037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 11928284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 11938284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 11948284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 11958284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 11968284SAli.Saidi@ARM.com oc->getITBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 119710037SARM gem5 Developers bits(newVal, 7,0), 119810037SARM gem5 Developers secure_lookup, target_el); 11998284SAli.Saidi@ARM.com oc->getDTBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 120010037SARM gem5 Developers bits(newVal, 7,0), 120110037SARM gem5 Developers secure_lookup, target_el); 12028887Sgeoffrey.blake@arm.com 12038887Sgeoffrey.blake@arm.com CheckerCPU *checker = oc->getCheckerCpuPtr(); 12048733Sgeoffrey.blake@arm.com if (checker) { 12058733Sgeoffrey.blake@arm.com checker->getITBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 120610037SARM gem5 Developers bits(newVal, 7,0), secure_lookup, target_el); 12078733Sgeoffrey.blake@arm.com checker->getDTBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 120810037SARM gem5 Developers bits(newVal, 7,0), secure_lookup, target_el); 12098733Sgeoffrey.blake@arm.com } 12108284SAli.Saidi@ARM.com } 12117408Sgblack@eecs.umich.edu return; 121210037SARM gem5 Developers // TLBI by ASID, EL0&1, inner sharable 12137408Sgblack@eecs.umich.edu case MISCREG_TLBIASIDIS: 12147408Sgblack@eecs.umich.edu case MISCREG_TLBIASID: 121510037SARM gem5 Developers assert32(tc); 121610037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 121710037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 121810037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 12198284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 12208284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 12218284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 12228284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 122310037SARM gem5 Developers oc->getITBPtr()->flushAsid(bits(newVal, 7,0), 122410037SARM gem5 Developers secure_lookup, target_el); 122510037SARM gem5 Developers oc->getDTBPtr()->flushAsid(bits(newVal, 7,0), 122610037SARM gem5 Developers secure_lookup, target_el); 12278887Sgeoffrey.blake@arm.com CheckerCPU *checker = oc->getCheckerCpuPtr(); 12288733Sgeoffrey.blake@arm.com if (checker) { 122910037SARM gem5 Developers checker->getITBPtr()->flushAsid(bits(newVal, 7,0), 123010037SARM gem5 Developers secure_lookup, target_el); 123110037SARM gem5 Developers checker->getDTBPtr()->flushAsid(bits(newVal, 7,0), 123210037SARM gem5 Developers secure_lookup, target_el); 12338733Sgeoffrey.blake@arm.com } 12348284SAli.Saidi@ARM.com } 12357408Sgblack@eecs.umich.edu return; 123610037SARM gem5 Developers // TLBI by address, EL0&1, inner sharable (ignored) 12377408Sgblack@eecs.umich.edu case MISCREG_TLBIMVAAIS: 12387408Sgblack@eecs.umich.edu case MISCREG_TLBIMVAA: 123910037SARM gem5 Developers assert32(tc); 124010037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 124110037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 124210037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 124310037SARM gem5 Developers hyp = 0; 124410037SARM gem5 Developers tlbiMVA(tc, newVal, secure_lookup, hyp, target_el); 124510037SARM gem5 Developers return; 124610037SARM gem5 Developers // TLBI by address, EL2, hypervisor mode 124710037SARM gem5 Developers case MISCREG_TLBIMVAH: 124810037SARM gem5 Developers case MISCREG_TLBIMVAHIS: 124910037SARM gem5 Developers assert32(tc); 125010037SARM gem5 Developers target_el = 1; // aarch32, use hyp bit 125110037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 125210037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 125310037SARM gem5 Developers hyp = 1; 125410037SARM gem5 Developers tlbiMVA(tc, newVal, secure_lookup, hyp, target_el); 125510037SARM gem5 Developers return; 125610037SARM gem5 Developers // TLBI by address and asid, EL0&1, instruction side only 125710037SARM gem5 Developers case MISCREG_ITLBIMVA: 125810037SARM gem5 Developers assert32(tc); 125910037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 126010037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 126110037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 126210037SARM gem5 Developers tc->getITBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 126310037SARM gem5 Developers bits(newVal, 7,0), secure_lookup, target_el); 126410037SARM gem5 Developers return; 126510037SARM gem5 Developers // TLBI by address and asid, EL0&1, data side only 126610037SARM gem5 Developers case MISCREG_DTLBIMVA: 126710037SARM gem5 Developers assert32(tc); 126810037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 126910037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 127010037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 127110037SARM gem5 Developers tc->getDTBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 127210037SARM gem5 Developers bits(newVal, 7,0), secure_lookup, target_el); 127310037SARM gem5 Developers return; 127410037SARM gem5 Developers // TLBI by ASID, EL0&1, instrution side only 127510037SARM gem5 Developers case MISCREG_ITLBIASID: 127610037SARM gem5 Developers assert32(tc); 127710037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 127810037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 127910037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 128010037SARM gem5 Developers tc->getITBPtr()->flushAsid(bits(newVal, 7,0), secure_lookup, 128110037SARM gem5 Developers target_el); 128210037SARM gem5 Developers return; 128310037SARM gem5 Developers // TLBI by ASID EL0&1 data size only 128410037SARM gem5 Developers case MISCREG_DTLBIASID: 128510037SARM gem5 Developers assert32(tc); 128610037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 128710037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 128810037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 128910037SARM gem5 Developers tc->getDTBPtr()->flushAsid(bits(newVal, 7,0), secure_lookup, 129010037SARM gem5 Developers target_el); 129110037SARM gem5 Developers return; 129210037SARM gem5 Developers // Invalidate entire Non-secure Hyp/Non-Hyp Unified TLB 129310037SARM gem5 Developers case MISCREG_TLBIALLNSNH: 129410037SARM gem5 Developers case MISCREG_TLBIALLNSNHIS: 129510037SARM gem5 Developers assert32(tc); 129610037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 129710037SARM gem5 Developers hyp = 0; 129810037SARM gem5 Developers tlbiALLN(tc, hyp, target_el); 129910037SARM gem5 Developers return; 130010037SARM gem5 Developers // TLBI all entries, EL2, hyp, 130110037SARM gem5 Developers case MISCREG_TLBIALLH: 130210037SARM gem5 Developers case MISCREG_TLBIALLHIS: 130310037SARM gem5 Developers assert32(tc); 130410037SARM gem5 Developers target_el = 1; // aarch32, use hyp bit 130510037SARM gem5 Developers hyp = 1; 130610037SARM gem5 Developers tlbiALLN(tc, hyp, target_el); 130710037SARM gem5 Developers return; 130810037SARM gem5 Developers // AArch64 TLBI: invalidate all entries EL3 130910037SARM gem5 Developers case MISCREG_TLBI_ALLE3IS: 131010037SARM gem5 Developers case MISCREG_TLBI_ALLE3: 131110037SARM gem5 Developers assert64(tc); 131210037SARM gem5 Developers target_el = 3; 131310037SARM gem5 Developers secure_lookup = true; 131410037SARM gem5 Developers tlbiALL(tc, secure_lookup, target_el); 131510037SARM gem5 Developers return; 131610037SARM gem5 Developers // @todo: uncomment this to enable Virtualization 131710037SARM gem5 Developers // case MISCREG_TLBI_ALLE2IS: 131810037SARM gem5 Developers // case MISCREG_TLBI_ALLE2: 131910037SARM gem5 Developers // TLBI all entries, EL0&1 132010037SARM gem5 Developers case MISCREG_TLBI_ALLE1IS: 132110037SARM gem5 Developers case MISCREG_TLBI_ALLE1: 132210037SARM gem5 Developers // AArch64 TLBI: invalidate all entries, stage 1, current VMID 132310037SARM gem5 Developers case MISCREG_TLBI_VMALLE1IS: 132410037SARM gem5 Developers case MISCREG_TLBI_VMALLE1: 132510037SARM gem5 Developers // AArch64 TLBI: invalidate all entries, stages 1 & 2, current VMID 132610037SARM gem5 Developers case MISCREG_TLBI_VMALLS12E1IS: 132710037SARM gem5 Developers case MISCREG_TLBI_VMALLS12E1: 132810037SARM gem5 Developers // @todo: handle VMID and stage 2 to enable Virtualization 132910037SARM gem5 Developers assert64(tc); 133010037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 133110037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 133210037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 133310037SARM gem5 Developers tlbiALL(tc, secure_lookup, target_el); 133410037SARM gem5 Developers return; 133510037SARM gem5 Developers // AArch64 TLBI: invalidate by VA and ASID, stage 1, current VMID 133610037SARM gem5 Developers // VAEx(IS) and VALEx(IS) are the same because TLBs only store entries 133710037SARM gem5 Developers // from the last level of translation table walks 133810037SARM gem5 Developers // @todo: handle VMID to enable Virtualization 133910037SARM gem5 Developers // TLBI all entries, EL0&1 134010037SARM gem5 Developers case MISCREG_TLBI_VAE3IS_Xt: 134110037SARM gem5 Developers case MISCREG_TLBI_VAE3_Xt: 134210037SARM gem5 Developers // TLBI by VA, EL3 regime stage 1, last level walk 134310037SARM gem5 Developers case MISCREG_TLBI_VALE3IS_Xt: 134410037SARM gem5 Developers case MISCREG_TLBI_VALE3_Xt: 134510037SARM gem5 Developers assert64(tc); 134610037SARM gem5 Developers target_el = 3; 134710037SARM gem5 Developers asid = 0xbeef; // does not matter, tlbi is global 134810037SARM gem5 Developers secure_lookup = true; 134910037SARM gem5 Developers tlbiVA(tc, newVal, asid, secure_lookup, target_el); 135010037SARM gem5 Developers return; 135110037SARM gem5 Developers // TLBI by VA, EL2 135210037SARM gem5 Developers case MISCREG_TLBI_VAE2IS_Xt: 135310037SARM gem5 Developers case MISCREG_TLBI_VAE2_Xt: 135410037SARM gem5 Developers // TLBI by VA, EL2, stage1 last level walk 135510037SARM gem5 Developers case MISCREG_TLBI_VALE2IS_Xt: 135610037SARM gem5 Developers case MISCREG_TLBI_VALE2_Xt: 135710037SARM gem5 Developers assert64(tc); 135810037SARM gem5 Developers target_el = 2; 135910037SARM gem5 Developers asid = 0xbeef; // does not matter, tlbi is global 136010037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 136110037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 136210037SARM gem5 Developers tlbiVA(tc, newVal, asid, secure_lookup, target_el); 136310037SARM gem5 Developers return; 136410037SARM gem5 Developers // TLBI by VA EL1 & 0, stage1, ASID, current VMID 136510037SARM gem5 Developers case MISCREG_TLBI_VAE1IS_Xt: 136610037SARM gem5 Developers case MISCREG_TLBI_VAE1_Xt: 136710037SARM gem5 Developers case MISCREG_TLBI_VALE1IS_Xt: 136810037SARM gem5 Developers case MISCREG_TLBI_VALE1_Xt: 136910037SARM gem5 Developers assert64(tc); 137010037SARM gem5 Developers asid = bits(newVal, 63, 48); 137110037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 137210037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 137310037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 137410037SARM gem5 Developers tlbiVA(tc, newVal, asid, secure_lookup, target_el); 137510037SARM gem5 Developers return; 137610037SARM gem5 Developers // AArch64 TLBI: invalidate by ASID, stage 1, current VMID 137710037SARM gem5 Developers // @todo: handle VMID to enable Virtualization 137810037SARM gem5 Developers case MISCREG_TLBI_ASIDE1IS_Xt: 137910037SARM gem5 Developers case MISCREG_TLBI_ASIDE1_Xt: 138010037SARM gem5 Developers assert64(tc); 138110037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 138210037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 138310037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 13848284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 13858284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 13868284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 13878284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 138810037SARM gem5 Developers asid = bits(newVal, 63, 48); 138910037SARM gem5 Developers if (haveLargeAsid64) 139010037SARM gem5 Developers asid &= mask(8); 139110037SARM gem5 Developers oc->getITBPtr()->flushAsid(asid, secure_lookup, target_el); 139210037SARM gem5 Developers oc->getDTBPtr()->flushAsid(asid, secure_lookup, target_el); 139310037SARM gem5 Developers CheckerCPU *checker = oc->getCheckerCpuPtr(); 139410037SARM gem5 Developers if (checker) { 139510037SARM gem5 Developers checker->getITBPtr()->flushAsid(asid, 139610037SARM gem5 Developers secure_lookup, target_el); 139710037SARM gem5 Developers checker->getDTBPtr()->flushAsid(asid, 139810037SARM gem5 Developers secure_lookup, target_el); 139910037SARM gem5 Developers } 140010037SARM gem5 Developers } 140110037SARM gem5 Developers return; 140210037SARM gem5 Developers // AArch64 TLBI: invalidate by VA, ASID, stage 1, current VMID 140310037SARM gem5 Developers // VAAE1(IS) and VAALE1(IS) are the same because TLBs only store 140410037SARM gem5 Developers // entries from the last level of translation table walks 140510037SARM gem5 Developers // @todo: handle VMID to enable Virtualization 140610037SARM gem5 Developers case MISCREG_TLBI_VAAE1IS_Xt: 140710037SARM gem5 Developers case MISCREG_TLBI_VAAE1_Xt: 140810037SARM gem5 Developers case MISCREG_TLBI_VAALE1IS_Xt: 140910037SARM gem5 Developers case MISCREG_TLBI_VAALE1_Xt: 141010037SARM gem5 Developers assert64(tc); 141110037SARM gem5 Developers target_el = 1; // el 0 and 1 are handled together 141210037SARM gem5 Developers scr = readMiscReg(MISCREG_SCR, tc); 141310037SARM gem5 Developers secure_lookup = haveSecurity && !scr.ns; 141410037SARM gem5 Developers sys = tc->getSystemPtr(); 141510037SARM gem5 Developers for (x = 0; x < sys->numContexts(); x++) { 141610037SARM gem5 Developers // @todo: extra controls on TLBI broadcast? 141710037SARM gem5 Developers oc = sys->getThreadContext(x); 141810037SARM gem5 Developers assert(oc->getITBPtr() && oc->getDTBPtr()); 141910037SARM gem5 Developers Addr va = ((Addr) bits(newVal, 43, 0)) << 12; 142010037SARM gem5 Developers oc->getITBPtr()->flushMva(va, 142110037SARM gem5 Developers secure_lookup, false, target_el); 142210037SARM gem5 Developers oc->getDTBPtr()->flushMva(va, 142310037SARM gem5 Developers secure_lookup, false, target_el); 14248887Sgeoffrey.blake@arm.com 14258887Sgeoffrey.blake@arm.com CheckerCPU *checker = oc->getCheckerCpuPtr(); 14268733Sgeoffrey.blake@arm.com if (checker) { 142710037SARM gem5 Developers checker->getITBPtr()->flushMva(va, 142810037SARM gem5 Developers secure_lookup, false, target_el); 142910037SARM gem5 Developers checker->getDTBPtr()->flushMva(va, 143010037SARM gem5 Developers secure_lookup, false, target_el); 14318733Sgeoffrey.blake@arm.com } 14328284SAli.Saidi@ARM.com } 14337408Sgblack@eecs.umich.edu return; 143410037SARM gem5 Developers // AArch64 TLBI: invalidate by IPA, stage 2, current VMID 143510037SARM gem5 Developers case MISCREG_TLBI_IPAS2LE1IS_Xt: 143610037SARM gem5 Developers case MISCREG_TLBI_IPAS2LE1_Xt: 143710037SARM gem5 Developers case MISCREG_TLBI_IPAS2E1IS_Xt: 143810037SARM gem5 Developers case MISCREG_TLBI_IPAS2E1_Xt: 143910037SARM gem5 Developers assert64(tc); 144010037SARM gem5 Developers // @todo: implement these as part of Virtualization 144110037SARM gem5 Developers warn("Not doing anything for write of miscreg ITLB_IPAS2\n"); 14427405SAli.Saidi@ARM.com return; 14437583SAli.Saidi@arm.com case MISCREG_ACTLR: 14447583SAli.Saidi@arm.com warn("Not doing anything for write of miscreg ACTLR\n"); 14457583SAli.Saidi@arm.com break; 14467583SAli.Saidi@arm.com case MISCREG_PMCR: 14478059SAli.Saidi@ARM.com { 14488059SAli.Saidi@ARM.com // Performance counters not implemented. Instead, interpret 14498059SAli.Saidi@ARM.com // a reset command to this register to reset the simulator 14508059SAli.Saidi@ARM.com // statistics. 14518059SAli.Saidi@ARM.com // PMCR_E | PMCR_P | PMCR_C 14528059SAli.Saidi@ARM.com const int ResetAndEnableCounters = 0x7; 14538059SAli.Saidi@ARM.com if (newVal == ResetAndEnableCounters) { 14548059SAli.Saidi@ARM.com inform("Resetting all simobject stats\n"); 14558059SAli.Saidi@ARM.com Stats::schedStatEvent(false, true); 14568059SAli.Saidi@ARM.com break; 14578059SAli.Saidi@ARM.com } 14588059SAli.Saidi@ARM.com } 14597583SAli.Saidi@arm.com case MISCREG_PMCCNTR: 14607583SAli.Saidi@arm.com case MISCREG_PMSELR: 14617583SAli.Saidi@arm.com warn("Not doing anything for write to miscreg %s\n", 14627583SAli.Saidi@arm.com miscRegName[misc_reg]); 14637583SAli.Saidi@arm.com break; 146410037SARM gem5 Developers case MISCREG_HSTR: // TJDBX, now redifined to be RES0 146510037SARM gem5 Developers { 146610037SARM gem5 Developers HSTR hstrMask = 0; 146710037SARM gem5 Developers hstrMask.tjdbx = 1; 146810037SARM gem5 Developers newVal &= ~((uint32_t) hstrMask); 146910037SARM gem5 Developers break; 147010037SARM gem5 Developers } 147110037SARM gem5 Developers case MISCREG_HCPTR: 147210037SARM gem5 Developers { 147310037SARM gem5 Developers // If a CP bit in NSACR is 0 then the corresponding bit in 147410037SARM gem5 Developers // HCPTR is RAO/WI. Same applies to NSASEDIS 147510037SARM gem5 Developers secure_lookup = haveSecurity && 147610037SARM gem5 Developers inSecureState(readMiscRegNoEffect(MISCREG_SCR), 147710037SARM gem5 Developers readMiscRegNoEffect(MISCREG_CPSR)); 147810037SARM gem5 Developers if (!secure_lookup) { 147910037SARM gem5 Developers MiscReg oldValue = readMiscRegNoEffect(MISCREG_HCPTR); 148010037SARM gem5 Developers MiscReg mask = (readMiscRegNoEffect(MISCREG_NSACR) ^ 0x7FFF) & 0xBFFF; 148110037SARM gem5 Developers newVal = (newVal & ~mask) | (oldValue & mask); 148210037SARM gem5 Developers } 148310037SARM gem5 Developers break; 148410037SARM gem5 Developers } 148510037SARM gem5 Developers case MISCREG_HDFAR: // alias for secure DFAR 148610037SARM gem5 Developers misc_reg = MISCREG_DFAR_S; 148710037SARM gem5 Developers break; 148810037SARM gem5 Developers case MISCREG_HIFAR: // alias for secure IFAR 148910037SARM gem5 Developers misc_reg = MISCREG_IFAR_S; 149010037SARM gem5 Developers break; 149110037SARM gem5 Developers case MISCREG_ATS1CPR: 149210037SARM gem5 Developers case MISCREG_ATS1CPW: 149310037SARM gem5 Developers case MISCREG_ATS1CUR: 149410037SARM gem5 Developers case MISCREG_ATS1CUW: 149510037SARM gem5 Developers case MISCREG_ATS12NSOPR: 149610037SARM gem5 Developers case MISCREG_ATS12NSOPW: 149710037SARM gem5 Developers case MISCREG_ATS12NSOUR: 149810037SARM gem5 Developers case MISCREG_ATS12NSOUW: 149910037SARM gem5 Developers case MISCREG_ATS1HR: 150010037SARM gem5 Developers case MISCREG_ATS1HW: 15017436Sdam.sunwoo@arm.com { 15027436Sdam.sunwoo@arm.com RequestPtr req = new Request; 150310037SARM gem5 Developers unsigned flags = 0; 150410037SARM gem5 Developers BaseTLB::Mode mode = BaseTLB::Read; 150510037SARM gem5 Developers TLB::ArmTranslationType tranType = TLB::NormalTran; 15067436Sdam.sunwoo@arm.com Fault fault; 15077436Sdam.sunwoo@arm.com switch(misc_reg) { 150810037SARM gem5 Developers case MISCREG_ATS1CPR: 150910037SARM gem5 Developers flags = TLB::MustBeOne; 151010037SARM gem5 Developers tranType = TLB::S1CTran; 151110037SARM gem5 Developers mode = BaseTLB::Read; 151210037SARM gem5 Developers break; 151310037SARM gem5 Developers case MISCREG_ATS1CPW: 151410037SARM gem5 Developers flags = TLB::MustBeOne; 151510037SARM gem5 Developers tranType = TLB::S1CTran; 151610037SARM gem5 Developers mode = BaseTLB::Write; 151710037SARM gem5 Developers break; 151810037SARM gem5 Developers case MISCREG_ATS1CUR: 151910037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 152010037SARM gem5 Developers tranType = TLB::S1CTran; 152110037SARM gem5 Developers mode = BaseTLB::Read; 152210037SARM gem5 Developers break; 152310037SARM gem5 Developers case MISCREG_ATS1CUW: 152410037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 152510037SARM gem5 Developers tranType = TLB::S1CTran; 152610037SARM gem5 Developers mode = BaseTLB::Write; 152710037SARM gem5 Developers break; 152810037SARM gem5 Developers case MISCREG_ATS12NSOPR: 152910037SARM gem5 Developers if (!haveSecurity) 153010037SARM gem5 Developers panic("Security Extensions required for ATS12NSOPR"); 153110037SARM gem5 Developers flags = TLB::MustBeOne; 153210037SARM gem5 Developers tranType = TLB::S1S2NsTran; 153310037SARM gem5 Developers mode = BaseTLB::Read; 153410037SARM gem5 Developers break; 153510037SARM gem5 Developers case MISCREG_ATS12NSOPW: 153610037SARM gem5 Developers if (!haveSecurity) 153710037SARM gem5 Developers panic("Security Extensions required for ATS12NSOPW"); 153810037SARM gem5 Developers flags = TLB::MustBeOne; 153910037SARM gem5 Developers tranType = TLB::S1S2NsTran; 154010037SARM gem5 Developers mode = BaseTLB::Write; 154110037SARM gem5 Developers break; 154210037SARM gem5 Developers case MISCREG_ATS12NSOUR: 154310037SARM gem5 Developers if (!haveSecurity) 154410037SARM gem5 Developers panic("Security Extensions required for ATS12NSOUR"); 154510037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 154610037SARM gem5 Developers tranType = TLB::S1S2NsTran; 154710037SARM gem5 Developers mode = BaseTLB::Read; 154810037SARM gem5 Developers break; 154910037SARM gem5 Developers case MISCREG_ATS12NSOUW: 155010037SARM gem5 Developers if (!haveSecurity) 155110037SARM gem5 Developers panic("Security Extensions required for ATS12NSOUW"); 155210037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 155310037SARM gem5 Developers tranType = TLB::S1S2NsTran; 155410037SARM gem5 Developers mode = BaseTLB::Write; 155510037SARM gem5 Developers break; 155610037SARM gem5 Developers case MISCREG_ATS1HR: // only really useful from secure mode. 155710037SARM gem5 Developers flags = TLB::MustBeOne; 155810037SARM gem5 Developers tranType = TLB::HypMode; 155910037SARM gem5 Developers mode = BaseTLB::Read; 156010037SARM gem5 Developers break; 156110037SARM gem5 Developers case MISCREG_ATS1HW: 156210037SARM gem5 Developers flags = TLB::MustBeOne; 156310037SARM gem5 Developers tranType = TLB::HypMode; 156410037SARM gem5 Developers mode = BaseTLB::Write; 156510037SARM gem5 Developers break; 15667436Sdam.sunwoo@arm.com } 156710037SARM gem5 Developers // If we're in timing mode then doing the translation in 156810037SARM gem5 Developers // functional mode then we're slightly distorting performance 156910037SARM gem5 Developers // results obtained from simulations. The translation should be 157010037SARM gem5 Developers // done in the same mode the core is running in. NOTE: This 157110037SARM gem5 Developers // can't be an atomic translation because that causes problems 157210037SARM gem5 Developers // with unexpected atomic snoop requests. 157310037SARM gem5 Developers warn("Translating via MISCREG(%d) in functional mode! Fix Me!\n", misc_reg); 157410037SARM gem5 Developers req->setVirt(0, val, 1, flags, Request::funcMasterId, 157510037SARM gem5 Developers tc->pcState().pc()); 157610037SARM gem5 Developers req->setThreadContext(tc->contextId(), tc->threadId()); 157710037SARM gem5 Developers fault = tc->getDTBPtr()->translateFunctional(req, tc, mode, tranType); 157810037SARM gem5 Developers TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); 157910037SARM gem5 Developers HCR hcr = readMiscRegNoEffect(MISCREG_HCR); 158010037SARM gem5 Developers 158110037SARM gem5 Developers MiscReg newVal; 15827436Sdam.sunwoo@arm.com if (fault == NoFault) { 158310037SARM gem5 Developers Addr paddr = req->getPaddr(); 158410037SARM gem5 Developers if (haveLPAE && (ttbcr.eae || tranType & TLB::HypMode || 158510037SARM gem5 Developers ((tranType & TLB::S1S2NsTran) && hcr.vm) )) { 158610037SARM gem5 Developers newVal = (paddr & mask(39, 12)) | 158710037SARM gem5 Developers (tc->getDTBPtr()->getAttr()); 158810037SARM gem5 Developers } else { 158910037SARM gem5 Developers newVal = (paddr & 0xfffff000) | 159010037SARM gem5 Developers (tc->getDTBPtr()->getAttr()); 159110037SARM gem5 Developers } 15927436Sdam.sunwoo@arm.com DPRINTF(MiscRegs, 15937436Sdam.sunwoo@arm.com "MISCREG: Translated addr 0x%08x: PAR: 0x%08x\n", 159410037SARM gem5 Developers val, newVal); 159510037SARM gem5 Developers } else { 159610037SARM gem5 Developers ArmFault *armFault = reinterpret_cast<ArmFault *>(fault.get()); 159710037SARM gem5 Developers // Set fault bit and FSR 159810037SARM gem5 Developers FSR fsr = armFault->getFsr(tc); 159910037SARM gem5 Developers 160010037SARM gem5 Developers newVal = ((fsr >> 9) & 1) << 11; 160110037SARM gem5 Developers if (newVal) { 160210037SARM gem5 Developers // LPAE - rearange fault status 160310037SARM gem5 Developers newVal |= ((fsr >> 0) & 0x3f) << 1; 160410037SARM gem5 Developers } else { 160510037SARM gem5 Developers // VMSA - rearange fault status 160610037SARM gem5 Developers newVal |= ((fsr >> 0) & 0xf) << 1; 160710037SARM gem5 Developers newVal |= ((fsr >> 10) & 0x1) << 5; 160810037SARM gem5 Developers newVal |= ((fsr >> 12) & 0x1) << 6; 160910037SARM gem5 Developers } 161010037SARM gem5 Developers newVal |= 0x1; // F bit 161110037SARM gem5 Developers newVal |= ((armFault->iss() >> 7) & 0x1) << 8; 161210037SARM gem5 Developers newVal |= armFault->isStage2() ? 0x200 : 0; 161310037SARM gem5 Developers DPRINTF(MiscRegs, 161410037SARM gem5 Developers "MISCREG: Translated addr 0x%08x fault fsr %#x: PAR: 0x%08x\n", 161510037SARM gem5 Developers val, fsr, newVal); 16167436Sdam.sunwoo@arm.com } 161710037SARM gem5 Developers delete req; 161810037SARM gem5 Developers setMiscRegNoEffect(MISCREG_PAR, newVal); 16197436Sdam.sunwoo@arm.com return; 16207436Sdam.sunwoo@arm.com } 162110037SARM gem5 Developers case MISCREG_TTBCR: 162210037SARM gem5 Developers { 162310037SARM gem5 Developers TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); 162410037SARM gem5 Developers const uint32_t ones = (uint32_t)(-1); 162510037SARM gem5 Developers TTBCR ttbcrMask = 0; 162610037SARM gem5 Developers TTBCR ttbcrNew = newVal; 162710037SARM gem5 Developers 162810037SARM gem5 Developers // ARM DDI 0406C.b, ARMv7-32 162910037SARM gem5 Developers ttbcrMask.n = ones; // T0SZ 163010037SARM gem5 Developers if (haveSecurity) { 163110037SARM gem5 Developers ttbcrMask.pd0 = ones; 163210037SARM gem5 Developers ttbcrMask.pd1 = ones; 163310037SARM gem5 Developers } 163410037SARM gem5 Developers ttbcrMask.epd0 = ones; 163510037SARM gem5 Developers ttbcrMask.irgn0 = ones; 163610037SARM gem5 Developers ttbcrMask.orgn0 = ones; 163710037SARM gem5 Developers ttbcrMask.sh0 = ones; 163810037SARM gem5 Developers ttbcrMask.ps = ones; // T1SZ 163910037SARM gem5 Developers ttbcrMask.a1 = ones; 164010037SARM gem5 Developers ttbcrMask.epd1 = ones; 164110037SARM gem5 Developers ttbcrMask.irgn1 = ones; 164210037SARM gem5 Developers ttbcrMask.orgn1 = ones; 164310037SARM gem5 Developers ttbcrMask.sh1 = ones; 164410037SARM gem5 Developers if (haveLPAE) 164510037SARM gem5 Developers ttbcrMask.eae = ones; 164610037SARM gem5 Developers 164710037SARM gem5 Developers if (haveLPAE && ttbcrNew.eae) { 164810037SARM gem5 Developers newVal = newVal & ttbcrMask; 164910037SARM gem5 Developers } else { 165010037SARM gem5 Developers newVal = (newVal & ttbcrMask) | (ttbcr & (~ttbcrMask)); 165110037SARM gem5 Developers } 165210037SARM gem5 Developers } 165310037SARM gem5 Developers case MISCREG_TTBR0: 165410037SARM gem5 Developers case MISCREG_TTBR1: 165510037SARM gem5 Developers { 165610037SARM gem5 Developers TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); 165710037SARM gem5 Developers if (haveLPAE) { 165810037SARM gem5 Developers if (ttbcr.eae) { 165910037SARM gem5 Developers // ARMv7 bit 63-56, 47-40 reserved, UNK/SBZP 166010037SARM gem5 Developers // ARMv8 AArch32 bit 63-56 only 166110037SARM gem5 Developers uint64_t ttbrMask = mask(63,56) | mask(47,40); 166210037SARM gem5 Developers newVal = (newVal & (~ttbrMask)); 166310037SARM gem5 Developers } 166410037SARM gem5 Developers } 166510037SARM gem5 Developers } 16667749SAli.Saidi@ARM.com case MISCREG_CONTEXTIDR: 16677749SAli.Saidi@ARM.com case MISCREG_PRRR: 16687749SAli.Saidi@ARM.com case MISCREG_NMRR: 166910037SARM gem5 Developers case MISCREG_MAIR0: 167010037SARM gem5 Developers case MISCREG_MAIR1: 16717749SAli.Saidi@ARM.com case MISCREG_DACR: 167210037SARM gem5 Developers case MISCREG_VTTBR: 167310037SARM gem5 Developers case MISCREG_SCR_EL3: 167410037SARM gem5 Developers case MISCREG_SCTLR_EL1: 167510037SARM gem5 Developers case MISCREG_SCTLR_EL2: 167610037SARM gem5 Developers case MISCREG_SCTLR_EL3: 167710037SARM gem5 Developers case MISCREG_TCR_EL1: 167810037SARM gem5 Developers case MISCREG_TCR_EL2: 167910037SARM gem5 Developers case MISCREG_TCR_EL3: 168010037SARM gem5 Developers case MISCREG_TTBR0_EL1: 168110037SARM gem5 Developers case MISCREG_TTBR1_EL1: 168210037SARM gem5 Developers case MISCREG_TTBR0_EL2: 168310037SARM gem5 Developers case MISCREG_TTBR0_EL3: 16847749SAli.Saidi@ARM.com tc->getITBPtr()->invalidateMiscReg(); 16857749SAli.Saidi@ARM.com tc->getDTBPtr()->invalidateMiscReg(); 16867749SAli.Saidi@ARM.com break; 168710037SARM gem5 Developers case MISCREG_NZCV: 168810037SARM gem5 Developers { 168910037SARM gem5 Developers CPSR cpsr = val; 169010037SARM gem5 Developers 169110338SCurtis.Dunham@arm.com tc->setCCReg(CCREG_NZ, cpsr.nz); 169210338SCurtis.Dunham@arm.com tc->setCCReg(CCREG_C, cpsr.c); 169310338SCurtis.Dunham@arm.com tc->setCCReg(CCREG_V, cpsr.v); 169410037SARM gem5 Developers } 169510037SARM gem5 Developers break; 169610037SARM gem5 Developers case MISCREG_DAIF: 169710037SARM gem5 Developers { 169810037SARM gem5 Developers CPSR cpsr = miscRegs[MISCREG_CPSR]; 169910037SARM gem5 Developers cpsr.daif = (uint8_t) ((CPSR) newVal).daif; 170010037SARM gem5 Developers newVal = cpsr; 170110037SARM gem5 Developers misc_reg = MISCREG_CPSR; 170210037SARM gem5 Developers } 170310037SARM gem5 Developers break; 170410037SARM gem5 Developers case MISCREG_SP_EL0: 170510037SARM gem5 Developers tc->setIntReg(INTREG_SP0, newVal); 170610037SARM gem5 Developers break; 170710037SARM gem5 Developers case MISCREG_SP_EL1: 170810037SARM gem5 Developers tc->setIntReg(INTREG_SP1, newVal); 170910037SARM gem5 Developers break; 171010037SARM gem5 Developers case MISCREG_SP_EL2: 171110037SARM gem5 Developers tc->setIntReg(INTREG_SP2, newVal); 171210037SARM gem5 Developers break; 171310037SARM gem5 Developers case MISCREG_SPSEL: 171410037SARM gem5 Developers { 171510037SARM gem5 Developers CPSR cpsr = miscRegs[MISCREG_CPSR]; 171610037SARM gem5 Developers cpsr.sp = (uint8_t) ((CPSR) newVal).sp; 171710037SARM gem5 Developers newVal = cpsr; 171810037SARM gem5 Developers misc_reg = MISCREG_CPSR; 171910037SARM gem5 Developers } 172010037SARM gem5 Developers break; 172110037SARM gem5 Developers case MISCREG_CURRENTEL: 172210037SARM gem5 Developers { 172310037SARM gem5 Developers CPSR cpsr = miscRegs[MISCREG_CPSR]; 172410037SARM gem5 Developers cpsr.el = (uint8_t) ((CPSR) newVal).el; 172510037SARM gem5 Developers newVal = cpsr; 172610037SARM gem5 Developers misc_reg = MISCREG_CPSR; 172710037SARM gem5 Developers } 172810037SARM gem5 Developers break; 172910037SARM gem5 Developers case MISCREG_AT_S1E1R_Xt: 173010037SARM gem5 Developers case MISCREG_AT_S1E1W_Xt: 173110037SARM gem5 Developers case MISCREG_AT_S1E0R_Xt: 173210037SARM gem5 Developers case MISCREG_AT_S1E0W_Xt: 173310037SARM gem5 Developers case MISCREG_AT_S1E2R_Xt: 173410037SARM gem5 Developers case MISCREG_AT_S1E2W_Xt: 173510037SARM gem5 Developers case MISCREG_AT_S12E1R_Xt: 173610037SARM gem5 Developers case MISCREG_AT_S12E1W_Xt: 173710037SARM gem5 Developers case MISCREG_AT_S12E0R_Xt: 173810037SARM gem5 Developers case MISCREG_AT_S12E0W_Xt: 173910037SARM gem5 Developers case MISCREG_AT_S1E3R_Xt: 174010037SARM gem5 Developers case MISCREG_AT_S1E3W_Xt: 174110037SARM gem5 Developers { 174210037SARM gem5 Developers RequestPtr req = new Request; 174310037SARM gem5 Developers unsigned flags = 0; 174410037SARM gem5 Developers BaseTLB::Mode mode = BaseTLB::Read; 174510037SARM gem5 Developers TLB::ArmTranslationType tranType = TLB::NormalTran; 174610037SARM gem5 Developers Fault fault; 174710037SARM gem5 Developers switch(misc_reg) { 174810037SARM gem5 Developers case MISCREG_AT_S1E1R_Xt: 174910037SARM gem5 Developers flags = TLB::MustBeOne; 175010037SARM gem5 Developers tranType = TLB::S1CTran; 175110037SARM gem5 Developers mode = BaseTLB::Read; 175210037SARM gem5 Developers break; 175310037SARM gem5 Developers case MISCREG_AT_S1E1W_Xt: 175410037SARM gem5 Developers flags = TLB::MustBeOne; 175510037SARM gem5 Developers tranType = TLB::S1CTran; 175610037SARM gem5 Developers mode = BaseTLB::Write; 175710037SARM gem5 Developers break; 175810037SARM gem5 Developers case MISCREG_AT_S1E0R_Xt: 175910037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 176010037SARM gem5 Developers tranType = TLB::S1CTran; 176110037SARM gem5 Developers mode = BaseTLB::Read; 176210037SARM gem5 Developers break; 176310037SARM gem5 Developers case MISCREG_AT_S1E0W_Xt: 176410037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 176510037SARM gem5 Developers tranType = TLB::S1CTran; 176610037SARM gem5 Developers mode = BaseTLB::Write; 176710037SARM gem5 Developers break; 176810037SARM gem5 Developers case MISCREG_AT_S1E2R_Xt: 176910037SARM gem5 Developers flags = TLB::MustBeOne; 177010037SARM gem5 Developers tranType = TLB::HypMode; 177110037SARM gem5 Developers mode = BaseTLB::Read; 177210037SARM gem5 Developers break; 177310037SARM gem5 Developers case MISCREG_AT_S1E2W_Xt: 177410037SARM gem5 Developers flags = TLB::MustBeOne; 177510037SARM gem5 Developers tranType = TLB::HypMode; 177610037SARM gem5 Developers mode = BaseTLB::Write; 177710037SARM gem5 Developers break; 177810037SARM gem5 Developers case MISCREG_AT_S12E0R_Xt: 177910037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 178010037SARM gem5 Developers tranType = TLB::S1S2NsTran; 178110037SARM gem5 Developers mode = BaseTLB::Read; 178210037SARM gem5 Developers break; 178310037SARM gem5 Developers case MISCREG_AT_S12E0W_Xt: 178410037SARM gem5 Developers flags = TLB::MustBeOne | TLB::UserMode; 178510037SARM gem5 Developers tranType = TLB::S1S2NsTran; 178610037SARM gem5 Developers mode = BaseTLB::Write; 178710037SARM gem5 Developers break; 178810037SARM gem5 Developers case MISCREG_AT_S12E1R_Xt: 178910037SARM gem5 Developers flags = TLB::MustBeOne; 179010037SARM gem5 Developers tranType = TLB::S1S2NsTran; 179110037SARM gem5 Developers mode = BaseTLB::Read; 179210037SARM gem5 Developers break; 179310037SARM gem5 Developers case MISCREG_AT_S12E1W_Xt: 179410037SARM gem5 Developers flags = TLB::MustBeOne; 179510037SARM gem5 Developers tranType = TLB::S1S2NsTran; 179610037SARM gem5 Developers mode = BaseTLB::Write; 179710037SARM gem5 Developers break; 179810037SARM gem5 Developers case MISCREG_AT_S1E3R_Xt: 179910037SARM gem5 Developers flags = TLB::MustBeOne; 180010037SARM gem5 Developers tranType = TLB::HypMode; // There is no TZ mode defined. 180110037SARM gem5 Developers mode = BaseTLB::Read; 180210037SARM gem5 Developers break; 180310037SARM gem5 Developers case MISCREG_AT_S1E3W_Xt: 180410037SARM gem5 Developers flags = TLB::MustBeOne; 180510037SARM gem5 Developers tranType = TLB::HypMode; // There is no TZ mode defined. 180610037SARM gem5 Developers mode = BaseTLB::Write; 180710037SARM gem5 Developers break; 180810037SARM gem5 Developers } 180910037SARM gem5 Developers // If we're in timing mode then doing the translation in 181010037SARM gem5 Developers // functional mode then we're slightly distorting performance 181110037SARM gem5 Developers // results obtained from simulations. The translation should be 181210037SARM gem5 Developers // done in the same mode the core is running in. NOTE: This 181310037SARM gem5 Developers // can't be an atomic translation because that causes problems 181410037SARM gem5 Developers // with unexpected atomic snoop requests. 181510037SARM gem5 Developers warn("Translating via MISCREG(%d) in functional mode! Fix Me!\n", misc_reg); 181610037SARM gem5 Developers req->setVirt(0, val, 1, flags, Request::funcMasterId, 181710037SARM gem5 Developers tc->pcState().pc()); 181810037SARM gem5 Developers req->setThreadContext(tc->contextId(), tc->threadId()); 181910037SARM gem5 Developers fault = tc->getDTBPtr()->translateFunctional(req, tc, mode, 182010037SARM gem5 Developers tranType); 182110037SARM gem5 Developers 182210037SARM gem5 Developers MiscReg newVal; 182310037SARM gem5 Developers if (fault == NoFault) { 182410037SARM gem5 Developers Addr paddr = req->getPaddr(); 182510037SARM gem5 Developers uint64_t attr = tc->getDTBPtr()->getAttr(); 182610037SARM gem5 Developers uint64_t attr1 = attr >> 56; 182710037SARM gem5 Developers if (!attr1 || attr1 ==0x44) { 182810037SARM gem5 Developers attr |= 0x100; 182910037SARM gem5 Developers attr &= ~ uint64_t(0x80); 183010037SARM gem5 Developers } 183110037SARM gem5 Developers newVal = (paddr & mask(47, 12)) | attr; 183210037SARM gem5 Developers DPRINTF(MiscRegs, 183310037SARM gem5 Developers "MISCREG: Translated addr %#x: PAR_EL1: %#xx\n", 183410037SARM gem5 Developers val, newVal); 183510037SARM gem5 Developers } else { 183610037SARM gem5 Developers ArmFault *armFault = reinterpret_cast<ArmFault *>(fault.get()); 183710037SARM gem5 Developers // Set fault bit and FSR 183810037SARM gem5 Developers FSR fsr = armFault->getFsr(tc); 183910037SARM gem5 Developers 184010037SARM gem5 Developers newVal = ((fsr >> 9) & 1) << 11; 184110037SARM gem5 Developers // rearange fault status 184210037SARM gem5 Developers newVal |= ((fsr >> 0) & 0x3f) << 1; 184310037SARM gem5 Developers newVal |= 0x1; // F bit 184410037SARM gem5 Developers newVal |= ((armFault->iss() >> 7) & 0x1) << 8; 184510037SARM gem5 Developers newVal |= armFault->isStage2() ? 0x200 : 0; 184610037SARM gem5 Developers DPRINTF(MiscRegs, 184710037SARM gem5 Developers "MISCREG: Translated addr %#x fault fsr %#x: PAR: %#x\n", 184810037SARM gem5 Developers val, fsr, newVal); 184910037SARM gem5 Developers } 185010037SARM gem5 Developers delete req; 185110037SARM gem5 Developers setMiscRegNoEffect(MISCREG_PAR_EL1, newVal); 185210037SARM gem5 Developers return; 185310037SARM gem5 Developers } 185410037SARM gem5 Developers case MISCREG_SPSR_EL3: 185510037SARM gem5 Developers case MISCREG_SPSR_EL2: 185610037SARM gem5 Developers case MISCREG_SPSR_EL1: 185710037SARM gem5 Developers // Force bits 23:21 to 0 185810037SARM gem5 Developers newVal = val & ~(0x7 << 21); 185910037SARM gem5 Developers break; 18608549Sdaniel.johnson@arm.com case MISCREG_L2CTLR: 18618549Sdaniel.johnson@arm.com warn("miscreg L2CTLR (%s) written with %#x. ignored...\n", 18628549Sdaniel.johnson@arm.com miscRegName[misc_reg], uint32_t(val)); 186310037SARM gem5 Developers break; 186410037SARM gem5 Developers 186510037SARM gem5 Developers // Generic Timer registers 186610037SARM gem5 Developers case MISCREG_CNTFRQ: 186710037SARM gem5 Developers case MISCREG_CNTFRQ_EL0: 186810037SARM gem5 Developers getSystemCounter(tc)->setFreq(val); 186910037SARM gem5 Developers break; 187010037SARM gem5 Developers case MISCREG_CNTP_CVAL: 187110037SARM gem5 Developers case MISCREG_CNTP_CVAL_EL0: 187210037SARM gem5 Developers getArchTimer(tc, tc->cpuId())->setCompareValue(val); 187310037SARM gem5 Developers break; 187410037SARM gem5 Developers case MISCREG_CNTP_TVAL: 187510037SARM gem5 Developers case MISCREG_CNTP_TVAL_EL0: 187610037SARM gem5 Developers getArchTimer(tc, tc->cpuId())->setTimerValue(val); 187710037SARM gem5 Developers break; 187810037SARM gem5 Developers case MISCREG_CNTP_CTL: 187910037SARM gem5 Developers case MISCREG_CNTP_CTL_EL0: 188010037SARM gem5 Developers getArchTimer(tc, tc->cpuId())->setControl(val); 188110037SARM gem5 Developers break; 188210037SARM gem5 Developers // PL1 phys. timer, secure 188310037SARM gem5 Developers // AArch64 188410037SARM gem5 Developers case MISCREG_CNTPS_CVAL_EL1: 188510037SARM gem5 Developers case MISCREG_CNTPS_TVAL_EL1: 188610037SARM gem5 Developers case MISCREG_CNTPS_CTL_EL1: 188710037SARM gem5 Developers // PL2 phys. timer, non-secure 188810037SARM gem5 Developers // AArch32 188910037SARM gem5 Developers case MISCREG_CNTHCTL: 189010037SARM gem5 Developers case MISCREG_CNTHP_CVAL: 189110037SARM gem5 Developers case MISCREG_CNTHP_TVAL: 189210037SARM gem5 Developers case MISCREG_CNTHP_CTL: 189310037SARM gem5 Developers // AArch64 189410037SARM gem5 Developers case MISCREG_CNTHCTL_EL2: 189510037SARM gem5 Developers case MISCREG_CNTHP_CVAL_EL2: 189610037SARM gem5 Developers case MISCREG_CNTHP_TVAL_EL2: 189710037SARM gem5 Developers case MISCREG_CNTHP_CTL_EL2: 189810037SARM gem5 Developers // Virtual timer 189910037SARM gem5 Developers // AArch32 190010037SARM gem5 Developers case MISCREG_CNTV_CVAL: 190110037SARM gem5 Developers case MISCREG_CNTV_TVAL: 190210037SARM gem5 Developers case MISCREG_CNTV_CTL: 190310037SARM gem5 Developers // AArch64 190410037SARM gem5 Developers // case MISCREG_CNTV_CVAL_EL2: 190510037SARM gem5 Developers // case MISCREG_CNTV_TVAL_EL2: 190610037SARM gem5 Developers // case MISCREG_CNTV_CTL_EL2: 190710037SARM gem5 Developers break; 19087405SAli.Saidi@ARM.com } 19097405SAli.Saidi@ARM.com } 19107405SAli.Saidi@ARM.com setMiscRegNoEffect(misc_reg, newVal); 19117405SAli.Saidi@ARM.com} 19127405SAli.Saidi@ARM.com 191310037SARM gem5 Developersvoid 191410037SARM gem5 DevelopersISA::tlbiVA(ThreadContext *tc, MiscReg newVal, uint8_t asid, bool secure_lookup, 191510037SARM gem5 Developers uint8_t target_el) 191610037SARM gem5 Developers{ 191710037SARM gem5 Developers if (haveLargeAsid64) 191810037SARM gem5 Developers asid &= mask(8); 191910037SARM gem5 Developers Addr va = ((Addr) bits(newVal, 43, 0)) << 12; 192010037SARM gem5 Developers System *sys = tc->getSystemPtr(); 192110037SARM gem5 Developers for (int x = 0; x < sys->numContexts(); x++) { 192210037SARM gem5 Developers ThreadContext *oc = sys->getThreadContext(x); 192310037SARM gem5 Developers assert(oc->getITBPtr() && oc->getDTBPtr()); 192410037SARM gem5 Developers oc->getITBPtr()->flushMvaAsid(va, asid, 192510037SARM gem5 Developers secure_lookup, target_el); 192610037SARM gem5 Developers oc->getDTBPtr()->flushMvaAsid(va, asid, 192710037SARM gem5 Developers secure_lookup, target_el); 192810037SARM gem5 Developers 192910037SARM gem5 Developers CheckerCPU *checker = oc->getCheckerCpuPtr(); 193010037SARM gem5 Developers if (checker) { 193110037SARM gem5 Developers checker->getITBPtr()->flushMvaAsid( 193210037SARM gem5 Developers va, asid, secure_lookup, target_el); 193310037SARM gem5 Developers checker->getDTBPtr()->flushMvaAsid( 193410037SARM gem5 Developers va, asid, secure_lookup, target_el); 193510037SARM gem5 Developers } 193610037SARM gem5 Developers } 193710037SARM gem5 Developers} 193810037SARM gem5 Developers 193910037SARM gem5 Developersvoid 194010037SARM gem5 DevelopersISA::tlbiALL(ThreadContext *tc, bool secure_lookup, uint8_t target_el) 194110037SARM gem5 Developers{ 194210037SARM gem5 Developers System *sys = tc->getSystemPtr(); 194310037SARM gem5 Developers for (int x = 0; x < sys->numContexts(); x++) { 194410037SARM gem5 Developers ThreadContext *oc = sys->getThreadContext(x); 194510037SARM gem5 Developers assert(oc->getITBPtr() && oc->getDTBPtr()); 194610037SARM gem5 Developers oc->getITBPtr()->flushAllSecurity(secure_lookup, target_el); 194710037SARM gem5 Developers oc->getDTBPtr()->flushAllSecurity(secure_lookup, target_el); 194810037SARM gem5 Developers 194910037SARM gem5 Developers // If CheckerCPU is connected, need to notify it of a flush 195010037SARM gem5 Developers CheckerCPU *checker = oc->getCheckerCpuPtr(); 195110037SARM gem5 Developers if (checker) { 195210037SARM gem5 Developers checker->getITBPtr()->flushAllSecurity(secure_lookup, 195310037SARM gem5 Developers target_el); 195410037SARM gem5 Developers checker->getDTBPtr()->flushAllSecurity(secure_lookup, 195510037SARM gem5 Developers target_el); 195610037SARM gem5 Developers } 195710037SARM gem5 Developers } 195810037SARM gem5 Developers} 195910037SARM gem5 Developers 196010037SARM gem5 Developersvoid 196110037SARM gem5 DevelopersISA::tlbiALLN(ThreadContext *tc, bool hyp, uint8_t target_el) 196210037SARM gem5 Developers{ 196310037SARM gem5 Developers System *sys = tc->getSystemPtr(); 196410037SARM gem5 Developers for (int x = 0; x < sys->numContexts(); x++) { 196510037SARM gem5 Developers ThreadContext *oc = sys->getThreadContext(x); 196610037SARM gem5 Developers assert(oc->getITBPtr() && oc->getDTBPtr()); 196710037SARM gem5 Developers oc->getITBPtr()->flushAllNs(hyp, target_el); 196810037SARM gem5 Developers oc->getDTBPtr()->flushAllNs(hyp, target_el); 196910037SARM gem5 Developers 197010037SARM gem5 Developers CheckerCPU *checker = oc->getCheckerCpuPtr(); 197110037SARM gem5 Developers if (checker) { 197210037SARM gem5 Developers checker->getITBPtr()->flushAllNs(hyp, target_el); 197310037SARM gem5 Developers checker->getDTBPtr()->flushAllNs(hyp, target_el); 197410037SARM gem5 Developers } 197510037SARM gem5 Developers } 197610037SARM gem5 Developers} 197710037SARM gem5 Developers 197810037SARM gem5 Developersvoid 197910037SARM gem5 DevelopersISA::tlbiMVA(ThreadContext *tc, MiscReg newVal, bool secure_lookup, bool hyp, 198010037SARM gem5 Developers uint8_t target_el) 198110037SARM gem5 Developers{ 198210037SARM gem5 Developers System *sys = tc->getSystemPtr(); 198310037SARM gem5 Developers for (int x = 0; x < sys->numContexts(); x++) { 198410037SARM gem5 Developers ThreadContext *oc = sys->getThreadContext(x); 198510037SARM gem5 Developers assert(oc->getITBPtr() && oc->getDTBPtr()); 198610037SARM gem5 Developers oc->getITBPtr()->flushMva(mbits(newVal, 31,12), 198710037SARM gem5 Developers secure_lookup, hyp, target_el); 198810037SARM gem5 Developers oc->getDTBPtr()->flushMva(mbits(newVal, 31,12), 198910037SARM gem5 Developers secure_lookup, hyp, target_el); 199010037SARM gem5 Developers 199110037SARM gem5 Developers CheckerCPU *checker = oc->getCheckerCpuPtr(); 199210037SARM gem5 Developers if (checker) { 199310037SARM gem5 Developers checker->getITBPtr()->flushMva(mbits(newVal, 31,12), 199410037SARM gem5 Developers secure_lookup, hyp, target_el); 199510037SARM gem5 Developers checker->getDTBPtr()->flushMva(mbits(newVal, 31,12), 199610037SARM gem5 Developers secure_lookup, hyp, target_el); 199710037SARM gem5 Developers } 199810037SARM gem5 Developers } 199910037SARM gem5 Developers} 200010037SARM gem5 Developers 200110037SARM gem5 Developers::GenericTimer::SystemCounter * 200210037SARM gem5 DevelopersISA::getSystemCounter(ThreadContext *tc) 200310037SARM gem5 Developers{ 200410037SARM gem5 Developers ::GenericTimer::SystemCounter *cnt = ((ArmSystem *) tc->getSystemPtr())-> 200510037SARM gem5 Developers getSystemCounter(); 200610037SARM gem5 Developers if (cnt == NULL) { 200710037SARM gem5 Developers panic("System counter not available\n"); 200810037SARM gem5 Developers } 200910037SARM gem5 Developers return cnt; 201010037SARM gem5 Developers} 201110037SARM gem5 Developers 201210037SARM gem5 Developers::GenericTimer::ArchTimer * 201310037SARM gem5 DevelopersISA::getArchTimer(ThreadContext *tc, int cpu_id) 201410037SARM gem5 Developers{ 201510037SARM gem5 Developers ::GenericTimer::ArchTimer *timer = ((ArmSystem *) tc->getSystemPtr())-> 201610037SARM gem5 Developers getArchTimer(cpu_id); 201710037SARM gem5 Developers if (timer == NULL) { 201810037SARM gem5 Developers panic("Architected timer not available\n"); 201910037SARM gem5 Developers } 202010037SARM gem5 Developers return timer; 202110037SARM gem5 Developers} 202210037SARM gem5 Developers 20237405SAli.Saidi@ARM.com} 20249384SAndreas.Sandberg@arm.com 20259384SAndreas.Sandberg@arm.comArmISA::ISA * 20269384SAndreas.Sandberg@arm.comArmISAParams::create() 20279384SAndreas.Sandberg@arm.com{ 20289384SAndreas.Sandberg@arm.com return new ArmISA::ISA(this); 20299384SAndreas.Sandberg@arm.com} 2030