isa.hh revision 6719
16313Sgblack@eecs.umich.edu/* 26313Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan 36313Sgblack@eecs.umich.edu * All rights reserved. 46313Sgblack@eecs.umich.edu * 56313Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 66313Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 76313Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 86313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 96313Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 106313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 116313Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 126313Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 136313Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 146313Sgblack@eecs.umich.edu * this software without specific prior written permission. 156313Sgblack@eecs.umich.edu * 166313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276313Sgblack@eecs.umich.edu * 286313Sgblack@eecs.umich.edu * Authors: Gabe Black 296313Sgblack@eecs.umich.edu */ 306313Sgblack@eecs.umich.edu 316313Sgblack@eecs.umich.edu#ifndef __ARCH_ARM_ISA_HH__ 326313Sgblack@eecs.umich.edu#define __ARCH_MRM_ISA_HH__ 336313Sgblack@eecs.umich.edu 346333Sgblack@eecs.umich.edu#include "arch/arm/registers.hh" 356313Sgblack@eecs.umich.edu#include "arch/arm/types.hh" 366313Sgblack@eecs.umich.edu 376333Sgblack@eecs.umich.educlass ThreadContext; 386313Sgblack@eecs.umich.educlass Checkpoint; 396313Sgblack@eecs.umich.educlass EventManager; 406313Sgblack@eecs.umich.edu 416313Sgblack@eecs.umich.edunamespace ArmISA 426313Sgblack@eecs.umich.edu{ 436313Sgblack@eecs.umich.edu class ISA 446313Sgblack@eecs.umich.edu { 456313Sgblack@eecs.umich.edu protected: 466333Sgblack@eecs.umich.edu MiscReg miscRegs[NumMiscRegs]; 476718Sgblack@eecs.umich.edu const IntRegIndex *intRegMap; 486718Sgblack@eecs.umich.edu 496718Sgblack@eecs.umich.edu void 506718Sgblack@eecs.umich.edu updateRegMap(CPSR cpsr) 516718Sgblack@eecs.umich.edu { 526718Sgblack@eecs.umich.edu switch (cpsr.mode) { 536718Sgblack@eecs.umich.edu case MODE_USER: 546718Sgblack@eecs.umich.edu case MODE_SYSTEM: 556718Sgblack@eecs.umich.edu intRegMap = IntRegUsrMap; 566718Sgblack@eecs.umich.edu break; 576718Sgblack@eecs.umich.edu case MODE_FIQ: 586718Sgblack@eecs.umich.edu intRegMap = IntRegFiqMap; 596718Sgblack@eecs.umich.edu break; 606718Sgblack@eecs.umich.edu case MODE_IRQ: 616718Sgblack@eecs.umich.edu intRegMap = IntRegIrqMap; 626718Sgblack@eecs.umich.edu break; 636718Sgblack@eecs.umich.edu case MODE_SVC: 646718Sgblack@eecs.umich.edu intRegMap = IntRegSvcMap; 656718Sgblack@eecs.umich.edu break; 666718Sgblack@eecs.umich.edu case MODE_ABORT: 676718Sgblack@eecs.umich.edu intRegMap = IntRegAbtMap; 686718Sgblack@eecs.umich.edu break; 696718Sgblack@eecs.umich.edu case MODE_UNDEFINED: 706718Sgblack@eecs.umich.edu intRegMap = IntRegUndMap; 716718Sgblack@eecs.umich.edu break; 726718Sgblack@eecs.umich.edu default: 736718Sgblack@eecs.umich.edu panic("Unrecognized mode setting in CPSR.\n"); 746718Sgblack@eecs.umich.edu } 756718Sgblack@eecs.umich.edu } 766313Sgblack@eecs.umich.edu 776313Sgblack@eecs.umich.edu public: 786333Sgblack@eecs.umich.edu void clear() 796333Sgblack@eecs.umich.edu { 806401Sgblack@eecs.umich.edu memset(miscRegs, 0, sizeof(miscRegs)); 816401Sgblack@eecs.umich.edu CPSR cpsr = 0; 826719Sgblack@eecs.umich.edu cpsr.mode = MODE_USER; 836401Sgblack@eecs.umich.edu miscRegs[MISCREG_CPSR] = cpsr; 846718Sgblack@eecs.umich.edu updateRegMap(cpsr); 856401Sgblack@eecs.umich.edu //XXX We need to initialize the rest of the state. 866333Sgblack@eecs.umich.edu } 876313Sgblack@eecs.umich.edu 886333Sgblack@eecs.umich.edu MiscReg 896333Sgblack@eecs.umich.edu readMiscRegNoEffect(int misc_reg) 906333Sgblack@eecs.umich.edu { 916333Sgblack@eecs.umich.edu assert(misc_reg < NumMiscRegs); 926333Sgblack@eecs.umich.edu return miscRegs[misc_reg]; 936333Sgblack@eecs.umich.edu } 946313Sgblack@eecs.umich.edu 956333Sgblack@eecs.umich.edu MiscReg 966333Sgblack@eecs.umich.edu readMiscReg(int misc_reg, ThreadContext *tc) 976333Sgblack@eecs.umich.edu { 986333Sgblack@eecs.umich.edu assert(misc_reg < NumMiscRegs); 996333Sgblack@eecs.umich.edu return miscRegs[misc_reg]; 1006333Sgblack@eecs.umich.edu } 1016333Sgblack@eecs.umich.edu 1026333Sgblack@eecs.umich.edu void 1036333Sgblack@eecs.umich.edu setMiscRegNoEffect(int misc_reg, const MiscReg &val) 1046333Sgblack@eecs.umich.edu { 1056333Sgblack@eecs.umich.edu assert(misc_reg < NumMiscRegs); 1066333Sgblack@eecs.umich.edu miscRegs[misc_reg] = val; 1076333Sgblack@eecs.umich.edu } 1086333Sgblack@eecs.umich.edu 1096333Sgblack@eecs.umich.edu void 1106333Sgblack@eecs.umich.edu setMiscReg(int misc_reg, const MiscReg &val, ThreadContext *tc) 1116333Sgblack@eecs.umich.edu { 1126718Sgblack@eecs.umich.edu if (misc_reg == MISCREG_CPSR) { 1136718Sgblack@eecs.umich.edu updateRegMap(val); 1146718Sgblack@eecs.umich.edu } 1156333Sgblack@eecs.umich.edu assert(misc_reg < NumMiscRegs); 1166333Sgblack@eecs.umich.edu miscRegs[misc_reg] = val; 1176333Sgblack@eecs.umich.edu } 1186313Sgblack@eecs.umich.edu 1196313Sgblack@eecs.umich.edu int 1206313Sgblack@eecs.umich.edu flattenIntIndex(int reg) 1216313Sgblack@eecs.umich.edu { 1226718Sgblack@eecs.umich.edu assert(reg >= 0); 1236718Sgblack@eecs.umich.edu if (reg < NUM_ARCH_INTREGS) { 1246718Sgblack@eecs.umich.edu return intRegMap[reg]; 1256718Sgblack@eecs.umich.edu } else { 1266718Sgblack@eecs.umich.edu assert(reg < NUM_INTREGS); 1276718Sgblack@eecs.umich.edu return reg; 1286718Sgblack@eecs.umich.edu } 1296313Sgblack@eecs.umich.edu } 1306313Sgblack@eecs.umich.edu 1316313Sgblack@eecs.umich.edu int 1326313Sgblack@eecs.umich.edu flattenFloatIndex(int reg) 1336313Sgblack@eecs.umich.edu { 1346313Sgblack@eecs.umich.edu return reg; 1356313Sgblack@eecs.umich.edu } 1366313Sgblack@eecs.umich.edu 1376678Sgblack@eecs.umich.edu void serialize(EventManager *em, std::ostream &os) 1386333Sgblack@eecs.umich.edu {} 1396678Sgblack@eecs.umich.edu void unserialize(EventManager *em, Checkpoint *cp, 1406678Sgblack@eecs.umich.edu const std::string §ion) 1416333Sgblack@eecs.umich.edu {} 1426313Sgblack@eecs.umich.edu 1436313Sgblack@eecs.umich.edu ISA() 1446313Sgblack@eecs.umich.edu { 1456313Sgblack@eecs.umich.edu clear(); 1466313Sgblack@eecs.umich.edu } 1476313Sgblack@eecs.umich.edu }; 1486313Sgblack@eecs.umich.edu} 1496313Sgblack@eecs.umich.edu 1506313Sgblack@eecs.umich.edu#endif 151