2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
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.
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.
29 #ifndef __ARCH_MIPS_ISA_TRAITS_HH__
30 #define __ARCH_MIPS_ISA_TRAITS_HH__
32 //#include "arch/mips/misc_regfile.hh"
33 #include "base/misc.hh"
34 #include "config/full_system.hh"
35 #include "sim/host.hh"
36 #include "sim/faults.hh"
44 namespace LittleEndianGuest {};
45 using namespace LittleEndianGuest;
53 int DTB_ASN_ASN(uint64_t reg);
54 int ITB_ASN_ASN(uint64_t reg);
59 typedef uint32_t MachInst;
60 // typedef uint64_t Addr;
61 typedef uint8_t RegIndex;
64 MemoryEnd = 0xffffffffffffffffULL,
70 MaxRegsOfAnyType = 32,
71 // Static instruction parameters
75 // semantically meaningful register indices
76 ZeroReg = 0, // architecturally meaningful
77 // the rest of these depend on the ABI
79 GlobalPointerReg = 29,
80 ProcedureValueReg = 27,
81 ReturnAddressReg = 26,
91 LogVMPageSize = 13, // 8K bytes
92 VMPageSize = (1 << LogVMPageSize),
94 BranchPredAddrShiftAmt = 2, // instructions are 4-byte aligned
102 // These enumerate all the registers for dependence tracking.
103 enum DependenceTags {
104 // 0..31 are the integer regs 0..31
105 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
107 Ctrl_Base_DepTag = 64,
108 Fpcr_DepTag = 64, // floating point control register
110 IPR_Base_DepTag = 66,
114 typedef uint64_t IntReg;
115 typedef IntReg IntRegFile[NumIntRegs];
117 // floating point register file entry type
124 uint64_t q[NumFloatRegs]; // integer qword view
125 double d[NumFloatRegs]; // double-precision floating point view
128 // cop-0/cop-1 system control register file
129 typedef uint64_t MiscReg;
130 typedef MiscReg MiscRegFile[NumMiscRegs];
134 //Coprocessor 0 Registers
135 //Reference MIPS32 Arch. for Programmers, Vol. III, Ch.8
136 //(Register Number-Register Select) Summary of Register
137 //------------------------------------------------------
138 Index = 0, //0-0 Index into the TLB array
140 MVPControl = 1, //0-1 Per-processor register containing global
141 //MIPS® MT configuration data
143 MVPConf0 = 2, //0-2 Per-processor register containing global
144 //MIPS® MT configuration data
146 MVPConf1 = 3, //0-3 Per-processor register containing global
147 //MIPS® MT configuration data
149 Random = 8, //1-0 Randomly generated index into the TLB array
151 VPEControl = 9, //1-1 Per-VPE register containing relatively volatile
152 //thread configuration data
154 VPEConf0 = 10, //1-2 Per-VPE multi-thread configuration
158 VPEConf1 = 11, //1-2 Per-VPE multi-thread configuration
161 YQMask = 12, //Per-VPE register defining which YIELD
162 //qualifier bits may be used without generating
168 EntryLo0 = 16, // Bank 3: 16 - 23
177 EntryLo1 = 24,// Bank 4: 24 - 31
179 Context = 32, // Bank 5: 32 - 39
182 //PageMask = 40, //Bank 6: 40 - 47
185 Wired = 48, //Bank 7:48 - 55
193 HWRena = 56,//Bank 8:56 - 63
195 Count = 64, //Bank 9:64 - 71
197 EntryHi = 72,//Bank 10:72 - 79
199 Compare = 80,//Bank 11:80 - 87
201 Status = 88,//Bank 12:88 - 96 //12-0 Processor status and control
202 IntCtl = 89, //12-1 Interrupt system status and control
203 SRSCtl = 90, //12-2 Shadow register set status and control
204 SRSMap = 91, //12-3 Shadow set IPL mapping
206 Cause = 97,//97-104 //13-0 Cause of last general exception
208 EPC = 105,//105-112 //14-0 Program counter at last exception
210 PrId = 113//113-120, //15-0 Processor identification and revision
211 EBase = 114, //15-1 Exception vector base register
213 Config = 121,//121-128
221 LLAddr = 129,//129-136
223 WatchLo0 = 137,//137-144
232 WatchHi0 = 145,//145-152
241 XCContext64 = 153,//153-160
247 Debug = 177, //177-184
255 PerfCnt0 = 193,//193 - 200
264 ErrCtl = 201, //201 - 208
266 CacheErr0 = 209, //209 - 216
271 TagLo0 = 217,//217 - 224
276 DataLo1 = 226,//225 - 232
281 TagHi0 = 233,//233 - 240
286 DataHi0 = 241,//241 - 248
291 ErrorEPC = 249,//249 - 256
303 //Alpha Regs, but here now, for
308 extern const Addr PageShift;
309 extern const Addr PageBytes;
310 extern const Addr PageMask;
311 extern const Addr PageOffset;
315 typedef uint64_t InternalProcReg;
317 #include "arch/mips/isa_fullsys_traits.hh"
321 NumInternalProcRegs = 0
327 NumIntRegs + NumFloatRegs + NumMiscRegs + NumInternalProcRegs
331 TotalDataRegs = NumIntRegs + NumFloatRegs
341 IntRegFile intRegFile; // (signed) integer register file
342 FloatRegFile floatRegFile; // floating point register file
343 MiscRegFile miscRegs; // control register file
346 Addr pc; // program counter
347 Addr npc; // next-cycle program counter
348 Addr nnpc; // next-next-cycle program counter
349 // used to implement branch delay slot
352 MiscReg hi; // MIPS HI Register
353 MiscReg lo; // MIPS LO Register
357 IntReg palregs[NumIntRegs]; // PAL shadow registers
358 InternalProcReg ipr[NumInternalProcRegs]; // internal processor regs
359 int intrflag; // interrupt flag
360 bool pal_shadow; // using pal_shadow registers
361 inline int instAsid() { return MIPS34K::ITB_ASN_ASN(ipr[IPR_ITB_ASN]); }
362 inline int dataAsid() { return MIPS34K::DTB_ASN_ASN(ipr[IPR_DTB_ASN]); }
363 #endif // FULL_SYSTEM
365 //void initCP0Regs();
366 void serialize(std::ostream &os);
367 void unserialize(Checkpoint *cp, const std::string §ion);
369 void createCP0Regs();
373 StaticInstPtr decodeInst(MachInst);
375 // return a no-op instruction... used for instruction fetch faults
376 extern const MachInst NoopMachInst;
380 // An impossible number for instruction annotations
381 ITOUCH_ANNOTE = 0xffffffff,
384 void getMiscRegIdx(int reg_name,int &idx, int &sel);
387 static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
388 panic("register classification not implemented");
389 return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
392 static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
393 panic("register classification not implemented");
394 return (reg >= 9 && reg <= 15);
397 static inline bool isCallerSaveFloatRegister(unsigned int reg) {
398 panic("register classification not implemented");
402 static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
403 panic("register classification not implemented");
407 static inline Addr alignAddress(const Addr &addr,
408 unsigned int nbytes) {
409 return (addr & ~(nbytes - 1));
412 // Instruction address compression hooks
413 static inline Addr realPCToFetchPC(const Addr &addr) {
417 static inline Addr fetchPCToRealPC(const Addr &addr) {
421 // the size of "fetched" instructions (not necessarily the size
422 // of real instructions for PISA)
423 static inline size_t fetchInstSize() {
424 return sizeof(MachInst);
427 static inline MachInst makeRegisterCopy(int dest, int src) {
428 panic("makeRegisterCopy not implemented");
432 // Machine operations
434 void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
437 void restoreMachineReg(RegFile ®s, const AnyReg ®,
441 static void serializeSpecialRegs(const Serializable::Proxy &proxy,
442 const RegFile ®s);
444 static void unserializeSpecialRegs(const IniFile *db,
445 const std::string &category,
451 * Function to insure ISA semantics about 0 registers.
452 * @param xc The execution context.
455 void zeroRegisters(XC *xc);
457 const Addr MaxAddr = (Addr)-1;
461 class SyscallReturn {
464 SyscallReturn(T v, bool s)
466 retval = (uint64_t)v;
474 retval = (uint64_t)v;
479 SyscallReturn& operator=(const SyscallReturn& s) {
485 bool successful() { return success; }
486 uint64_t value() { return retval; }
498 //typedef TheISA::InternalProcReg InternalProcReg;
499 //const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
500 //const int NumInterruptLevels = TheISA::NumInterruptLevels;
502 #include "arch/mips/mips34k.hh"
505 #endif // __ARCH_MIPS_ISA_TRAITS_HH__