isa.hh revision 10035
16019Shines@cs.fsu.edu/* 213882Sgiacomo.travaglini@arm.com * Copyright (c) 2009 The Regents of The University of Michigan 37399SAli.Saidi@ARM.com * All rights reserved. 47399SAli.Saidi@ARM.com * 57399SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without 67399SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are 77399SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright 87399SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer; 97399SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright 107399SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the 117399SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution; 127399SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its 137399SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from 146019Shines@cs.fsu.edu * this software without specific prior written permission. 156019Shines@cs.fsu.edu * 166019Shines@cs.fsu.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176019Shines@cs.fsu.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186019Shines@cs.fsu.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196019Shines@cs.fsu.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206019Shines@cs.fsu.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216019Shines@cs.fsu.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226019Shines@cs.fsu.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236019Shines@cs.fsu.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246019Shines@cs.fsu.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256019Shines@cs.fsu.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266019Shines@cs.fsu.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276019Shines@cs.fsu.edu * 286019Shines@cs.fsu.edu * Authors: Gabe Black 296019Shines@cs.fsu.edu */ 306019Shines@cs.fsu.edu 316019Shines@cs.fsu.edu#ifndef __ARCH_MIPS_ISA_HH__ 326019Shines@cs.fsu.edu#define __ARCH_MIPS_ISA_HH__ 336019Shines@cs.fsu.edu 346019Shines@cs.fsu.edu#include <queue> 356019Shines@cs.fsu.edu#include <string> 366019Shines@cs.fsu.edu#include <vector> 376019Shines@cs.fsu.edu 386019Shines@cs.fsu.edu#include "arch/mips/registers.hh" 396019Shines@cs.fsu.edu#include "arch/mips/types.hh" 407399SAli.Saidi@ARM.com#include "sim/eventq.hh" 416019Shines@cs.fsu.edu#include "sim/fault_fwd.hh" 426019Shines@cs.fsu.edu#include "sim/sim_object.hh" 436019Shines@cs.fsu.edu 446019Shines@cs.fsu.educlass BaseCPU; 456019Shines@cs.fsu.educlass Checkpoint; 466019Shines@cs.fsu.educlass EventManager; 476019Shines@cs.fsu.edustruct MipsISAParams; 488229Snate@binkert.orgclass ThreadContext; 496019Shines@cs.fsu.edu 506019Shines@cs.fsu.edunamespace MipsISA 5110687SAndreas.Sandberg@ARM.com{ 526019Shines@cs.fsu.edu class ISA : public SimObject 536019Shines@cs.fsu.edu { 546116Snate@binkert.org public: 5510463SAndreas.Sandberg@ARM.com // The MIPS name for this file is CP0 or Coprocessor 0 566019Shines@cs.fsu.edu typedef ISA CP0; 576019Shines@cs.fsu.edu 586019Shines@cs.fsu.edu typedef MipsISAParams Params; 596019Shines@cs.fsu.edu 606019Shines@cs.fsu.edu protected: 617404SAli.Saidi@ARM.com // Number of threads and vpes an individual ISA state can handle 6210037SARM gem5 Developers uint8_t numThreads; 6310037SARM gem5 Developers uint8_t numVpes; 6411395Sandreas.sandberg@arm.com 6511395Sandreas.sandberg@arm.com enum BankType { 6611395Sandreas.sandberg@arm.com perProcessor, 6711395Sandreas.sandberg@arm.com perThreadContext, 6811395Sandreas.sandberg@arm.com perVirtProcessor 6911395Sandreas.sandberg@arm.com }; 7011395Sandreas.sandberg@arm.com 7111395Sandreas.sandberg@arm.com std::vector<std::vector<MiscReg> > miscRegFile; 7211395Sandreas.sandberg@arm.com std::vector<std::vector<MiscReg> > miscRegFile_WriteMask; 7311395Sandreas.sandberg@arm.com std::vector<BankType> bankType; 7411395Sandreas.sandberg@arm.com 7511395Sandreas.sandberg@arm.com public: 7611395Sandreas.sandberg@arm.com void clear(); 7711395Sandreas.sandberg@arm.com 7811395Sandreas.sandberg@arm.com void configCP(); 7911395Sandreas.sandberg@arm.com 8012749Sgiacomo.travaglini@arm.com unsigned getVPENum(ThreadID tid); 8111395Sandreas.sandberg@arm.com 8211395Sandreas.sandberg@arm.com ////////////////////////////////////////////////////////// 8311395Sandreas.sandberg@arm.com // 8411395Sandreas.sandberg@arm.com // READ/WRITE CP0 STATE 8511395Sandreas.sandberg@arm.com // 8611395Sandreas.sandberg@arm.com // 8711395Sandreas.sandberg@arm.com ////////////////////////////////////////////////////////// 8811395Sandreas.sandberg@arm.com //@TODO: MIPS MT's register view automatically connects 8911395Sandreas.sandberg@arm.com // Status to TCStatus depending on current thread 9011395Sandreas.sandberg@arm.com void updateCP0ReadView(int misc_reg, ThreadID tid) { } 9111395Sandreas.sandberg@arm.com MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0); 9211395Sandreas.sandberg@arm.com 9311395Sandreas.sandberg@arm.com //template <class TC> 9411395Sandreas.sandberg@arm.com MiscReg readMiscReg(int misc_reg, 9511395Sandreas.sandberg@arm.com ThreadContext *tc, ThreadID tid = 0); 9611395Sandreas.sandberg@arm.com 9711395Sandreas.sandberg@arm.com MiscReg filterCP0Write(int misc_reg, int reg_sel, const MiscReg &val); 9811395Sandreas.sandberg@arm.com void setRegMask(int misc_reg, const MiscReg &val, ThreadID tid = 0); 9911395Sandreas.sandberg@arm.com void setMiscRegNoEffect(int misc_reg, const MiscReg &val, 10011395Sandreas.sandberg@arm.com ThreadID tid = 0); 1017404SAli.Saidi@ARM.com 1026019Shines@cs.fsu.edu //template <class TC> 1036019Shines@cs.fsu.edu void setMiscReg(int misc_reg, const MiscReg &val, 1047294Sgblack@eecs.umich.edu ThreadContext *tc, ThreadID tid = 0); 1057294Sgblack@eecs.umich.edu 10610037SARM gem5 Developers ////////////////////////////////////////////////////////// 1077294Sgblack@eecs.umich.edu // 1087294Sgblack@eecs.umich.edu // DECLARE INTERFACE THAT WILL ALLOW A MiscRegFile (Cop0) 1097294Sgblack@eecs.umich.edu // TO SCHEDULE EVENTS 11010037SARM gem5 Developers // 11110037SARM gem5 Developers ////////////////////////////////////////////////////////// 11210037SARM gem5 Developers 11310037SARM gem5 Developers // Flag that is set when CP0 state has been written to. 1147294Sgblack@eecs.umich.edu bool cp0Updated; 11510037SARM gem5 Developers 1167404SAli.Saidi@ARM.com // Enumerated List of CP0 Event Types 11710037SARM gem5 Developers enum CP0EventType { 1187294Sgblack@eecs.umich.edu UpdateCP0 1197294Sgblack@eecs.umich.edu }; 1207294Sgblack@eecs.umich.edu 12110037SARM gem5 Developers // Declare A CP0Event Class for scheduling 12210037SARM gem5 Developers class CP0Event : public Event 12310037SARM gem5 Developers { 12410037SARM gem5 Developers protected: 12510037SARM gem5 Developers ISA::CP0 *cp0; 12610037SARM gem5 Developers BaseCPU *cpu; 12710037SARM gem5 Developers CP0EventType cp0EventType; 12810037SARM gem5 Developers Fault fault; 12910037SARM gem5 Developers 13011577SDylan.Johnson@ARM.com public: 13111577SDylan.Johnson@ARM.com /** Constructs a CP0 event. */ 13211577SDylan.Johnson@ARM.com CP0Event(CP0 *_cp0, BaseCPU *_cpu, CP0EventType e_type); 13311577SDylan.Johnson@ARM.com 13411577SDylan.Johnson@ARM.com /** Process this event. */ 13511577SDylan.Johnson@ARM.com virtual void process(); 13611577SDylan.Johnson@ARM.com 13711577SDylan.Johnson@ARM.com /** Returns the description of this event. */ 13811577SDylan.Johnson@ARM.com const char *description() const; 13911577SDylan.Johnson@ARM.com 14011577SDylan.Johnson@ARM.com /** Schedule This Event */ 1417294Sgblack@eecs.umich.edu void scheduleEvent(Cycles delay); 14212735Sandreas.sandberg@arm.com 14312735Sandreas.sandberg@arm.com /** Unschedule This Event */ 14412735Sandreas.sandberg@arm.com void unscheduleEvent(); 14512735Sandreas.sandberg@arm.com }; 14612735Sandreas.sandberg@arm.com 14712735Sandreas.sandberg@arm.com // Schedule a CP0 Update Event 14812735Sandreas.sandberg@arm.com void scheduleCP0Update(BaseCPU *cpu, Cycles delay = Cycles(0)); 14912735Sandreas.sandberg@arm.com 1506019Shines@cs.fsu.edu // If any changes have been made, then check the state for changes 15110037SARM gem5 Developers // and if necessary alert the CPU 15210037SARM gem5 Developers void updateCPU(BaseCPU *cpu); 15310037SARM gem5 Developers 15410037SARM gem5 Developers // Keep a List of CPU Events that need to be deallocated 15513374Sanouk.vanlaer@arm.com std::queue<CP0Event*> cp0EventRemoveList; 15613374Sanouk.vanlaer@arm.com 15713374Sanouk.vanlaer@arm.com static std::string miscRegNames[NumMiscRegs]; 15813374Sanouk.vanlaer@arm.com 15910037SARM gem5 Developers public: 16010037SARM gem5 Developers void startup(ThreadContext *tc) {} 16110037SARM gem5 Developers 1627436Sdam.sunwoo@arm.com /// Explicitly import the otherwise hidden startup 1637404SAli.Saidi@ARM.com using SimObject::startup; 16410037SARM gem5 Developers 16510037SARM gem5 Developers const Params *params() const; 1666019Shines@cs.fsu.edu 16711395Sandreas.sandberg@arm.com ISA(Params *p); 16811395Sandreas.sandberg@arm.com 1697399SAli.Saidi@ARM.com int 1707734SAli.Saidi@ARM.com flattenIntIndex(int reg) const 1717734SAli.Saidi@ARM.com { 1727734SAli.Saidi@ARM.com return reg; 1737734SAli.Saidi@ARM.com } 1747734SAli.Saidi@ARM.com 1757734SAli.Saidi@ARM.com int 1767734SAli.Saidi@ARM.com flattenFloatIndex(int reg) const 1777734SAli.Saidi@ARM.com { 1787734SAli.Saidi@ARM.com return reg; 1797734SAli.Saidi@ARM.com } 1807734SAli.Saidi@ARM.com 1817734SAli.Saidi@ARM.com // dummy 1827734SAli.Saidi@ARM.com int 1837734SAli.Saidi@ARM.com flattenCCIndex(int reg) const 1847734SAli.Saidi@ARM.com { 1857734SAli.Saidi@ARM.com return reg; 1867734SAli.Saidi@ARM.com } 1877734SAli.Saidi@ARM.com 1887734SAli.Saidi@ARM.com int 1897734SAli.Saidi@ARM.com flattenMiscIndex(int reg) const 1906019Shines@cs.fsu.edu { 1916019Shines@cs.fsu.edu return reg; 1926019Shines@cs.fsu.edu } 1936019Shines@cs.fsu.edu 19410463SAndreas.Sandberg@ARM.com }; 19510463SAndreas.Sandberg@ARM.com} 19610463SAndreas.Sandberg@ARM.com 1977697SAli.Saidi@ARM.com#endif 1987404SAli.Saidi@ARM.com