isa.hh revision 9384
1/* 2 * Copyright (c) 2009 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Gabe Black 29 */ 30 31#ifndef __ARCH_MIPS_ISA_HH__ 32#define __ARCH_MIPS_ISA_HH__ 33 34#include <queue> 35#include <string> 36#include <vector> 37 38#include "arch/mips/registers.hh" 39#include "arch/mips/types.hh" 40#include "sim/eventq.hh" 41#include "sim/fault_fwd.hh" 42#include "sim/sim_object.hh" 43 44class BaseCPU; 45class Checkpoint; 46class EventManager; 47struct MipsISAParams; 48class ThreadContext; 49 50namespace MipsISA 51{ 52 class ISA : public SimObject 53 { 54 public: 55 // The MIPS name for this file is CP0 or Coprocessor 0 56 typedef ISA CP0; 57 58 typedef MipsISAParams Params; 59 60 protected: 61 // Number of threads and vpes an individual ISA state can handle 62 uint8_t numThreads; 63 uint8_t numVpes; 64 65 enum BankType { 66 perProcessor, 67 perThreadContext, 68 perVirtProcessor 69 }; 70 71 std::vector<std::vector<MiscReg> > miscRegFile; 72 std::vector<std::vector<MiscReg> > miscRegFile_WriteMask; 73 std::vector<BankType> bankType; 74 75 public: 76 void clear(); 77 78 void configCP(); 79 80 unsigned getVPENum(ThreadID tid); 81 82 ////////////////////////////////////////////////////////// 83 // 84 // READ/WRITE CP0 STATE 85 // 86 // 87 ////////////////////////////////////////////////////////// 88 //@TODO: MIPS MT's register view automatically connects 89 // Status to TCStatus depending on current thread 90 void updateCP0ReadView(int misc_reg, ThreadID tid) { } 91 MiscReg readMiscRegNoEffect(int misc_reg, ThreadID tid = 0); 92 93 //template <class TC> 94 MiscReg readMiscReg(int misc_reg, 95 ThreadContext *tc, ThreadID tid = 0); 96 97 MiscReg filterCP0Write(int misc_reg, int reg_sel, const MiscReg &val); 98 void setRegMask(int misc_reg, const MiscReg &val, ThreadID tid = 0); 99 void setMiscRegNoEffect(int misc_reg, const MiscReg &val, 100 ThreadID tid = 0); 101 102 //template <class TC> 103 void setMiscReg(int misc_reg, const MiscReg &val, 104 ThreadContext *tc, ThreadID tid = 0); 105 106 ////////////////////////////////////////////////////////// 107 // 108 // DECLARE INTERFACE THAT WILL ALLOW A MiscRegFile (Cop0) 109 // TO SCHEDULE EVENTS 110 // 111 ////////////////////////////////////////////////////////// 112 113 // Flag that is set when CP0 state has been written to. 114 bool cp0Updated; 115 116 // Enumerated List of CP0 Event Types 117 enum CP0EventType { 118 UpdateCP0 119 }; 120 121 // Declare A CP0Event Class for scheduling 122 class CP0Event : public Event 123 { 124 protected: 125 ISA::CP0 *cp0; 126 BaseCPU *cpu; 127 CP0EventType cp0EventType; 128 Fault fault; 129 130 public: 131 /** Constructs a CP0 event. */ 132 CP0Event(CP0 *_cp0, BaseCPU *_cpu, CP0EventType e_type); 133 134 /** Process this event. */ 135 virtual void process(); 136 137 /** Returns the description of this event. */ 138 const char *description() const; 139 140 /** Schedule This Event */ 141 void scheduleEvent(Cycles delay); 142 143 /** Unschedule This Event */ 144 void unscheduleEvent(); 145 }; 146 147 // Schedule a CP0 Update Event 148 void scheduleCP0Update(BaseCPU *cpu, Cycles delay = Cycles(0)); 149 150 // If any changes have been made, then check the state for changes 151 // and if necessary alert the CPU 152 void updateCPU(BaseCPU *cpu); 153 154 // Keep a List of CPU Events that need to be deallocated 155 std::queue<CP0Event*> cp0EventRemoveList; 156 157 static std::string miscRegNames[NumMiscRegs]; 158 159 public: 160 const Params *params() const; 161 162 ISA(Params *p); 163 164 int 165 flattenIntIndex(int reg) 166 { 167 return reg; 168 } 169 170 int 171 flattenFloatIndex(int reg) 172 { 173 return reg; 174 } 175 176 void serialize(EventManager *em, std::ostream &os) 177 {} 178 void unserialize(EventManager *em, Checkpoint *cp, 179 const std::string §ion) 180 {} 181 }; 182} 183 184#endif 185