isa.hh revision 9180
1768SN/A/* 21762SN/A * Copyright (c) 2009 The Regents of The University of Michigan 3768SN/A * All rights reserved. 4768SN/A * 5768SN/A * Redistribution and use in source and binary forms, with or without 6768SN/A * modification, are permitted provided that the following conditions are 7768SN/A * met: redistributions of source code must retain the above copyright 8768SN/A * notice, this list of conditions and the following disclaimer; 9768SN/A * redistributions in binary form must reproduce the above copyright 10768SN/A * notice, this list of conditions and the following disclaimer in the 11768SN/A * documentation and/or other materials provided with the distribution; 12768SN/A * neither the name of the copyright holders nor the names of its 13768SN/A * contributors may be used to endorse or promote products derived from 14768SN/A * this software without specific prior written permission. 15768SN/A * 16768SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17768SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18768SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19768SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20768SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21768SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22768SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23768SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24768SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25768SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26768SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A * 282665SN/A * Authors: Gabe Black 292665SN/A */ 302665SN/A 31768SN/A#ifndef __ARCH_MIPS_ISA_HH__ 32768SN/A#define __ARCH_MIPS_ISA_HH__ 331722SN/A 341722SN/A#include <queue> 35768SN/A#include <string> 36768SN/A#include <vector> 371401SN/A 381401SN/A#include "arch/mips/registers.hh" 39768SN/A#include "arch/mips/types.hh" 40909SN/A#include "sim/eventq.hh" 413540Sgblack@eecs.umich.edu#include "sim/fault_fwd.hh" 424762Snate@binkert.org 434762Snate@binkert.orgclass BaseCPU; 44932SN/Aclass Checkpoint; 45768SN/Aclass EventManager; 461722SN/Aclass ThreadContext; 47885SN/A 48885SN/Anamespace MipsISA 49768SN/A{ 502542SN/A class ISA 51768SN/A { 52809SN/A public: 53773SN/A // The MIPS name for this file is CP0 or Coprocessor 0 54773SN/A typedef ISA CP0; 55768SN/A 561854SN/A protected: 571854SN/A // Number of threads and vpes an individual ISA state can handle 581854SN/A uint8_t numThreads; 591854SN/A uint8_t numVpes; 601854SN/A 611854SN/A enum BankType { 621854SN/A perProcessor, 631854SN/A perThreadContext, 641854SN/A perVirtProcessor 651854SN/A }; 66768SN/A 671854SN/A std::vector<std::vector<MiscReg> > miscRegFile; 681817SN/A std::vector<std::vector<MiscReg> > miscRegFile_WriteMask; 691854SN/A std::vector<BankType> bankType; 701854SN/A 711817SN/A public: 721854SN/A ISA(uint8_t num_threads = 1, uint8_t num_vpes = 1); 731854SN/A 741817SN/A void clear(); 751854SN/A 761854SN/A void configCP(); 771854SN/A 781817SN/A unsigned getVPENum(ThreadID tid); 791817SN/A 801854SN/A ////////////////////////////////////////////////////////// 811854SN/A // 821854SN/A // READ/WRITE CP0 STATE 831817SN/A // 841817SN/A // 851817SN/A ////////////////////////////////////////////////////////// 861817SN/A //@TODO: MIPS MT's register view automatically connects 871817SN/A // Status to TCStatus depending on current thread 881817SN/A void updateCP0ReadView(int misc_reg, ThreadID tid) { } 891817SN/A MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0); 901817SN/A 911817SN/A //template <class TC> 921817SN/A MiscReg readMiscReg(int misc_reg, 931817SN/A ThreadContext *tc, ThreadID tid = 0); 941817SN/A 951817SN/A MiscReg filterCP0Write(int misc_reg, int reg_sel, const MiscReg &val); 961817SN/A void setRegMask(int misc_reg, const MiscReg &val, ThreadID tid = 0); 971817SN/A void setMiscRegNoEffect(int misc_reg, const MiscReg &val, 981817SN/A ThreadID tid = 0); 991817SN/A 1001817SN/A //template <class TC> 1011817SN/A void setMiscReg(int misc_reg, const MiscReg &val, 1021817SN/A ThreadContext *tc, ThreadID tid = 0); 1031817SN/A 1041817SN/A ////////////////////////////////////////////////////////// 1051817SN/A // 1061817SN/A // DECLARE INTERFACE THAT WILL ALLOW A MiscRegFile (Cop0) 1071817SN/A // TO SCHEDULE EVENTS 1081817SN/A // 1091817SN/A ////////////////////////////////////////////////////////// 1101817SN/A 1111817SN/A // Flag that is set when CP0 state has been written to. 112771SN/A bool cp0Updated; 113803SN/A 1143932Sbinkertn@umich.edu // Enumerated List of CP0 Event Types 1154762Snate@binkert.org enum CP0EventType { 1161817SN/A UpdateCP0 1171817SN/A }; 1182539SN/A 1191817SN/A // Declare A CP0Event Class for scheduling 1201817SN/A class CP0Event : public Event 1212539SN/A { 1221817SN/A protected: 1231817SN/A ISA::CP0 *cp0; 1242648SN/A BaseCPU *cpu; 125771SN/A CP0EventType cp0EventType; 126885SN/A Fault fault; 1271817SN/A 1282982SN/A public: 1291817SN/A /** Constructs a CP0 event. */ 1301817SN/A CP0Event(CP0 *_cp0, BaseCPU *_cpu, CP0EventType e_type); 1311854SN/A 132918SN/A /** Process this event. */ 133918SN/A virtual void process(); 134918SN/A 1352982SN/A /** Returns the description of this event. */ 136918SN/A const char *description() const; 137918SN/A 138918SN/A /** Schedule This Event */ 1391854SN/A void scheduleEvent(Cycles delay); 1401854SN/A 1411817SN/A /** Unschedule This Event */ 142771SN/A void unscheduleEvent(); 1431817SN/A }; 1441854SN/A 145772SN/A // Schedule a CP0 Update Event 1461817SN/A void scheduleCP0Update(BaseCPU *cpu, Cycles delay = Cycles(0)); 1471854SN/A 1481817SN/A // If any changes have been made, then check the state for changes 1491817SN/A // and if necessary alert the CPU 1501817SN/A void updateCPU(BaseCPU *cpu); 1511817SN/A 1521817SN/A // Keep a List of CPU Events that need to be deallocated 1531817SN/A std::queue<CP0Event*> cp0EventRemoveList; 1541817SN/A 1551817SN/A static std::string miscRegNames[NumMiscRegs]; 1561817SN/A 1571817SN/A public: 1581817SN/A 1591817SN/A int 1601817SN/A flattenIntIndex(int reg) 1611817SN/A { 1621817SN/A return reg; 1631817SN/A } 1641817SN/A 1651817SN/A int 1661817SN/A flattenFloatIndex(int reg) 1671817SN/A { 1681817SN/A return reg; 1691817SN/A } 1701854SN/A 1711854SN/A void serialize(EventManager *em, std::ostream &os) 1721854SN/A {} 1731817SN/A void unserialize(EventManager *em, Checkpoint *cp, 1741817SN/A const std::string §ion) 1751817SN/A {} 1761817SN/A }; 1771817SN/A} 1781817SN/A 1791817SN/A#endif 1801817SN/A