isa.hh revision 7405
16313Sgblack@eecs.umich.edu/* 27093Sgblack@eecs.umich.edu * Copyright (c) 2010 ARM Limited 37093Sgblack@eecs.umich.edu * All rights reserved 47093Sgblack@eecs.umich.edu * 57093Sgblack@eecs.umich.edu * The license below extends only to copyright in the software and shall 67093Sgblack@eecs.umich.edu * not be construed as granting a license to any other intellectual 77093Sgblack@eecs.umich.edu * property including but not limited to intellectual property relating 87093Sgblack@eecs.umich.edu * to a hardware implementation of the functionality of the software 97093Sgblack@eecs.umich.edu * licensed hereunder. You may use the software subject to the license 107093Sgblack@eecs.umich.edu * terms below provided that you ensure that this notice is replicated 117093Sgblack@eecs.umich.edu * unmodified and in its entirety in all distributions of the software, 127093Sgblack@eecs.umich.edu * modified or unmodified, in source code or in binary form. 137093Sgblack@eecs.umich.edu * 146313Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan 156313Sgblack@eecs.umich.edu * All rights reserved. 166313Sgblack@eecs.umich.edu * 176313Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 186313Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 196313Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 206313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 216313Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 226313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 236313Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 246313Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 256313Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 266313Sgblack@eecs.umich.edu * this software without specific prior written permission. 276313Sgblack@eecs.umich.edu * 286313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 296313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 306313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 316313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 326313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 336313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 346313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 356313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 366313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 376313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 386313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 396313Sgblack@eecs.umich.edu * 406313Sgblack@eecs.umich.edu * Authors: Gabe Black 416313Sgblack@eecs.umich.edu */ 426313Sgblack@eecs.umich.edu 436313Sgblack@eecs.umich.edu#ifndef __ARCH_ARM_ISA_HH__ 447404SAli.Saidi@ARM.com#define __ARCH_ARM_ISA_HH__ 456313Sgblack@eecs.umich.edu 466333Sgblack@eecs.umich.edu#include "arch/arm/registers.hh" 477404SAli.Saidi@ARM.com#include "arch/arm/tlb.hh" 486313Sgblack@eecs.umich.edu#include "arch/arm/types.hh" 496313Sgblack@eecs.umich.edu 506333Sgblack@eecs.umich.educlass ThreadContext; 516313Sgblack@eecs.umich.educlass Checkpoint; 526313Sgblack@eecs.umich.educlass EventManager; 536313Sgblack@eecs.umich.edu 546313Sgblack@eecs.umich.edunamespace ArmISA 556313Sgblack@eecs.umich.edu{ 566313Sgblack@eecs.umich.edu class ISA 576313Sgblack@eecs.umich.edu { 586313Sgblack@eecs.umich.edu protected: 596333Sgblack@eecs.umich.edu MiscReg miscRegs[NumMiscRegs]; 606718Sgblack@eecs.umich.edu const IntRegIndex *intRegMap; 616718Sgblack@eecs.umich.edu 626718Sgblack@eecs.umich.edu void 636718Sgblack@eecs.umich.edu updateRegMap(CPSR cpsr) 646718Sgblack@eecs.umich.edu { 656718Sgblack@eecs.umich.edu switch (cpsr.mode) { 666718Sgblack@eecs.umich.edu case MODE_USER: 676718Sgblack@eecs.umich.edu case MODE_SYSTEM: 686718Sgblack@eecs.umich.edu intRegMap = IntRegUsrMap; 696718Sgblack@eecs.umich.edu break; 706718Sgblack@eecs.umich.edu case MODE_FIQ: 716718Sgblack@eecs.umich.edu intRegMap = IntRegFiqMap; 726718Sgblack@eecs.umich.edu break; 736718Sgblack@eecs.umich.edu case MODE_IRQ: 746718Sgblack@eecs.umich.edu intRegMap = IntRegIrqMap; 756718Sgblack@eecs.umich.edu break; 766718Sgblack@eecs.umich.edu case MODE_SVC: 776718Sgblack@eecs.umich.edu intRegMap = IntRegSvcMap; 786718Sgblack@eecs.umich.edu break; 796723Sgblack@eecs.umich.edu case MODE_MON: 806723Sgblack@eecs.umich.edu intRegMap = IntRegMonMap; 816723Sgblack@eecs.umich.edu break; 826718Sgblack@eecs.umich.edu case MODE_ABORT: 836718Sgblack@eecs.umich.edu intRegMap = IntRegAbtMap; 846718Sgblack@eecs.umich.edu break; 856718Sgblack@eecs.umich.edu case MODE_UNDEFINED: 866718Sgblack@eecs.umich.edu intRegMap = IntRegUndMap; 876718Sgblack@eecs.umich.edu break; 886718Sgblack@eecs.umich.edu default: 896718Sgblack@eecs.umich.edu panic("Unrecognized mode setting in CPSR.\n"); 906718Sgblack@eecs.umich.edu } 916718Sgblack@eecs.umich.edu } 926313Sgblack@eecs.umich.edu 936313Sgblack@eecs.umich.edu public: 946333Sgblack@eecs.umich.edu void clear() 956333Sgblack@eecs.umich.edu { 967400SAli.Saidi@ARM.com SCTLR sctlr_rst = miscRegs[MISCREG_SCTLR_RST]; 977400SAli.Saidi@ARM.com 986401Sgblack@eecs.umich.edu memset(miscRegs, 0, sizeof(miscRegs)); 996401Sgblack@eecs.umich.edu CPSR cpsr = 0; 1006719Sgblack@eecs.umich.edu cpsr.mode = MODE_USER; 1016401Sgblack@eecs.umich.edu miscRegs[MISCREG_CPSR] = cpsr; 1026718Sgblack@eecs.umich.edu updateRegMap(cpsr); 1036735Sgblack@eecs.umich.edu 1046735Sgblack@eecs.umich.edu SCTLR sctlr = 0; 1057400SAli.Saidi@ARM.com sctlr.nmfi = (bool)sctlr_rst.nmfi; 1067400SAli.Saidi@ARM.com sctlr.v = (bool)sctlr_rst.v; 1077400SAli.Saidi@ARM.com sctlr.u = 1; 1086735Sgblack@eecs.umich.edu sctlr.rao1 = 1; 1096735Sgblack@eecs.umich.edu sctlr.rao2 = 1; 1106735Sgblack@eecs.umich.edu sctlr.rao3 = 1; 1116735Sgblack@eecs.umich.edu sctlr.rao4 = 1; 1127270Sgblack@eecs.umich.edu miscRegs[MISCREG_SCTLR] = sctlr; 1137400SAli.Saidi@ARM.com miscRegs[MISCREG_SCTLR_RST] = sctlr_rst; 1147400SAli.Saidi@ARM.com 1156735Sgblack@eecs.umich.edu 1167271Sgblack@eecs.umich.edu /* 1177271Sgblack@eecs.umich.edu * Technically this should be 0, but we don't support those 1187271Sgblack@eecs.umich.edu * settings. 1197271Sgblack@eecs.umich.edu */ 1207320Sgblack@eecs.umich.edu CPACR cpacr = 0; 1217320Sgblack@eecs.umich.edu // Enable CP 10, 11 1227320Sgblack@eecs.umich.edu cpacr.cp10 = 0x3; 1237320Sgblack@eecs.umich.edu cpacr.cp11 = 0x3; 1247320Sgblack@eecs.umich.edu miscRegs[MISCREG_CPACR] = cpacr; 1257271Sgblack@eecs.umich.edu 1267350SAli.Saidi@ARM.com /* Start with an event in the mailbox */ 1277350SAli.Saidi@ARM.com miscRegs[MISCREG_SEV_MAILBOX] = 1; 1287350SAli.Saidi@ARM.com 1297298Sgblack@eecs.umich.edu /* 1307298Sgblack@eecs.umich.edu * Implemented = '5' from "M5", 1317298Sgblack@eecs.umich.edu * Variant = 0, 1327298Sgblack@eecs.umich.edu */ 1337298Sgblack@eecs.umich.edu miscRegs[MISCREG_MIDR] = 1347298Sgblack@eecs.umich.edu (0x35 << 24) | //Implementor is '5' from "M5" 1357298Sgblack@eecs.umich.edu (0 << 20) | //Variant 1367298Sgblack@eecs.umich.edu (0xf << 16) | //Architecture from CPUID scheme 1377298Sgblack@eecs.umich.edu (0 << 4) | //Primary part number 1387298Sgblack@eecs.umich.edu (0 << 0) | //Revision 1397298Sgblack@eecs.umich.edu 0; 1407298Sgblack@eecs.umich.edu 1417354Sgblack@eecs.umich.edu // Separate Instruction and Data TLBs. 1427354Sgblack@eecs.umich.edu miscRegs[MISCREG_TLBTR] = 1; 1437354Sgblack@eecs.umich.edu 1447383Sgblack@eecs.umich.edu MVFR0 mvfr0 = 0; 1457383Sgblack@eecs.umich.edu mvfr0.advSimdRegisters = 2; 1467383Sgblack@eecs.umich.edu mvfr0.singlePrecision = 2; 1477383Sgblack@eecs.umich.edu mvfr0.doublePrecision = 2; 1487383Sgblack@eecs.umich.edu mvfr0.vfpExceptionTrapping = 0; 1497383Sgblack@eecs.umich.edu mvfr0.divide = 1; 1507383Sgblack@eecs.umich.edu mvfr0.squareRoot = 1; 1517383Sgblack@eecs.umich.edu mvfr0.shortVectors = 1; 1527383Sgblack@eecs.umich.edu mvfr0.roundingModes = 1; 1537383Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR0] = mvfr0; 1547383Sgblack@eecs.umich.edu 1557383Sgblack@eecs.umich.edu MVFR1 mvfr1 = 0; 1567383Sgblack@eecs.umich.edu mvfr1.flushToZero = 1; 1577383Sgblack@eecs.umich.edu mvfr1.defaultNaN = 1; 1587383Sgblack@eecs.umich.edu mvfr1.advSimdLoadStore = 1; 1597383Sgblack@eecs.umich.edu mvfr1.advSimdInteger = 1; 1607383Sgblack@eecs.umich.edu mvfr1.advSimdSinglePrecision = 1; 1617383Sgblack@eecs.umich.edu mvfr1.advSimdHalfPrecision = 1; 1627383Sgblack@eecs.umich.edu mvfr1.vfpHalfPrecision = 1; 1637383Sgblack@eecs.umich.edu miscRegs[MISCREG_MVFR1] = mvfr1; 1647383Sgblack@eecs.umich.edu 1657390Sgblack@eecs.umich.edu miscRegs[MISCREG_MPIDR] = 0; 1667390Sgblack@eecs.umich.edu 1676401Sgblack@eecs.umich.edu //XXX We need to initialize the rest of the state. 1686333Sgblack@eecs.umich.edu } 1696313Sgblack@eecs.umich.edu 1707405SAli.Saidi@ARM.com MiscReg readMiscRegNoEffect(int misc_reg); 1716313Sgblack@eecs.umich.edu 1727405SAli.Saidi@ARM.com MiscReg readMiscReg(int misc_reg, ThreadContext *tc); 1736333Sgblack@eecs.umich.edu 1747405SAli.Saidi@ARM.com void setMiscRegNoEffect(int misc_reg, const MiscReg &val); 1756333Sgblack@eecs.umich.edu 1767405SAli.Saidi@ARM.com void setMiscReg(int misc_reg, const MiscReg &val, ThreadContext *tc); 1776313Sgblack@eecs.umich.edu 1786313Sgblack@eecs.umich.edu int 1796313Sgblack@eecs.umich.edu flattenIntIndex(int reg) 1806313Sgblack@eecs.umich.edu { 1816718Sgblack@eecs.umich.edu assert(reg >= 0); 1826718Sgblack@eecs.umich.edu if (reg < NUM_ARCH_INTREGS) { 1836718Sgblack@eecs.umich.edu return intRegMap[reg]; 1846726Sgblack@eecs.umich.edu } else if (reg < NUM_INTREGS) { 1856726Sgblack@eecs.umich.edu return reg; 1866718Sgblack@eecs.umich.edu } else { 1877310Sgblack@eecs.umich.edu int mode = reg / intRegsPerMode; 1887310Sgblack@eecs.umich.edu reg = reg % intRegsPerMode; 1897310Sgblack@eecs.umich.edu switch (mode) { 1907310Sgblack@eecs.umich.edu case MODE_USER: 1917310Sgblack@eecs.umich.edu case MODE_SYSTEM: 1927310Sgblack@eecs.umich.edu return INTREG_USR(reg); 1937310Sgblack@eecs.umich.edu case MODE_FIQ: 1947310Sgblack@eecs.umich.edu return INTREG_FIQ(reg); 1957310Sgblack@eecs.umich.edu case MODE_IRQ: 1967310Sgblack@eecs.umich.edu return INTREG_IRQ(reg); 1977310Sgblack@eecs.umich.edu case MODE_SVC: 1987310Sgblack@eecs.umich.edu return INTREG_SVC(reg); 1997310Sgblack@eecs.umich.edu case MODE_MON: 2007310Sgblack@eecs.umich.edu return INTREG_MON(reg); 2017310Sgblack@eecs.umich.edu case MODE_ABORT: 2027310Sgblack@eecs.umich.edu return INTREG_ABT(reg); 2037310Sgblack@eecs.umich.edu case MODE_UNDEFINED: 2047310Sgblack@eecs.umich.edu return INTREG_UND(reg); 2057310Sgblack@eecs.umich.edu default: 2067310Sgblack@eecs.umich.edu panic("Flattening into an unknown mode.\n"); 2077310Sgblack@eecs.umich.edu } 2086718Sgblack@eecs.umich.edu } 2096313Sgblack@eecs.umich.edu } 2106313Sgblack@eecs.umich.edu 2116313Sgblack@eecs.umich.edu int 2126313Sgblack@eecs.umich.edu flattenFloatIndex(int reg) 2136313Sgblack@eecs.umich.edu { 2146313Sgblack@eecs.umich.edu return reg; 2156313Sgblack@eecs.umich.edu } 2166313Sgblack@eecs.umich.edu 2176678Sgblack@eecs.umich.edu void serialize(EventManager *em, std::ostream &os) 2186333Sgblack@eecs.umich.edu {} 2196678Sgblack@eecs.umich.edu void unserialize(EventManager *em, Checkpoint *cp, 2206678Sgblack@eecs.umich.edu const std::string §ion) 2216333Sgblack@eecs.umich.edu {} 2226313Sgblack@eecs.umich.edu 2236313Sgblack@eecs.umich.edu ISA() 2246313Sgblack@eecs.umich.edu { 2257400SAli.Saidi@ARM.com SCTLR sctlr; 2267400SAli.Saidi@ARM.com sctlr = 0; 2277400SAli.Saidi@ARM.com miscRegs[MISCREG_SCTLR_RST] = sctlr; 2287400SAli.Saidi@ARM.com 2296313Sgblack@eecs.umich.edu clear(); 2306313Sgblack@eecs.umich.edu } 2316313Sgblack@eecs.umich.edu }; 2326313Sgblack@eecs.umich.edu} 2336313Sgblack@eecs.umich.edu 2346313Sgblack@eecs.umich.edu#endif 235