isa.cc revision 8733
17405SAli.Saidi@ARM.com/* 28733Sgeoffrey.blake@arm.com * Copyright (c) 2010-2011 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" 428733Sgeoffrey.blake@arm.com#include "config/use_checker.hh" 438232Snate@binkert.org#include "debug/Arm.hh" 448232Snate@binkert.org#include "debug/MiscRegs.hh" 457678Sgblack@eecs.umich.edu#include "sim/faults.hh" 468059SAli.Saidi@ARM.com#include "sim/stat_control.hh" 478284SAli.Saidi@ARM.com#include "sim/system.hh" 487405SAli.Saidi@ARM.com 498733Sgeoffrey.blake@arm.com#if USE_CHECKER 508733Sgeoffrey.blake@arm.com#include "cpu/checker/cpu.hh" 518733Sgeoffrey.blake@arm.com#endif 528733Sgeoffrey.blake@arm.com 537405SAli.Saidi@ARM.comnamespace ArmISA 547405SAli.Saidi@ARM.com{ 557405SAli.Saidi@ARM.com 567427Sgblack@eecs.umich.eduvoid 577427Sgblack@eecs.umich.eduISA::clear() 587427Sgblack@eecs.umich.edu{ 597427Sgblack@eecs.umich.edu SCTLR sctlr_rst = miscRegs[MISCREG_SCTLR_RST]; 608299Schander.sudanthi@arm.com uint32_t midr = miscRegs[MISCREG_MIDR]; 617427Sgblack@eecs.umich.edu memset(miscRegs, 0, sizeof(miscRegs)); 627427Sgblack@eecs.umich.edu CPSR cpsr = 0; 637427Sgblack@eecs.umich.edu cpsr.mode = MODE_USER; 647427Sgblack@eecs.umich.edu miscRegs[MISCREG_CPSR] = cpsr; 657427Sgblack@eecs.umich.edu updateRegMap(cpsr); 667427Sgblack@eecs.umich.edu 677427Sgblack@eecs.umich.edu SCTLR sctlr = 0; 687604SGene.Wu@arm.com sctlr.te = (bool)sctlr_rst.te; 697427Sgblack@eecs.umich.edu sctlr.nmfi = (bool)sctlr_rst.nmfi; 707427Sgblack@eecs.umich.edu sctlr.v = (bool)sctlr_rst.v; 717427Sgblack@eecs.umich.edu sctlr.u = 1; 727427Sgblack@eecs.umich.edu sctlr.xp = 1; 737427Sgblack@eecs.umich.edu sctlr.rao2 = 1; 747427Sgblack@eecs.umich.edu sctlr.rao3 = 1; 757427Sgblack@eecs.umich.edu sctlr.rao4 = 1; 767427Sgblack@eecs.umich.edu miscRegs[MISCREG_SCTLR] = sctlr; 777427Sgblack@eecs.umich.edu miscRegs[MISCREG_SCTLR_RST] = sctlr_rst; 787427Sgblack@eecs.umich.edu 798299Schander.sudanthi@arm.com // Preserve MIDR accross reset 808299Schander.sudanthi@arm.com miscRegs[MISCREG_MIDR] = midr; 818299Schander.sudanthi@arm.com 827427Sgblack@eecs.umich.edu /* Start with an event in the mailbox */ 837427Sgblack@eecs.umich.edu miscRegs[MISCREG_SEV_MAILBOX] = 1; 847427Sgblack@eecs.umich.edu 857427Sgblack@eecs.umich.edu // Separate Instruction and Data TLBs. 867427Sgblack@eecs.umich.edu miscRegs[MISCREG_TLBTR] = 1; 877427Sgblack@eecs.umich.edu 887427Sgblack@eecs.umich.edu MVFR0 mvfr0 = 0; 897427Sgblack@eecs.umich.edu mvfr0.advSimdRegisters = 2; 907427Sgblack@eecs.umich.edu mvfr0.singlePrecision = 2; 917427Sgblack@eecs.umich.edu mvfr0.doublePrecision = 2; 927427Sgblack@eecs.umich.edu mvfr0.vfpExceptionTrapping = 0; 937427Sgblack@eecs.umich.edu mvfr0.divide = 1; 947427Sgblack@eecs.umich.edu mvfr0.squareRoot = 1; 957427Sgblack@eecs.umich.edu mvfr0.shortVectors = 1; 967427Sgblack@eecs.umich.edu mvfr0.roundingModes = 1; 977427Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR0] = mvfr0; 987427Sgblack@eecs.umich.edu 997427Sgblack@eecs.umich.edu MVFR1 mvfr1 = 0; 1007427Sgblack@eecs.umich.edu mvfr1.flushToZero = 1; 1017427Sgblack@eecs.umich.edu mvfr1.defaultNaN = 1; 1027427Sgblack@eecs.umich.edu mvfr1.advSimdLoadStore = 1; 1037427Sgblack@eecs.umich.edu mvfr1.advSimdInteger = 1; 1047427Sgblack@eecs.umich.edu mvfr1.advSimdSinglePrecision = 1; 1057427Sgblack@eecs.umich.edu mvfr1.advSimdHalfPrecision = 1; 1067427Sgblack@eecs.umich.edu mvfr1.vfpHalfPrecision = 1; 1077427Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR1] = mvfr1; 1087427Sgblack@eecs.umich.edu 1097427Sgblack@eecs.umich.edu miscRegs[MISCREG_MPIDR] = 0; 1107427Sgblack@eecs.umich.edu 1117436Sdam.sunwoo@arm.com // Reset values of PRRR and NMRR are implementation dependent 1127436Sdam.sunwoo@arm.com 1137436Sdam.sunwoo@arm.com miscRegs[MISCREG_PRRR] = 1147436Sdam.sunwoo@arm.com (1 << 19) | // 19 1157436Sdam.sunwoo@arm.com (0 << 18) | // 18 1167436Sdam.sunwoo@arm.com (0 << 17) | // 17 1177436Sdam.sunwoo@arm.com (1 << 16) | // 16 1187436Sdam.sunwoo@arm.com (2 << 14) | // 15:14 1197436Sdam.sunwoo@arm.com (0 << 12) | // 13:12 1207436Sdam.sunwoo@arm.com (2 << 10) | // 11:10 1217436Sdam.sunwoo@arm.com (2 << 8) | // 9:8 1227436Sdam.sunwoo@arm.com (2 << 6) | // 7:6 1237436Sdam.sunwoo@arm.com (2 << 4) | // 5:4 1247436Sdam.sunwoo@arm.com (1 << 2) | // 3:2 1257436Sdam.sunwoo@arm.com 0; // 1:0 1267436Sdam.sunwoo@arm.com miscRegs[MISCREG_NMRR] = 1277436Sdam.sunwoo@arm.com (1 << 30) | // 31:30 1287436Sdam.sunwoo@arm.com (0 << 26) | // 27:26 1297436Sdam.sunwoo@arm.com (0 << 24) | // 25:24 1307436Sdam.sunwoo@arm.com (3 << 22) | // 23:22 1317436Sdam.sunwoo@arm.com (2 << 20) | // 21:20 1327436Sdam.sunwoo@arm.com (0 << 18) | // 19:18 1337436Sdam.sunwoo@arm.com (0 << 16) | // 17:16 1347436Sdam.sunwoo@arm.com (1 << 14) | // 15:14 1357436Sdam.sunwoo@arm.com (0 << 12) | // 13:12 1367436Sdam.sunwoo@arm.com (2 << 10) | // 11:10 1377436Sdam.sunwoo@arm.com (0 << 8) | // 9:8 1387436Sdam.sunwoo@arm.com (3 << 6) | // 7:6 1397436Sdam.sunwoo@arm.com (2 << 4) | // 5:4 1407436Sdam.sunwoo@arm.com (0 << 2) | // 3:2 1417436Sdam.sunwoo@arm.com 0; // 1:0 1427436Sdam.sunwoo@arm.com 1437644Sali.saidi@arm.com miscRegs[MISCREG_CPACR] = 0; 1447644Sali.saidi@arm.com miscRegs[MISCREG_FPSID] = 0x410430A0; 1458147SAli.Saidi@ARM.com 1468147SAli.Saidi@ARM.com // See section B4.1.84 of ARM ARM 1478147SAli.Saidi@ARM.com // All values are latest for ARMv7-A profile 1488520SAli.Saidi@ARM.com miscRegs[MISCREG_ID_ISAR0] = 0x02101111; 1498147SAli.Saidi@ARM.com miscRegs[MISCREG_ID_ISAR1] = 0x02112111; 1508147SAli.Saidi@ARM.com miscRegs[MISCREG_ID_ISAR2] = 0x21232141; 1518147SAli.Saidi@ARM.com miscRegs[MISCREG_ID_ISAR3] = 0x01112131; 1528147SAli.Saidi@ARM.com miscRegs[MISCREG_ID_ISAR4] = 0x10010142; 1538147SAli.Saidi@ARM.com miscRegs[MISCREG_ID_ISAR5] = 0x00000000; 1548147SAli.Saidi@ARM.com 1557427Sgblack@eecs.umich.edu //XXX We need to initialize the rest of the state. 1567427Sgblack@eecs.umich.edu} 1577427Sgblack@eecs.umich.edu 1587405SAli.Saidi@ARM.comMiscReg 1597405SAli.Saidi@ARM.comISA::readMiscRegNoEffect(int misc_reg) 1607405SAli.Saidi@ARM.com{ 1617405SAli.Saidi@ARM.com assert(misc_reg < NumMiscRegs); 1627614Sminkyu.jeong@arm.com 1637614Sminkyu.jeong@arm.com int flat_idx; 1647614Sminkyu.jeong@arm.com if (misc_reg == MISCREG_SPSR) 1657614Sminkyu.jeong@arm.com flat_idx = flattenMiscIndex(misc_reg); 1667614Sminkyu.jeong@arm.com else 1677614Sminkyu.jeong@arm.com flat_idx = misc_reg; 1687614Sminkyu.jeong@arm.com MiscReg val = miscRegs[flat_idx]; 1697614Sminkyu.jeong@arm.com 1707614Sminkyu.jeong@arm.com DPRINTF(MiscRegs, "Reading From misc reg %d (%d) : %#x\n", 1717614Sminkyu.jeong@arm.com misc_reg, flat_idx, val); 1727614Sminkyu.jeong@arm.com return val; 1737405SAli.Saidi@ARM.com} 1747405SAli.Saidi@ARM.com 1757405SAli.Saidi@ARM.com 1767405SAli.Saidi@ARM.comMiscReg 1777405SAli.Saidi@ARM.comISA::readMiscReg(int misc_reg, ThreadContext *tc) 1787405SAli.Saidi@ARM.com{ 1797405SAli.Saidi@ARM.com if (misc_reg == MISCREG_CPSR) { 1807405SAli.Saidi@ARM.com CPSR cpsr = miscRegs[misc_reg]; 1817720Sgblack@eecs.umich.edu PCState pc = tc->pcState(); 1827720Sgblack@eecs.umich.edu cpsr.j = pc.jazelle() ? 1 : 0; 1837720Sgblack@eecs.umich.edu cpsr.t = pc.thumb() ? 1 : 0; 1847405SAli.Saidi@ARM.com return cpsr; 1857405SAli.Saidi@ARM.com } 1867757SAli.Saidi@ARM.com if (misc_reg >= MISCREG_CP15_UNIMP_START) 1877405SAli.Saidi@ARM.com panic("Unimplemented CP15 register %s read.\n", 1887405SAli.Saidi@ARM.com miscRegName[misc_reg]); 1897757SAli.Saidi@ARM.com 1907405SAli.Saidi@ARM.com switch (misc_reg) { 1918284SAli.Saidi@ARM.com case MISCREG_MPIDR: 1928284SAli.Saidi@ARM.com return tc->cpuId(); 1938284SAli.Saidi@ARM.com break; 1948468Swade.walker@arm.com case MISCREG_ID_MMFR0: 1958468Swade.walker@arm.com return 0x03; // VMSAv7 support 1968468Swade.walker@arm.com case MISCREG_ID_MMFR2: 1978468Swade.walker@arm.com return 0x01230000; // no HW access | WFI stalling | ISB and DSB 1988468Swade.walker@arm.com // | all TLB maintenance | no Harvard 1998284SAli.Saidi@ARM.com case MISCREG_ID_MMFR3: 2008284SAli.Saidi@ARM.com return 0xF0102211; // SuperSec | Coherent TLB | Bcast Maint | 2018284SAli.Saidi@ARM.com // BP Maint | Cache Maint Set/way | Cache Maint MVA 2027405SAli.Saidi@ARM.com case MISCREG_CLIDR: 2037731SAli.Saidi@ARM.com warn_once("The clidr register always reports 0 caches.\n"); 2048468Swade.walker@arm.com warn_once("clidr LoUIS field of 0b001 to match current " 2058468Swade.walker@arm.com "ARM implementations.\n"); 2068468Swade.walker@arm.com return 0x00200000; 2077405SAli.Saidi@ARM.com case MISCREG_CCSIDR: 2087731SAli.Saidi@ARM.com warn_once("The ccsidr register isn't implemented and " 2097405SAli.Saidi@ARM.com "always reads as 0.\n"); 2107405SAli.Saidi@ARM.com break; 2117405SAli.Saidi@ARM.com case MISCREG_ID_PFR0: 2127588SAli.Saidi@arm.com warn("Returning thumbEE disabled for now since we don't support CP14" 2137588SAli.Saidi@arm.com "config registers and jumping to ThumbEE vectors\n"); 2147588SAli.Saidi@arm.com return 0x0031; // !ThumbEE | !Jazelle | Thumb | ARM 2158299Schander.sudanthi@arm.com case MISCREG_ID_PFR1: 2168299Schander.sudanthi@arm.com warn("reading unimplmented register ID_PFR1"); 2178299Schander.sudanthi@arm.com return 0; 2187583SAli.Saidi@arm.com case MISCREG_CTR: 2197583SAli.Saidi@arm.com return 0x86468006; // V7, 64 byte cache line, load/exclusive is exact 2207583SAli.Saidi@arm.com case MISCREG_ACTLR: 2217583SAli.Saidi@arm.com warn("Not doing anything for miscreg ACTLR\n"); 2227583SAli.Saidi@arm.com break; 2237583SAli.Saidi@arm.com case MISCREG_PMCR: 2247583SAli.Saidi@arm.com case MISCREG_PMCCNTR: 2257583SAli.Saidi@arm.com case MISCREG_PMSELR: 2268299Schander.sudanthi@arm.com warn("Not doing anything for read to miscreg %s\n", 2277583SAli.Saidi@arm.com miscRegName[misc_reg]); 2287583SAli.Saidi@arm.com break; 2298302SAli.Saidi@ARM.com case MISCREG_CPSR_Q: 2308302SAli.Saidi@ARM.com panic("shouldn't be reading this register seperately\n"); 2317783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_QC: 2327783SGiacomo.Gabrielli@arm.com return readMiscRegNoEffect(MISCREG_FPSCR) & ~FpscrQcMask; 2337783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_EXC: 2347783SGiacomo.Gabrielli@arm.com return readMiscRegNoEffect(MISCREG_FPSCR) & ~FpscrExcMask; 2358549Sdaniel.johnson@arm.com case MISCREG_L2CTLR: 2368549Sdaniel.johnson@arm.com // mostly unimplemented, just set NumCPUs field from sim and return 2378549Sdaniel.johnson@arm.com L2CTLR l2ctlr = 0; 2388549Sdaniel.johnson@arm.com // b00:1CPU to b11:4CPUs 2398549Sdaniel.johnson@arm.com l2ctlr.numCPUs = tc->getSystemPtr()->numContexts() - 1; 2408549Sdaniel.johnson@arm.com return l2ctlr; 2417405SAli.Saidi@ARM.com } 2427405SAli.Saidi@ARM.com return readMiscRegNoEffect(misc_reg); 2437405SAli.Saidi@ARM.com} 2447405SAli.Saidi@ARM.com 2457405SAli.Saidi@ARM.comvoid 2467405SAli.Saidi@ARM.comISA::setMiscRegNoEffect(int misc_reg, const MiscReg &val) 2477405SAli.Saidi@ARM.com{ 2487405SAli.Saidi@ARM.com assert(misc_reg < NumMiscRegs); 2497614Sminkyu.jeong@arm.com 2507614Sminkyu.jeong@arm.com int flat_idx; 2517614Sminkyu.jeong@arm.com if (misc_reg == MISCREG_SPSR) 2527614Sminkyu.jeong@arm.com flat_idx = flattenMiscIndex(misc_reg); 2537614Sminkyu.jeong@arm.com else 2547614Sminkyu.jeong@arm.com flat_idx = misc_reg; 2557614Sminkyu.jeong@arm.com miscRegs[flat_idx] = val; 2567614Sminkyu.jeong@arm.com 2577614Sminkyu.jeong@arm.com DPRINTF(MiscRegs, "Writing to misc reg %d (%d) : %#x\n", misc_reg, 2587614Sminkyu.jeong@arm.com flat_idx, val); 2597405SAli.Saidi@ARM.com} 2607405SAli.Saidi@ARM.com 2617405SAli.Saidi@ARM.comvoid 2627405SAli.Saidi@ARM.comISA::setMiscReg(int misc_reg, const MiscReg &val, ThreadContext *tc) 2637405SAli.Saidi@ARM.com{ 2647749SAli.Saidi@ARM.com 2657405SAli.Saidi@ARM.com MiscReg newVal = val; 2668284SAli.Saidi@ARM.com int x; 2678284SAli.Saidi@ARM.com System *sys; 2688284SAli.Saidi@ARM.com ThreadContext *oc; 2698284SAli.Saidi@ARM.com 2707405SAli.Saidi@ARM.com if (misc_reg == MISCREG_CPSR) { 2717405SAli.Saidi@ARM.com updateRegMap(val); 2727749SAli.Saidi@ARM.com 2737749SAli.Saidi@ARM.com 2747749SAli.Saidi@ARM.com CPSR old_cpsr = miscRegs[MISCREG_CPSR]; 2757749SAli.Saidi@ARM.com int old_mode = old_cpsr.mode; 2767405SAli.Saidi@ARM.com CPSR cpsr = val; 2777749SAli.Saidi@ARM.com if (old_mode != cpsr.mode) { 2787749SAli.Saidi@ARM.com tc->getITBPtr()->invalidateMiscReg(); 2797749SAli.Saidi@ARM.com tc->getDTBPtr()->invalidateMiscReg(); 2807749SAli.Saidi@ARM.com } 2817749SAli.Saidi@ARM.com 2827614Sminkyu.jeong@arm.com DPRINTF(Arm, "Updating CPSR from %#x to %#x f:%d i:%d a:%d mode:%#x\n", 2837614Sminkyu.jeong@arm.com miscRegs[misc_reg], cpsr, cpsr.f, cpsr.i, cpsr.a, cpsr.mode); 2847720Sgblack@eecs.umich.edu PCState pc = tc->pcState(); 2857720Sgblack@eecs.umich.edu pc.nextThumb(cpsr.t); 2867720Sgblack@eecs.umich.edu pc.nextJazelle(cpsr.j); 2878733Sgeoffrey.blake@arm.com#if USE_CHECKER 2888733Sgeoffrey.blake@arm.com tc->pcStateNoRecord(pc); 2898733Sgeoffrey.blake@arm.com#else 2907720Sgblack@eecs.umich.edu tc->pcState(pc); 2918733Sgeoffrey.blake@arm.com#endif //USE_CHECKER 2927408Sgblack@eecs.umich.edu } else if (misc_reg >= MISCREG_CP15_UNIMP_START && 2937405SAli.Saidi@ARM.com misc_reg < MISCREG_CP15_END) { 2947405SAli.Saidi@ARM.com panic("Unimplemented CP15 register %s wrote with %#x.\n", 2957405SAli.Saidi@ARM.com miscRegName[misc_reg], val); 2967408Sgblack@eecs.umich.edu } else { 2977408Sgblack@eecs.umich.edu switch (misc_reg) { 2987408Sgblack@eecs.umich.edu case MISCREG_CPACR: 2997408Sgblack@eecs.umich.edu { 3008206SWilliam.Wang@arm.com 3018206SWilliam.Wang@arm.com const uint32_t ones = (uint32_t)(-1); 3028206SWilliam.Wang@arm.com CPACR cpacrMask = 0; 3038206SWilliam.Wang@arm.com // Only cp10, cp11, and ase are implemented, nothing else should 3048206SWilliam.Wang@arm.com // be writable 3058206SWilliam.Wang@arm.com cpacrMask.cp10 = ones; 3068206SWilliam.Wang@arm.com cpacrMask.cp11 = ones; 3078206SWilliam.Wang@arm.com cpacrMask.asedis = ones; 3088206SWilliam.Wang@arm.com newVal &= cpacrMask; 3098206SWilliam.Wang@arm.com DPRINTF(MiscRegs, "Writing misc reg %s: %#x\n", 3108206SWilliam.Wang@arm.com miscRegName[misc_reg], newVal); 3117408Sgblack@eecs.umich.edu } 3127408Sgblack@eecs.umich.edu break; 3137408Sgblack@eecs.umich.edu case MISCREG_CSSELR: 3147731SAli.Saidi@ARM.com warn_once("The csselr register isn't implemented.\n"); 3158206SWilliam.Wang@arm.com return; 3167408Sgblack@eecs.umich.edu case MISCREG_FPSCR: 3177408Sgblack@eecs.umich.edu { 3187408Sgblack@eecs.umich.edu const uint32_t ones = (uint32_t)(-1); 3197408Sgblack@eecs.umich.edu FPSCR fpscrMask = 0; 3207408Sgblack@eecs.umich.edu fpscrMask.ioc = ones; 3217408Sgblack@eecs.umich.edu fpscrMask.dzc = ones; 3227408Sgblack@eecs.umich.edu fpscrMask.ofc = ones; 3237408Sgblack@eecs.umich.edu fpscrMask.ufc = ones; 3247408Sgblack@eecs.umich.edu fpscrMask.ixc = ones; 3257408Sgblack@eecs.umich.edu fpscrMask.idc = ones; 3267408Sgblack@eecs.umich.edu fpscrMask.len = ones; 3277408Sgblack@eecs.umich.edu fpscrMask.stride = ones; 3287408Sgblack@eecs.umich.edu fpscrMask.rMode = ones; 3297408Sgblack@eecs.umich.edu fpscrMask.fz = ones; 3307408Sgblack@eecs.umich.edu fpscrMask.dn = ones; 3317408Sgblack@eecs.umich.edu fpscrMask.ahp = ones; 3327408Sgblack@eecs.umich.edu fpscrMask.qc = ones; 3337408Sgblack@eecs.umich.edu fpscrMask.v = ones; 3347408Sgblack@eecs.umich.edu fpscrMask.c = ones; 3357408Sgblack@eecs.umich.edu fpscrMask.z = ones; 3367408Sgblack@eecs.umich.edu fpscrMask.n = ones; 3377408Sgblack@eecs.umich.edu newVal = (newVal & (uint32_t)fpscrMask) | 3387408Sgblack@eecs.umich.edu (miscRegs[MISCREG_FPSCR] & ~(uint32_t)fpscrMask); 3397408Sgblack@eecs.umich.edu } 3407408Sgblack@eecs.umich.edu break; 3418302SAli.Saidi@ARM.com case MISCREG_CPSR_Q: 3428302SAli.Saidi@ARM.com { 3438302SAli.Saidi@ARM.com assert(!(newVal & ~CpsrMaskQ)); 3448302SAli.Saidi@ARM.com newVal = miscRegs[MISCREG_CPSR] | newVal; 3458302SAli.Saidi@ARM.com misc_reg = MISCREG_CPSR; 3468302SAli.Saidi@ARM.com } 3478302SAli.Saidi@ARM.com break; 3487783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_QC: 3497783SGiacomo.Gabrielli@arm.com { 3507783SGiacomo.Gabrielli@arm.com newVal = miscRegs[MISCREG_FPSCR] | (newVal & FpscrQcMask); 3517783SGiacomo.Gabrielli@arm.com misc_reg = MISCREG_FPSCR; 3527783SGiacomo.Gabrielli@arm.com } 3537783SGiacomo.Gabrielli@arm.com break; 3547783SGiacomo.Gabrielli@arm.com case MISCREG_FPSCR_EXC: 3557783SGiacomo.Gabrielli@arm.com { 3567783SGiacomo.Gabrielli@arm.com newVal = miscRegs[MISCREG_FPSCR] | (newVal & FpscrExcMask); 3577783SGiacomo.Gabrielli@arm.com misc_reg = MISCREG_FPSCR; 3587783SGiacomo.Gabrielli@arm.com } 3597783SGiacomo.Gabrielli@arm.com break; 3607408Sgblack@eecs.umich.edu case MISCREG_FPEXC: 3617408Sgblack@eecs.umich.edu { 3628206SWilliam.Wang@arm.com // vfpv3 architecture, section B.6.1 of DDI04068 3638206SWilliam.Wang@arm.com // bit 29 - valid only if fpexc[31] is 0 3647408Sgblack@eecs.umich.edu const uint32_t fpexcMask = 0x60000000; 3657408Sgblack@eecs.umich.edu newVal = (newVal & fpexcMask) | 3667408Sgblack@eecs.umich.edu (miscRegs[MISCREG_FPEXC] & ~fpexcMask); 3677408Sgblack@eecs.umich.edu } 3687408Sgblack@eecs.umich.edu break; 3697408Sgblack@eecs.umich.edu case MISCREG_SCTLR: 3707408Sgblack@eecs.umich.edu { 3717408Sgblack@eecs.umich.edu DPRINTF(MiscRegs, "Writing SCTLR: %#x\n", newVal); 3727408Sgblack@eecs.umich.edu SCTLR sctlr = miscRegs[MISCREG_SCTLR]; 3737408Sgblack@eecs.umich.edu SCTLR new_sctlr = newVal; 3747408Sgblack@eecs.umich.edu new_sctlr.nmfi = (bool)sctlr.nmfi; 3757408Sgblack@eecs.umich.edu miscRegs[MISCREG_SCTLR] = (MiscReg)new_sctlr; 3767749SAli.Saidi@ARM.com tc->getITBPtr()->invalidateMiscReg(); 3777749SAli.Saidi@ARM.com tc->getDTBPtr()->invalidateMiscReg(); 3788527SAli.Saidi@ARM.com 3798527SAli.Saidi@ARM.com // Check if all CPUs are booted with caches enabled 3808527SAli.Saidi@ARM.com // so we can stop enforcing coherency of some kernel 3818527SAli.Saidi@ARM.com // structures manually. 3828527SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 3838527SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 3848527SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 3858527SAli.Saidi@ARM.com SCTLR other_sctlr = oc->readMiscRegNoEffect(MISCREG_SCTLR); 3868527SAli.Saidi@ARM.com if (!other_sctlr.c && oc->status() != ThreadContext::Halted) 3878527SAli.Saidi@ARM.com return; 3888527SAli.Saidi@ARM.com } 3898527SAli.Saidi@ARM.com 3908527SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 3918527SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 3928527SAli.Saidi@ARM.com oc->getDTBPtr()->allCpusCaching(); 3938527SAli.Saidi@ARM.com oc->getITBPtr()->allCpusCaching(); 3948733Sgeoffrey.blake@arm.com#if USE_CHECKER 3958733Sgeoffrey.blake@arm.com CheckerCPU *checker = 3968733Sgeoffrey.blake@arm.com dynamic_cast<CheckerCPU*>(oc->getCheckerCpuPtr()); 3978733Sgeoffrey.blake@arm.com if (checker) { 3988733Sgeoffrey.blake@arm.com checker->getDTBPtr()->allCpusCaching(); 3998733Sgeoffrey.blake@arm.com checker->getITBPtr()->allCpusCaching(); 4008733Sgeoffrey.blake@arm.com } 4018733Sgeoffrey.blake@arm.com#endif 4028527SAli.Saidi@ARM.com } 4037408Sgblack@eecs.umich.edu return; 4047408Sgblack@eecs.umich.edu } 4057408Sgblack@eecs.umich.edu case MISCREG_TLBTR: 4067408Sgblack@eecs.umich.edu case MISCREG_MVFR0: 4077408Sgblack@eecs.umich.edu case MISCREG_MVFR1: 4087408Sgblack@eecs.umich.edu case MISCREG_MPIDR: 4097408Sgblack@eecs.umich.edu case MISCREG_FPSID: 4107408Sgblack@eecs.umich.edu return; 4117408Sgblack@eecs.umich.edu case MISCREG_TLBIALLIS: 4127408Sgblack@eecs.umich.edu case MISCREG_TLBIALL: 4138284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 4148284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 4158284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 4168284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 4178284SAli.Saidi@ARM.com oc->getITBPtr()->flushAll(); 4188284SAli.Saidi@ARM.com oc->getDTBPtr()->flushAll(); 4198733Sgeoffrey.blake@arm.com#if USE_CHECKER 4208733Sgeoffrey.blake@arm.com CheckerCPU *checker = 4218733Sgeoffrey.blake@arm.com dynamic_cast<CheckerCPU*>(oc->getCheckerCpuPtr()); 4228733Sgeoffrey.blake@arm.com if (checker) { 4238733Sgeoffrey.blake@arm.com checker->getITBPtr()->flushAll(); 4248733Sgeoffrey.blake@arm.com checker->getDTBPtr()->flushAll(); 4258733Sgeoffrey.blake@arm.com } 4268733Sgeoffrey.blake@arm.com#endif 4278284SAli.Saidi@ARM.com } 4287408Sgblack@eecs.umich.edu return; 4297408Sgblack@eecs.umich.edu case MISCREG_ITLBIALL: 4307408Sgblack@eecs.umich.edu tc->getITBPtr()->flushAll(); 4317408Sgblack@eecs.umich.edu return; 4327408Sgblack@eecs.umich.edu case MISCREG_DTLBIALL: 4337408Sgblack@eecs.umich.edu tc->getDTBPtr()->flushAll(); 4347408Sgblack@eecs.umich.edu return; 4357408Sgblack@eecs.umich.edu case MISCREG_TLBIMVAIS: 4367408Sgblack@eecs.umich.edu case MISCREG_TLBIMVA: 4378284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 4388284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 4398284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 4408284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 4418284SAli.Saidi@ARM.com oc->getITBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 4428284SAli.Saidi@ARM.com bits(newVal, 7,0)); 4438284SAli.Saidi@ARM.com oc->getDTBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 4448284SAli.Saidi@ARM.com bits(newVal, 7,0)); 4458733Sgeoffrey.blake@arm.com#if USE_CHECKER 4468733Sgeoffrey.blake@arm.com CheckerCPU *checker = 4478733Sgeoffrey.blake@arm.com dynamic_cast<CheckerCPU*>(oc->getCheckerCpuPtr()); 4488733Sgeoffrey.blake@arm.com if (checker) { 4498733Sgeoffrey.blake@arm.com checker->getITBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 4508733Sgeoffrey.blake@arm.com bits(newVal, 7,0)); 4518733Sgeoffrey.blake@arm.com checker->getDTBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 4528733Sgeoffrey.blake@arm.com bits(newVal, 7,0)); 4538733Sgeoffrey.blake@arm.com } 4548733Sgeoffrey.blake@arm.com#endif 4558284SAli.Saidi@ARM.com } 4567408Sgblack@eecs.umich.edu return; 4577408Sgblack@eecs.umich.edu case MISCREG_TLBIASIDIS: 4587408Sgblack@eecs.umich.edu case MISCREG_TLBIASID: 4598284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 4608284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 4618284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 4628284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 4638284SAli.Saidi@ARM.com oc->getITBPtr()->flushAsid(bits(newVal, 7,0)); 4648284SAli.Saidi@ARM.com oc->getDTBPtr()->flushAsid(bits(newVal, 7,0)); 4658733Sgeoffrey.blake@arm.com#if USE_CHECKER 4668733Sgeoffrey.blake@arm.com CheckerCPU *checker = 4678733Sgeoffrey.blake@arm.com dynamic_cast<CheckerCPU*>(oc->getCheckerCpuPtr()); 4688733Sgeoffrey.blake@arm.com if (checker) { 4698733Sgeoffrey.blake@arm.com checker->getITBPtr()->flushAsid(bits(newVal, 7,0)); 4708733Sgeoffrey.blake@arm.com checker->getDTBPtr()->flushAsid(bits(newVal, 7,0)); 4718733Sgeoffrey.blake@arm.com } 4728733Sgeoffrey.blake@arm.com#endif 4738284SAli.Saidi@ARM.com } 4747408Sgblack@eecs.umich.edu return; 4757408Sgblack@eecs.umich.edu case MISCREG_TLBIMVAAIS: 4767408Sgblack@eecs.umich.edu case MISCREG_TLBIMVAA: 4778284SAli.Saidi@ARM.com sys = tc->getSystemPtr(); 4788284SAli.Saidi@ARM.com for (x = 0; x < sys->numContexts(); x++) { 4798284SAli.Saidi@ARM.com oc = sys->getThreadContext(x); 4808284SAli.Saidi@ARM.com assert(oc->getITBPtr() && oc->getDTBPtr()); 4818284SAli.Saidi@ARM.com oc->getITBPtr()->flushMva(mbits(newVal, 31,12)); 4828284SAli.Saidi@ARM.com oc->getDTBPtr()->flushMva(mbits(newVal, 31,12)); 4838733Sgeoffrey.blake@arm.com#if USE_CHECKER 4848733Sgeoffrey.blake@arm.com CheckerCPU *checker = 4858733Sgeoffrey.blake@arm.com dynamic_cast<CheckerCPU*>(oc->getCheckerCpuPtr()); 4868733Sgeoffrey.blake@arm.com if (checker) { 4878733Sgeoffrey.blake@arm.com checker->getITBPtr()->flushMva(mbits(newVal, 31,12)); 4888733Sgeoffrey.blake@arm.com checker->getDTBPtr()->flushMva(mbits(newVal, 31,12)); 4898733Sgeoffrey.blake@arm.com } 4908733Sgeoffrey.blake@arm.com#endif 4918284SAli.Saidi@ARM.com } 4927408Sgblack@eecs.umich.edu return; 4937408Sgblack@eecs.umich.edu case MISCREG_ITLBIMVA: 4947408Sgblack@eecs.umich.edu tc->getITBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 4957408Sgblack@eecs.umich.edu bits(newVal, 7,0)); 4967408Sgblack@eecs.umich.edu return; 4977408Sgblack@eecs.umich.edu case MISCREG_DTLBIMVA: 4987408Sgblack@eecs.umich.edu tc->getDTBPtr()->flushMvaAsid(mbits(newVal, 31, 12), 4997408Sgblack@eecs.umich.edu bits(newVal, 7,0)); 5007408Sgblack@eecs.umich.edu return; 5017408Sgblack@eecs.umich.edu case MISCREG_ITLBIASID: 5027408Sgblack@eecs.umich.edu tc->getITBPtr()->flushAsid(bits(newVal, 7,0)); 5037408Sgblack@eecs.umich.edu return; 5047408Sgblack@eecs.umich.edu case MISCREG_DTLBIASID: 5057408Sgblack@eecs.umich.edu tc->getDTBPtr()->flushAsid(bits(newVal, 7,0)); 5067405SAli.Saidi@ARM.com return; 5077583SAli.Saidi@arm.com case MISCREG_ACTLR: 5087583SAli.Saidi@arm.com warn("Not doing anything for write of miscreg ACTLR\n"); 5097583SAli.Saidi@arm.com break; 5107583SAli.Saidi@arm.com case MISCREG_PMCR: 5118059SAli.Saidi@ARM.com { 5128059SAli.Saidi@ARM.com // Performance counters not implemented. Instead, interpret 5138059SAli.Saidi@ARM.com // a reset command to this register to reset the simulator 5148059SAli.Saidi@ARM.com // statistics. 5158059SAli.Saidi@ARM.com // PMCR_E | PMCR_P | PMCR_C 5168059SAli.Saidi@ARM.com const int ResetAndEnableCounters = 0x7; 5178059SAli.Saidi@ARM.com if (newVal == ResetAndEnableCounters) { 5188059SAli.Saidi@ARM.com inform("Resetting all simobject stats\n"); 5198059SAli.Saidi@ARM.com Stats::schedStatEvent(false, true); 5208059SAli.Saidi@ARM.com break; 5218059SAli.Saidi@ARM.com } 5228059SAli.Saidi@ARM.com } 5237583SAli.Saidi@arm.com case MISCREG_PMCCNTR: 5247583SAli.Saidi@arm.com case MISCREG_PMSELR: 5257583SAli.Saidi@arm.com warn("Not doing anything for write to miscreg %s\n", 5267583SAli.Saidi@arm.com miscRegName[misc_reg]); 5277583SAli.Saidi@arm.com break; 5287436Sdam.sunwoo@arm.com case MISCREG_V2PCWPR: 5297436Sdam.sunwoo@arm.com case MISCREG_V2PCWPW: 5307436Sdam.sunwoo@arm.com case MISCREG_V2PCWUR: 5317436Sdam.sunwoo@arm.com case MISCREG_V2PCWUW: 5327436Sdam.sunwoo@arm.com case MISCREG_V2POWPR: 5337436Sdam.sunwoo@arm.com case MISCREG_V2POWPW: 5347436Sdam.sunwoo@arm.com case MISCREG_V2POWUR: 5357436Sdam.sunwoo@arm.com case MISCREG_V2POWUW: 5367436Sdam.sunwoo@arm.com { 5377436Sdam.sunwoo@arm.com RequestPtr req = new Request; 5387436Sdam.sunwoo@arm.com unsigned flags; 5397436Sdam.sunwoo@arm.com BaseTLB::Mode mode; 5407436Sdam.sunwoo@arm.com Fault fault; 5417436Sdam.sunwoo@arm.com switch(misc_reg) { 5427436Sdam.sunwoo@arm.com case MISCREG_V2PCWPR: 5437436Sdam.sunwoo@arm.com flags = TLB::MustBeOne; 5447436Sdam.sunwoo@arm.com mode = BaseTLB::Read; 5457436Sdam.sunwoo@arm.com break; 5467436Sdam.sunwoo@arm.com case MISCREG_V2PCWPW: 5477436Sdam.sunwoo@arm.com flags = TLB::MustBeOne; 5487436Sdam.sunwoo@arm.com mode = BaseTLB::Write; 5497436Sdam.sunwoo@arm.com break; 5507436Sdam.sunwoo@arm.com case MISCREG_V2PCWUR: 5517436Sdam.sunwoo@arm.com flags = TLB::MustBeOne | TLB::UserMode; 5527436Sdam.sunwoo@arm.com mode = BaseTLB::Read; 5537436Sdam.sunwoo@arm.com break; 5547436Sdam.sunwoo@arm.com case MISCREG_V2PCWUW: 5557436Sdam.sunwoo@arm.com flags = TLB::MustBeOne | TLB::UserMode; 5567436Sdam.sunwoo@arm.com mode = BaseTLB::Write; 5577436Sdam.sunwoo@arm.com break; 5587442Ssaidi@eecs.umich.edu default: 5597436Sdam.sunwoo@arm.com panic("Security Extensions not implemented!"); 5607436Sdam.sunwoo@arm.com } 5618208SAli.Saidi@ARM.com warn("Translating via MISCREG in atomic mode! Fix Me!\n"); 5627720Sgblack@eecs.umich.edu req->setVirt(0, val, 1, flags, tc->pcState().pc()); 5637436Sdam.sunwoo@arm.com fault = tc->getDTBPtr()->translateAtomic(req, tc, mode); 5647436Sdam.sunwoo@arm.com if (fault == NoFault) { 5657436Sdam.sunwoo@arm.com miscRegs[MISCREG_PAR] = 5667436Sdam.sunwoo@arm.com (req->getPaddr() & 0xfffff000) | 5677436Sdam.sunwoo@arm.com (tc->getDTBPtr()->getAttr() ); 5687436Sdam.sunwoo@arm.com DPRINTF(MiscRegs, 5697436Sdam.sunwoo@arm.com "MISCREG: Translated addr 0x%08x: PAR: 0x%08x\n", 5707436Sdam.sunwoo@arm.com val, miscRegs[MISCREG_PAR]); 5717436Sdam.sunwoo@arm.com } 5727436Sdam.sunwoo@arm.com else { 5737436Sdam.sunwoo@arm.com // Set fault bit and FSR 5747436Sdam.sunwoo@arm.com FSR fsr = miscRegs[MISCREG_DFSR]; 5757436Sdam.sunwoo@arm.com miscRegs[MISCREG_PAR] = 5767436Sdam.sunwoo@arm.com (fsr.ext << 6) | 5777436Sdam.sunwoo@arm.com (fsr.fsHigh << 5) | 5787436Sdam.sunwoo@arm.com (fsr.fsLow << 1) | 5797436Sdam.sunwoo@arm.com 0x1; // F bit 5807436Sdam.sunwoo@arm.com } 5817436Sdam.sunwoo@arm.com return; 5827436Sdam.sunwoo@arm.com } 5837749SAli.Saidi@ARM.com case MISCREG_CONTEXTIDR: 5847749SAli.Saidi@ARM.com case MISCREG_PRRR: 5857749SAli.Saidi@ARM.com case MISCREG_NMRR: 5867749SAli.Saidi@ARM.com case MISCREG_DACR: 5877749SAli.Saidi@ARM.com tc->getITBPtr()->invalidateMiscReg(); 5887749SAli.Saidi@ARM.com tc->getDTBPtr()->invalidateMiscReg(); 5897749SAli.Saidi@ARM.com break; 5908208SAli.Saidi@ARM.com case MISCREG_CPSR_MODE: 5918208SAli.Saidi@ARM.com // This miscreg is used by copy*Regs to set the CPSR mode 5928208SAli.Saidi@ARM.com // without updating other CPSR variables. It's used to 5938208SAli.Saidi@ARM.com // make sure the register map is in such a state that we can 5948208SAli.Saidi@ARM.com // see all of the registers for the copy. 5958208SAli.Saidi@ARM.com updateRegMap(val); 5968208SAli.Saidi@ARM.com return; 5978549Sdaniel.johnson@arm.com case MISCREG_L2CTLR: 5988549Sdaniel.johnson@arm.com warn("miscreg L2CTLR (%s) written with %#x. ignored...\n", 5998549Sdaniel.johnson@arm.com miscRegName[misc_reg], uint32_t(val)); 6007405SAli.Saidi@ARM.com } 6017405SAli.Saidi@ARM.com } 6027405SAli.Saidi@ARM.com setMiscRegNoEffect(misc_reg, newVal); 6037405SAli.Saidi@ARM.com} 6047405SAli.Saidi@ARM.com 6057405SAli.Saidi@ARM.com} 606