isa.hh revision 10698
1451SN/A/* 22212SN/A * Copyright (c) 2009 The Regents of The University of Michigan 3451SN/A * All rights reserved. 4451SN/A * 5451SN/A * Redistribution and use in source and binary forms, with or without 6451SN/A * modification, are permitted provided that the following conditions are 7451SN/A * met: redistributions of source code must retain the above copyright 8451SN/A * notice, this list of conditions and the following disclaimer; 9451SN/A * redistributions in binary form must reproduce the above copyright 10451SN/A * notice, this list of conditions and the following disclaimer in the 11451SN/A * documentation and/or other materials provided with the distribution; 12451SN/A * neither the name of the copyright holders nor the names of its 13451SN/A * contributors may be used to endorse or promote products derived from 14451SN/A * this software without specific prior written permission. 15451SN/A * 16451SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17451SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18451SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19451SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20451SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21451SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22451SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23451SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24451SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25451SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26451SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292665Ssaidi@eecs.umich.edu */ 302665Ssaidi@eecs.umich.edu 31451SN/A#ifndef __ARCH_MIPS_ISA_HH__ 32451SN/A#define __ARCH_MIPS_ISA_HH__ 332212SN/A 342212SN/A#include <queue> 35451SN/A#include <string> 36451SN/A#include <vector> 371070SN/A 381070SN/A#include "arch/mips/registers.hh" 391070SN/A#include "arch/mips/types.hh" 402212SN/A#include "sim/eventq.hh" 412212SN/A#include "sim/sim_object.hh" 422212SN/A 432212SN/Aclass BaseCPU; 442212SN/Aclass Checkpoint; 452212SN/Aclass EventManager; 46451SN/Astruct MipsISAParams; 47885SN/Aclass ThreadContext; 48885SN/A 49885SN/Anamespace MipsISA 50885SN/A{ 51885SN/A class ISA : public SimObject 522212SN/A { 53451SN/A public: 54451SN/A // The MIPS name for this file is CP0 or Coprocessor 0 551885SN/A typedef ISA CP0; 561885SN/A 571885SN/A typedef MipsISAParams Params; 581885SN/A 591885SN/A protected: 601885SN/A // Number of threads and vpes an individual ISA state can handle 611885SN/A uint8_t numThreads; 621885SN/A uint8_t numVpes; 631885SN/A 641885SN/A enum BankType { 651885SN/A perProcessor, 661885SN/A perThreadContext, 671885SN/A perVirtProcessor 681885SN/A }; 691885SN/A 701885SN/A std::vector<std::vector<MiscReg> > miscRegFile; 712212SN/A std::vector<std::vector<MiscReg> > miscRegFile_WriteMask; 721855SN/A std::vector<BankType> bankType; 731855SN/A 741855SN/A public: 751855SN/A void clear(); 761855SN/A 771855SN/A void configCP(); 781855SN/A 791855SN/A unsigned getVPENum(ThreadID tid) const; 801855SN/A 811855SN/A ////////////////////////////////////////////////////////// 821855SN/A // 831855SN/A // READ/WRITE CP0 STATE 841855SN/A // 851855SN/A // 861855SN/A ////////////////////////////////////////////////////////// 871855SN/A //@TODO: MIPS MT's register view automatically connects 881855SN/A // Status to TCStatus depending on current thread 891855SN/A void updateCP0ReadView(int misc_reg, ThreadID tid) { } 901855SN/A MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0) const; 911855SN/A 921492SN/A //template <class TC> 93887SN/A MiscReg readMiscReg(int misc_reg, 94451SN/A ThreadContext *tc, ThreadID tid = 0); 951492SN/A 961492SN/A MiscReg filterCP0Write(int misc_reg, int reg_sel, const MiscReg &val); 971492SN/A void setRegMask(int misc_reg, const MiscReg &val, ThreadID tid = 0); 981070SN/A void setMiscRegNoEffect(int misc_reg, const MiscReg &val, 99887SN/A ThreadID tid = 0); 1001070SN/A 1011070SN/A //template <class TC> 1021070SN/A void setMiscReg(int misc_reg, const MiscReg &val, 103887SN/A ThreadContext *tc, ThreadID tid = 0); 104885SN/A 105887SN/A ////////////////////////////////////////////////////////// 106887SN/A // 107885SN/A // DECLARE INTERFACE THAT WILL ALLOW A MiscRegFile (Cop0) 108887SN/A // TO SCHEDULE EVENTS 1091070SN/A // 1101070SN/A ////////////////////////////////////////////////////////// 1111070SN/A 1121070SN/A // Flag that is set when CP0 state has been written to. 1131039SN/A bool cp0Updated; 1141039SN/A 1151070SN/A // Enumerated List of CP0 Event Types 1161070SN/A enum CP0EventType { 117887SN/A UpdateCP0 118887SN/A }; 1191885SN/A 120841SN/A // Declare A CP0Event Class for scheduling 1211082SN/A class CP0Event : public Event 1221082SN/A { 1231082SN/A protected: 1241082SN/A ISA::CP0 *cp0; 1251067SN/A BaseCPU *cpu; 1261067SN/A CP0EventType cp0EventType; 1271082SN/A Fault fault; 1281082SN/A 1291082SN/A public: 1301082SN/A /** Constructs a CP0 event. */ 1311082SN/A CP0Event(CP0 *_cp0, BaseCPU *_cpu, CP0EventType e_type); 1321082SN/A 1331082SN/A /** Process this event. */ 1341082SN/A virtual void process(); 1351082SN/A 1361084SN/A /** Returns the description of this event. */ 1371084SN/A const char *description() const; 1381082SN/A 1391070SN/A /** Schedule This Event */ 1401070SN/A void scheduleEvent(Cycles delay); 141451SN/A 142451SN/A /** Unschedule This Event */ 1432212SN/A void unscheduleEvent(); 1442212SN/A }; 145451SN/A 146803SN/A // Schedule a CP0 Update Event 147451SN/A void scheduleCP0Update(BaseCPU *cpu, Cycles delay = Cycles(0)); 148451SN/A 1492212SN/A // If any changes have been made, then check the state for changes 150 // and if necessary alert the CPU 151 void updateCPU(BaseCPU *cpu); 152 153 // Keep a List of CPU Events that need to be deallocated 154 std::queue<CP0Event*> cp0EventRemoveList; 155 156 static std::string miscRegNames[NumMiscRegs]; 157 158 public: 159 void startup(ThreadContext *tc) {} 160 161 /// Explicitly import the otherwise hidden startup 162 using SimObject::startup; 163 164 const Params *params() const; 165 166 ISA(Params *p); 167 168 int 169 flattenIntIndex(int reg) const 170 { 171 return reg; 172 } 173 174 int 175 flattenFloatIndex(int reg) const 176 { 177 return reg; 178 } 179 180 // dummy 181 int 182 flattenCCIndex(int reg) const 183 { 184 return reg; 185 } 186 187 int 188 flattenMiscIndex(int reg) const 189 { 190 return reg; 191 } 192 193 }; 194} 195 196#endif 197