isa_traits.hh revision 2495
1360SN/A/*
21458SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
3360SN/A * All rights reserved.
4360SN/A *
5360SN/A * Redistribution and use in source and binary forms, with or without
6360SN/A * modification, are permitted provided that the following conditions are
7360SN/A * met: redistributions of source code must retain the above copyright
8360SN/A * notice, this list of conditions and the following disclaimer;
9360SN/A * redistributions in binary form must reproduce the above copyright
10360SN/A * notice, this list of conditions and the following disclaimer in the
11360SN/A * documentation and/or other materials provided with the distribution;
12360SN/A * neither the name of the copyright holders nor the names of its
13360SN/A * contributors may be used to endorse or promote products derived from
14360SN/A * this software without specific prior written permission.
15360SN/A *
16360SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17360SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18360SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19360SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20360SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21360SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22360SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23360SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24360SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25360SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26360SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu */
282665Ssaidi@eecs.umich.edu
292665Ssaidi@eecs.umich.edu#ifndef __ARCH_MIPS_ISA_TRAITS_HH__
30360SN/A#define __ARCH_MIPS_ISA_TRAITS_HH__
31360SN/A
322093SN/A//#include "arch/mips/misc_regfile.hh"
33360SN/A#include "base/misc.hh"
34360SN/A#include "config/full_system.hh"
356712Snate@binkert.org#include "sim/host.hh"
366712Snate@binkert.org#include "sim/faults.hh"
37360SN/A
38360SN/A#include <vector>
397680Sgblack@eecs.umich.edu
402474SN/Aclass FastCPU;
41360SN/Aclass FullCPU;
426658Snate@binkert.orgclass Checkpoint;
438229Snate@binkert.orgclass ExecContext;
442680Sktlim@umich.edu
458232Snate@binkert.orgnamespace LittleEndianGuest {};
462474SN/Ausing namespace LittleEndianGuest;
47360SN/A
488229Snate@binkert.org#define TARGET_MIPS
498229Snate@binkert.org
506029Ssteve.reinhardt@amd.comclass StaticInst;
51360SN/Aclass StaticInstPtr;
52360SN/A
532107SN/Anamespace MIPS34K {
54360SN/Aint DTB_ASN_ASN(uint64_t reg);
55360SN/Aint ITB_ASN_ASN(uint64_t reg);
563114Sgblack@eecs.umich.edu};
57360SN/A
5810253Ssteve.reinhardt@amd.com#if !FULL_SYSTEM
5910253Ssteve.reinhardt@amd.comclass SyscallReturn {
6010257Ssteve.reinhardt@amd.com        public:
6110253Ssteve.reinhardt@amd.com           template <class T>
6210253Ssteve.reinhardt@amd.com           SyscallReturn(T v, bool s)
6310253Ssteve.reinhardt@amd.com           {
6410253Ssteve.reinhardt@amd.com               retval = (uint32_t)v;
6510253Ssteve.reinhardt@amd.com               success = s;
6610253Ssteve.reinhardt@amd.com           }
6710253Ssteve.reinhardt@amd.com
6810253Ssteve.reinhardt@amd.com           template <class T>
6910253Ssteve.reinhardt@amd.com           SyscallReturn(T v)
7010253Ssteve.reinhardt@amd.com           {
71360SN/A               success = (v >= 0);
722680Sktlim@umich.edu               retval = (uint32_t)v;
73360SN/A           }
742495SN/A
7510223Ssteve.reinhardt@amd.com           ~SyscallReturn() {}
76360SN/A
771450SN/A           SyscallReturn& operator=(const SyscallReturn& s) {
785958Sgblack@eecs.umich.edu               retval = s.retval;
79360SN/A               success = s.success;
80360SN/A               return *this;
81360SN/A           }
821450SN/A
833114Sgblack@eecs.umich.edu           bool successful() { return success; }
842680Sktlim@umich.edu           uint64_t value() { return retval; }
85360SN/A
861969SN/A
872484SN/A       private:
882484SN/A           uint64_t retval;
89360SN/A           bool success;
90360SN/A};
91360SN/A#endif
921450SN/A
933114Sgblack@eecs.umich.edunamespace MipsISA
942680Sktlim@umich.edu{
95360SN/A    typedef uint32_t MachInst;
966701Sgblack@eecs.umich.edu    typedef uint32_t MachInst;
9710253Ssteve.reinhardt@amd.com    typedef uint64_t ExtMachInst;
9810253Ssteve.reinhardt@amd.com    typedef uint8_t  RegIndex;
99360SN/A//  typedef uint64_t Addr;
1001458SN/A
101360SN/A       // Constants Related to the number of registers
102360SN/A
103360SN/A    const int NumIntArchRegs = 32;
1041450SN/A    const int NumPALShadowRegs = 8;
1058149SChris.Emmons@ARM.com    const int NumFloatArchRegs = 32;
1068149SChris.Emmons@ARM.com    // @todo: Figure out what this number really should be.
1078149SChris.Emmons@ARM.com    const int NumMiscArchRegs = 32;
1088149SChris.Emmons@ARM.com
10910253Ssteve.reinhardt@amd.com    const int NumIntRegs = NumIntArchRegs + NumPALShadowRegs;
11010253Ssteve.reinhardt@amd.com    const int NumFloatRegs = NumFloatArchRegs;
1118149SChris.Emmons@ARM.com    const int NumMiscRegs = NumMiscArchRegs;
1128149SChris.Emmons@ARM.com
1138149SChris.Emmons@ARM.com    const int TotalNumRegs = NumIntRegs + NumFloatRegs +
1148149SChris.Emmons@ARM.com    NumMiscRegs + 0/*NumInternalProcRegs*/;
1158149SChris.Emmons@ARM.com
1168149SChris.Emmons@ARM.com    const int TotalDataRegs = NumIntRegs + NumFloatRegs;
1173114Sgblack@eecs.umich.edu
1182680Sktlim@umich.edu    // Static instruction parameters
119360SN/A    const int MaxInstSrcRegs = 3;
1206029Ssteve.reinhardt@amd.com    const int MaxInstDestRegs = 2;
1216029Ssteve.reinhardt@amd.com
1226701Sgblack@eecs.umich.edu    // semantically meaningful register indices
1235958Sgblack@eecs.umich.edu    const int ZeroReg = 0;
1246701Sgblack@eecs.umich.edu    const int AssemblerReg = 1;
1256029Ssteve.reinhardt@amd.com    const int ReturnValueReg1 = 2;
1266029Ssteve.reinhardt@amd.com    const int ReturnValueReg2 = 3;
1276029Ssteve.reinhardt@amd.com    const int ArgumentReg0 = 4;
1282834Sksewell@umich.edu    const int ArgumentReg1 = 5;
129360SN/A    const int ArgumentReg2 = 6;
1301458SN/A    const int ArgumentReg3 = 7;
131360SN/A    const int KernelReg0 = 26;
132360SN/A    const int KernelReg1 = 27;
133360SN/A    const int GlobalPointerReg = 28;
1341450SN/A    const int StackPointerReg = 29;
1356109Ssanchezd@stanford.edu    const int FramePointerReg = 30;
1366109Ssanchezd@stanford.edu    const int ReturnAddressReg = 31;
1376109Ssanchezd@stanford.edu
1386109Ssanchezd@stanford.edu    const int SyscallNumReg = ReturnValueReg1;
1396109Ssanchezd@stanford.edu    const int SyscallPseudoReturnReg = ReturnValueReg1;
1406701Sgblack@eecs.umich.edu    const int SyscallSuccessReg = ArgumentReg3;
1416109Ssanchezd@stanford.edu
1426701Sgblack@eecs.umich.edu    const int LogVMPageSize = 13;	// 8K bytes
1436109Ssanchezd@stanford.edu    const int VMPageSize = (1 << LogVMPageSize);
1446109Ssanchezd@stanford.edu
1456109Ssanchezd@stanford.edu    const int BranchPredAddrShiftAmt = 2; // instructions are 4-byte aligned
1466109Ssanchezd@stanford.edu
1476109Ssanchezd@stanford.edu    const int MachineBytes = 4;
1486109Ssanchezd@stanford.edu    const int WordBytes = 4;
1493114Sgblack@eecs.umich.edu    const int HalfwordBytes = 2;
150360SN/A    const int ByteBytes = 1;
1512107SN/A
152360SN/A
153360SN/A    // These enumerate all the registers for dependence tracking.
154360SN/A    enum DependenceTags {
1551450SN/A        // 0..31 are the integer regs 0..31
1565748SSteve.Reinhardt@amd.com        // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
157360SN/A        FP_Base_DepTag = 32,
158360SN/A        Ctrl_Base_DepTag = 64,
1596701Sgblack@eecs.umich.edu        Fpcr_DepTag = 64,		// floating point control register
1606701Sgblack@eecs.umich.edu        Uniq_DepTag = 65,
1615748SSteve.Reinhardt@amd.com        IPR_Base_DepTag = 66,
1625748SSteve.Reinhardt@amd.com        MiscReg_DepTag = 67
1635748SSteve.Reinhardt@amd.com    };
1645748SSteve.Reinhardt@amd.com
1655748SSteve.Reinhardt@amd.com    typedef uint32_t IntReg;
1665748SSteve.Reinhardt@amd.com    typedef IntReg IntRegFile[NumIntRegs];
1675748SSteve.Reinhardt@amd.com
1685748SSteve.Reinhardt@amd.com/* floating point register file entry type
1692474SN/A    typedef union {
1702474SN/A        uint64_t q;
1715748SSteve.Reinhardt@amd.com        double d;
1728601Ssteve.reinhardt@amd.com    } FloatReg;*/
1736687Stjones1@inf.ed.ac.uk
1746687Stjones1@inf.ed.ac.uk    typedef double FloatReg;
1756687Stjones1@inf.ed.ac.uk    typedef uint64_t FloatRegBits;
1766687Stjones1@inf.ed.ac.uk
1778852Sandreas.hansson@arm.com/*typedef union {
1786687Stjones1@inf.ed.ac.uk        uint64_t q[NumFloatRegs];	// integer qword view
1796687Stjones1@inf.ed.ac.uk        double d[NumFloatRegs];		// double-precision floating point view
1806687Stjones1@inf.ed.ac.uk    } FloatRegFile;*/
1816687Stjones1@inf.ed.ac.uk
1828852Sandreas.hansson@arm.com   class FloatRegFile
1836687Stjones1@inf.ed.ac.uk    {
1846687Stjones1@inf.ed.ac.uk      protected:
1856687Stjones1@inf.ed.ac.uk
1866687Stjones1@inf.ed.ac.uk        FloatRegBits q[NumFloatRegs];	// integer qword view
1876687Stjones1@inf.ed.ac.uk        double d[NumFloatRegs];	// double-precision floating point view
1888852Sandreas.hansson@arm.com
1896687Stjones1@inf.ed.ac.uk      public:
1906687Stjones1@inf.ed.ac.uk
1912474SN/A        FloatReg readReg(int floatReg)
1921450SN/A        {
1935748SSteve.Reinhardt@amd.com            return d[floatReg];
1945748SSteve.Reinhardt@amd.com        }
1951458SN/A
1961458SN/A        FloatReg readReg(int floatReg, int width)
197360SN/A        {
198360SN/A            return readReg(floatReg);
199360SN/A        }
2001450SN/A
2013114Sgblack@eecs.umich.edu        FloatRegBits readRegBits(int floatReg)
202360SN/A        {
2036701Sgblack@eecs.umich.edu            return q[floatReg];
2046701Sgblack@eecs.umich.edu        }
2057508Stjones1@inf.ed.ac.uk
2067508Stjones1@inf.ed.ac.uk        FloatRegBits readRegBits(int floatReg, int width)
2077508Stjones1@inf.ed.ac.uk        {
2087508Stjones1@inf.ed.ac.uk            return readRegBits(floatReg);
2091970SN/A        }
2101970SN/A
2111970SN/A        Fault setReg(int floatReg, const FloatReg &val)
212360SN/A        {
213360SN/A            d[floatReg] = val;
214360SN/A            return NoFault;
2151450SN/A        }
2163114Sgblack@eecs.umich.edu
217360SN/A        Fault setReg(int floatReg, const FloatReg &val, int width)
2186701Sgblack@eecs.umich.edu        {
2196701Sgblack@eecs.umich.edu            return setReg(floatReg, val);
2206701Sgblack@eecs.umich.edu        }
2216701Sgblack@eecs.umich.edu
2226701Sgblack@eecs.umich.edu        Fault setRegBits(int floatReg, const FloatRegBits &val)
223360SN/A        {
224360SN/A            q[floatReg] = val;
225360SN/A            return NoFault;
226360SN/A        }
2278706Sandreas.hansson@arm.com
228360SN/A        Fault setRegBits(int floatReg, const FloatRegBits &val, int width)
2291458SN/A        {
230360SN/A            return setRegBits(floatReg, val);
231360SN/A        }
2321450SN/A
2333114Sgblack@eecs.umich.edu        void serialize(std::ostream &os);
234360SN/A
2356701Sgblack@eecs.umich.edu        void unserialize(Checkpoint *cp, const std::string &section);
2366701Sgblack@eecs.umich.edu
2376701Sgblack@eecs.umich.edu    };
2386701Sgblack@eecs.umich.edu
2396701Sgblack@eecs.umich.edu        void copyRegs(ExecContext *src, ExecContext *dest);
240360SN/A
2418706Sandreas.hansson@arm.com    // cop-0/cop-1 system control register file
242360SN/A    typedef uint64_t MiscReg;
243360SN/A    //typedef MiscReg MiscRegFile[NumMiscRegs];
244360SN/A    class MiscRegFile {
245360SN/A
246360SN/A      protected:
2471458SN/A        uint64_t	fpcr;		// floating point condition codes
248360SN/A        uint64_t	uniq;		// process-unique register
249360SN/A        bool		lock_flag;	// lock flag for LL/SC
250360SN/A        Addr		lock_addr;	// lock address for LL/SC
2511450SN/A
2523114Sgblack@eecs.umich.edu        MiscReg miscRegFile[NumMiscRegs];
253360SN/A
2546701Sgblack@eecs.umich.edu      public:
2556701Sgblack@eecs.umich.edu        //These functions should be removed once the simplescalar cpu model
2566701Sgblack@eecs.umich.edu        //has been replaced.
2576701Sgblack@eecs.umich.edu        int getInstAsid();
258360SN/A        int getDataAsid();
259360SN/A
260360SN/A        void copyMiscRegs(ExecContext *xc);
2611458SN/A
262360SN/A        MiscReg readReg(int misc_reg)
263360SN/A        { return miscRegFile[misc_reg]; }
264360SN/A
2651450SN/A        MiscReg readRegWithEffect(int misc_reg, Fault &fault, ExecContext *xc)
2664118Sgblack@eecs.umich.edu        { return miscRegFile[misc_reg];}
2674118Sgblack@eecs.umich.edu
2686701Sgblack@eecs.umich.edu        Fault setReg(int misc_reg, const MiscReg &val)
2696701Sgblack@eecs.umich.edu        { miscRegFile[misc_reg] = val; return NoFault; }
2706701Sgblack@eecs.umich.edu
2716701Sgblack@eecs.umich.edu        Fault setRegWithEffect(int misc_reg, const MiscReg &val,
2726701Sgblack@eecs.umich.edu                               ExecContext *xc)
2736701Sgblack@eecs.umich.edu        { miscRegFile[misc_reg] = val; return NoFault; }
2744118Sgblack@eecs.umich.edu
2754118Sgblack@eecs.umich.edu#if FULL_SYSTEM
2764118Sgblack@eecs.umich.edu        void clearIprs() { }
2774118Sgblack@eecs.umich.edu
2784118Sgblack@eecs.umich.edu      protected:
2794118Sgblack@eecs.umich.edu        InternalProcReg ipr[NumInternalProcRegs]; // Internal processor regs
2804118Sgblack@eecs.umich.edu
2814118Sgblack@eecs.umich.edu      private:
2824118Sgblack@eecs.umich.edu        MiscReg readIpr(int idx, Fault &fault, ExecContext *xc) { }
2834118Sgblack@eecs.umich.edu
2846111Ssteve.reinhardt@amd.com        Fault setIpr(int idx, uint64_t val, ExecContext *xc) { }
2856111Ssteve.reinhardt@amd.com#endif
2866111Ssteve.reinhardt@amd.com        friend class RegFile;
2876111Ssteve.reinhardt@amd.com    };
2884118Sgblack@eecs.umich.edu
2894118Sgblack@eecs.umich.edu    enum MiscRegTags {
2908706Sandreas.hansson@arm.com        //Coprocessor 0 Registers
2914118Sgblack@eecs.umich.edu        //Reference MIPS32 Arch. for Programmers, Vol. III, Ch.8
2924118Sgblack@eecs.umich.edu        //(Register Number-Register Select) Summary of Register
2934118Sgblack@eecs.umich.edu        //------------------------------------------------------
2944118Sgblack@eecs.umich.edu        Index = 0,       //0-0 Index into the TLB array
2954118Sgblack@eecs.umich.edu
2964118Sgblack@eecs.umich.edu        MVPControl = 1,  //0-1 Per-processor register containing global
2974118Sgblack@eecs.umich.edu                     //MIPS� MT configuration data
2984118Sgblack@eecs.umich.edu
2994118Sgblack@eecs.umich.edu        MVPConf0 = 2,    //0-2 Per-processor register containing global
3003114Sgblack@eecs.umich.edu                     //MIPS� MT configuration data
301360SN/A
302360SN/A        MVPConf1 = 3,    //0-3 Per-processor register containing global
3031458SN/A                     //MIPS� MT configuration data
304360SN/A
305360SN/A        Random = 8,      //1-0 Randomly generated index into the TLB array
306360SN/A
307360SN/A        VPEControl = 9,  //1-1 Per-VPE register containing relatively volatile
308360SN/A                     //thread configuration data
3091450SN/A
3103114Sgblack@eecs.umich.edu        VPEConf0 = 10,    //1-2 Per-VPE multi-thread configuration
311360SN/A                     //information
3126701Sgblack@eecs.umich.edu
3136701Sgblack@eecs.umich.edu
3146701Sgblack@eecs.umich.edu        VPEConf1 = 11,    //1-2 Per-VPE multi-thread configuration
3156701Sgblack@eecs.umich.edu                     //information
316360SN/A
317360SN/A        YQMask = 12,      //Per-VPE register defining which YIELD
318360SN/A                     //qualifier bits may be used without generating
3198706Sandreas.hansson@arm.com                     //an exception
320360SN/A
3211458SN/A        VPESchedule = 13,
322360SN/A        VPEScheFBack =  14,
323360SN/A        VPEOpt = 15,
3241450SN/A        EntryLo0 = 16, // Bank 3: 16 - 23
3255513SMichael.Adler@intel.com        TCStatus = 17,
3265513SMichael.Adler@intel.com        TCBind = 18,
3275513SMichael.Adler@intel.com        TCRestart = 19,
3286731Svince@csl.cornell.edu        TCHalt = 20,
3296701Sgblack@eecs.umich.edu        TCContext = 21,
3306701Sgblack@eecs.umich.edu        TCSchedule = 22,
3316701Sgblack@eecs.umich.edu        TCScheFBack = 23,
3325513SMichael.Adler@intel.com
3335513SMichael.Adler@intel.com        EntryLo1 = 24,// Bank 4: 24 - 31
3345513SMichael.Adler@intel.com
3355513SMichael.Adler@intel.com        Context = 32, // Bank 5: 32 - 39
3365513SMichael.Adler@intel.com        ContextConfig = 33,
3375513SMichael.Adler@intel.com
3385513SMichael.Adler@intel.com        //PageMask = 40, //Bank 6: 40 - 47
3395513SMichael.Adler@intel.com        PageGrain = 41,
3405513SMichael.Adler@intel.com
3415513SMichael.Adler@intel.com        Wired = 48, //Bank 7:48 - 55
3425513SMichael.Adler@intel.com        SRSConf0 = 49,
3435513SMichael.Adler@intel.com        SRSConf1 = 50,
3445513SMichael.Adler@intel.com        SRSConf2 = 51,
3455513SMichael.Adler@intel.com        SRSConf3 = 52,
3465513SMichael.Adler@intel.com        SRSConf4 = 53,
3475513SMichael.Adler@intel.com        BadVAddr = 54,
3485513SMichael.Adler@intel.com
3495513SMichael.Adler@intel.com        HWRena = 56,//Bank 8:56 - 63
3505513SMichael.Adler@intel.com
3515513SMichael.Adler@intel.com        Count = 64, //Bank 9:64 - 71
3528706Sandreas.hansson@arm.com
3535513SMichael.Adler@intel.com        EntryHi = 72,//Bank 10:72 - 79
3545513SMichael.Adler@intel.com
3555513SMichael.Adler@intel.com        Compare = 80,//Bank 11:80 - 87
3565513SMichael.Adler@intel.com
35710203SAli.Saidi@ARM.com        Status = 88,//Bank 12:88 - 96     //12-0 Processor status and control
35810203SAli.Saidi@ARM.com        IntCtl = 89,                      //12-1 Interrupt system status and control
35910203SAli.Saidi@ARM.com        SRSCtl = 90,                      //12-2 Shadow register set status and control
36010203SAli.Saidi@ARM.com        SRSMap = 91,                      //12-3 Shadow set IPL mapping
36110203SAli.Saidi@ARM.com
36210203SAli.Saidi@ARM.com        Cause = 97,//97-104      //13-0 Cause of last general exception
36310203SAli.Saidi@ARM.com
3645513SMichael.Adler@intel.com        EPC = 105,//105-112        //14-0 Program counter at last exception
3655513SMichael.Adler@intel.com
36610203SAli.Saidi@ARM.com        PRId = 113,//113-120,       //15-0 Processor identification and revision
36710203SAli.Saidi@ARM.com        EBase = 114,      //15-1 Exception vector base register
3685513SMichael.Adler@intel.com
3695513SMichael.Adler@intel.com        Config = 121,//Bank 16: 121-128
3705513SMichael.Adler@intel.com        Config1 = 122,
3718852Sandreas.hansson@arm.com        Config2 = 123,
37210223Ssteve.reinhardt@amd.com        Config3 = 124,
3735513SMichael.Adler@intel.com        Config6 = 127,
3745513SMichael.Adler@intel.com        Config7 = 128,
3755513SMichael.Adler@intel.com
3765513SMichael.Adler@intel.com
3776701Sgblack@eecs.umich.edu        LLAddr = 129,//Bank 17: 129-136
3786701Sgblack@eecs.umich.edu
3796701Sgblack@eecs.umich.edu        WatchLo0 = 137,//Bank 18: 137-144
3806701Sgblack@eecs.umich.edu        WatchLo1 = 138,
3815513SMichael.Adler@intel.com        WatchLo2 = 139,
3825513SMichael.Adler@intel.com        WatchLo3 = 140,
3835513SMichael.Adler@intel.com        WatchLo4 = 141,
3848706Sandreas.hansson@arm.com        WatchLo5 = 142,
3855513SMichael.Adler@intel.com        WatchLo6 = 143,
3865513SMichael.Adler@intel.com        WatchLo7 = 144,
3875513SMichael.Adler@intel.com
3885513SMichael.Adler@intel.com        WatchHi0 = 145,//Bank 19: 145-152
3895513SMichael.Adler@intel.com        WatchHi1 = 146,
3903114Sgblack@eecs.umich.edu        WatchHi2 = 147,
391511SN/A        WatchHi3 = 148,
3921706SN/A        WatchHi4 = 149,
393360SN/A        WatchHi5 = 150,
3946701Sgblack@eecs.umich.edu        WatchHi6 = 151,
3958852Sandreas.hansson@arm.com        WatchHi7 = 152,
39610223Ssteve.reinhardt@amd.com
397511SN/A        XCContext64 = 153,//Bank 20: 153-160
3983669Sbinkertn@umich.edu
3993669Sbinkertn@umich.edu        //Bank 21: 161-168
4003669Sbinkertn@umich.edu
401511SN/A        //Bank 22: 169-176
4021458SN/A
403511SN/A        Debug = 177, //Bank 23: 177-184
404511SN/A        TraceControl1 = 178,
4055513SMichael.Adler@intel.com        TraceControl2 = 179,
4065513SMichael.Adler@intel.com        UserTraceData = 180,
4075513SMichael.Adler@intel.com        TraceBPC = 181,
4085513SMichael.Adler@intel.com
4095513SMichael.Adler@intel.com        DEPC = 185,//Bank 24: 185-192
4105513SMichael.Adler@intel.com
4116701Sgblack@eecs.umich.edu        PerfCnt0 = 193,//Bank 25: 193 - 200
4128852Sandreas.hansson@arm.com        PerfCnt1 = 194,
41310223Ssteve.reinhardt@amd.com        PerfCnt2 = 195,
4145513SMichael.Adler@intel.com        PerfCnt3 = 196,
4155513SMichael.Adler@intel.com        PerfCnt4 = 197,
4165513SMichael.Adler@intel.com        PerfCnt5 = 198,
4175513SMichael.Adler@intel.com        PerfCnt6 = 199,
4186701Sgblack@eecs.umich.edu        PerfCnt7 = 200,
4195513SMichael.Adler@intel.com
4205513SMichael.Adler@intel.com        ErrCtl = 201, //Bank 26: 201 - 208
4215513SMichael.Adler@intel.com
4225513SMichael.Adler@intel.com        CacheErr0 = 209, //Bank 27: 209 - 216
4235513SMichael.Adler@intel.com        CacheErr1 = 210,
4241450SN/A        CacheErr2 = 211,
4253114Sgblack@eecs.umich.edu        CacheErr3 = 212,
426511SN/A
4271706SN/A        TagLo0 = 217,//Bank 28: 217 - 224
428511SN/A        DataLo1 = 218,
4296701Sgblack@eecs.umich.edu        TagLo2 = 219,
4308852Sandreas.hansson@arm.com        DataLo3 = 220,
4311458SN/A        TagLo4 = 221,
432511SN/A        DataLo5 = 222,
4331706SN/A        TagLo6 = 223,
434511SN/A        DataLo7 = 234,
4358852Sandreas.hansson@arm.com
4361458SN/A        TagHi0 = 233,//Bank 29: 233 - 240
437511SN/A        DataHi1 = 234,
4383669Sbinkertn@umich.edu        TagHi2 = 235,
4393669Sbinkertn@umich.edu        DataHi3 = 236,
4403669Sbinkertn@umich.edu        TagHi4 = 237,
4413669Sbinkertn@umich.edu        DataHi5 = 238,
4421706SN/A        TagHi6 = 239,
4431458SN/A        DataHi7 = 240,
444511SN/A
445511SN/A
4461706SN/A        ErrorEPC = 249,//Bank 30: 241 - 248
4473114Sgblack@eecs.umich.edu
4481706SN/A        DESAVE = 257,//Bank 31: 249-256
4491706SN/A
4501706SN/A        //More Misc. Regs
4516701Sgblack@eecs.umich.edu        Hi,
4528852Sandreas.hansson@arm.com        Lo,
4531706SN/A        FCSR,
4541706SN/A        FIR,
4556701Sgblack@eecs.umich.edu        FPCR,
4561706SN/A
4573669Sbinkertn@umich.edu        //Alpha Regs, but here now, for
4583669Sbinkertn@umich.edu        //compiling sake
4593669Sbinkertn@umich.edu        UNIQ,
4601706SN/A        LockAddr,
4611706SN/A        LockFlag
4621706SN/A    };
4631706SN/A
4641706SN/Aextern const Addr PageShift;
4656111Ssteve.reinhardt@amd.comextern const Addr PageBytes;
4666111Ssteve.reinhardt@amd.comextern const Addr PageMask;
4671706SN/Aextern const Addr PageOffset;
4686701Sgblack@eecs.umich.edu
4696701Sgblack@eecs.umich.edu#if FULL_SYSTEM
4701706SN/A
4711706SN/A    typedef uint64_t InternalProcReg;
4721706SN/A
4731706SN/A#include "arch/mips/isa_fullsys_traits.hh"
4746701Sgblack@eecs.umich.edu
4751706SN/A#else
4761706SN/A    enum {
4771706SN/A        NumInternalProcRegs = 0
4781706SN/A    };
4791999SN/A#endif
4801999SN/A
4816703Svince@csl.cornell.edu    typedef union {
4826703Svince@csl.cornell.edu        IntReg  intreg;
4836703Svince@csl.cornell.edu        FloatReg   fpreg;
4846703Svince@csl.cornell.edu        MiscReg ctrlreg;
4856703Svince@csl.cornell.edu    } AnyReg;
4866703Svince@csl.cornell.edu
4878852Sandreas.hansson@arm.com    struct RegFile {
4886703Svince@csl.cornell.edu        IntRegFile intRegFile;		// (signed) integer register file
4896703Svince@csl.cornell.edu        FloatRegFile floatRegFile;	// floating point register file
4906744SAli.Saidi@arm.com        MiscRegFile miscRegs;		// control register file
4916703Svince@csl.cornell.edu
4926703Svince@csl.cornell.edu
4936703Svince@csl.cornell.edu        Addr pc;			// program counter
4946703Svince@csl.cornell.edu        Addr npc;			// next-cycle program counter
4956744SAli.Saidi@arm.com        Addr nnpc;			// next-next-cycle program counter
4966744SAli.Saidi@arm.com                                        // used to implement branch delay slot
4976744SAli.Saidi@arm.com                                        // not real register
4986703Svince@csl.cornell.edu
4996744SAli.Saidi@arm.com        MiscReg hi;                     // MIPS HI Register
5006703Svince@csl.cornell.edu        MiscReg lo;                     // MIPS LO Register
5016703Svince@csl.cornell.edu
5026703Svince@csl.cornell.edu
5036703Svince@csl.cornell.edu#if FULL_SYSTEM
5046685Stjones1@inf.ed.ac.uk        IntReg palregs[NumIntRegs];	// PAL shadow registers
5056685Stjones1@inf.ed.ac.uk        InternalProcReg ipr[NumInternalProcRegs]; // internal processor regs
5066685Stjones1@inf.ed.ac.uk        int intrflag;			// interrupt flag
5076701Sgblack@eecs.umich.edu        bool pal_shadow;		// using pal_shadow registers
5086701Sgblack@eecs.umich.edu        inline int instAsid() { return MIPS34K::ITB_ASN_ASN(ipr[IPR_ITB_ASN]); }
5096685Stjones1@inf.ed.ac.uk        inline int dataAsid() { return MIPS34K::DTB_ASN_ASN(ipr[IPR_DTB_ASN]); }
5106685Stjones1@inf.ed.ac.uk#endif // FULL_SYSTEM
5116685Stjones1@inf.ed.ac.uk
5126685Stjones1@inf.ed.ac.uk        //void initCP0Regs();
5136744SAli.Saidi@arm.com        void serialize(std::ostream &os);
5146685Stjones1@inf.ed.ac.uk        void unserialize(Checkpoint *cp, const std::string &section);
5156744SAli.Saidi@arm.com
5166744SAli.Saidi@arm.com        void createCP0Regs();
5176744SAli.Saidi@arm.com        void coldReset();
5186685Stjones1@inf.ed.ac.uk    };
5196744SAli.Saidi@arm.com
5206685Stjones1@inf.ed.ac.uk    StaticInstPtr decodeInst(ExtMachInst);
5216685Stjones1@inf.ed.ac.uk
5226685Stjones1@inf.ed.ac.uk    // return a no-op instruction... used for instruction fetch faults
5236685Stjones1@inf.ed.ac.uk    extern const MachInst NoopMachInst;
5245513SMichael.Adler@intel.com
5255513SMichael.Adler@intel.com    enum annotes {
5265513SMichael.Adler@intel.com        ANNOTE_NONE = 0,
5275513SMichael.Adler@intel.com        // An impossible number for instruction annotations
5285513SMichael.Adler@intel.com        ITOUCH_ANNOTE = 0xffffffff,
5295513SMichael.Adler@intel.com    };
5305513SMichael.Adler@intel.com
5315521Snate@binkert.org//void getMiscRegIdx(int reg_name,int &idx, int &sel);
5325513SMichael.Adler@intel.com
5335513SMichael.Adler@intel.com    static inline ExtMachInst
5345513SMichael.Adler@intel.com    makeExtMI(MachInst inst, const uint64_t &pc) {
5353114Sgblack@eecs.umich.edu#if FULL_SYSTEM
5361999SN/A        ExtMachInst ext_inst = inst;
5371999SN/A        if (pc && 0x1)
5381999SN/A            return ext_inst|=(static_cast<ExtMachInst>(pc & 0x1) << 32);
5396701Sgblack@eecs.umich.edu        else
5408852Sandreas.hansson@arm.com            return ext_inst;
5411999SN/A#else
5421999SN/A        return ExtMachInst(inst);
5431999SN/A#endif
5446701Sgblack@eecs.umich.edu    }
5451999SN/A
5466701Sgblack@eecs.umich.edu    static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
5471999SN/A        panic("register classification not implemented");
5481999SN/A        return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
5493669Sbinkertn@umich.edu    }
5503669Sbinkertn@umich.edu
5513669Sbinkertn@umich.edu    static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
5521999SN/A        panic("register classification not implemented");
5531999SN/A        return (reg >= 9 && reg <= 15);
5541999SN/A    }
5551999SN/A
5561999SN/A    static inline bool isCallerSaveFloatRegister(unsigned int reg) {
5573114Sgblack@eecs.umich.edu        panic("register classification not implemented");
5581999SN/A        return false;
5596701Sgblack@eecs.umich.edu    }
5606701Sgblack@eecs.umich.edu
5611999SN/A    static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
5621999SN/A        panic("register classification not implemented");
5631999SN/A        return false;
5641999SN/A    }
5651999SN/A
5666701Sgblack@eecs.umich.edu    static inline Addr alignAddress(const Addr &addr,
5671999SN/A                                         unsigned int nbytes) {
5686701Sgblack@eecs.umich.edu        return (addr & ~(nbytes - 1));
5691999SN/A    }
5701999SN/A
5711999SN/A    // Instruction address compression hooks
5721999SN/A    static inline Addr realPCToFetchPC(const Addr &addr) {
5731999SN/A        return addr;
5742093SN/A    }
5752093SN/A
5762093SN/A    static inline Addr fetchPCToRealPC(const Addr &addr) {
5773114Sgblack@eecs.umich.edu        return addr;
5783079Sstever@eecs.umich.edu    }
5796701Sgblack@eecs.umich.edu
5806701Sgblack@eecs.umich.edu    // the size of "fetched" instructions (not necessarily the size
5813079Sstever@eecs.umich.edu    // of real instructions for PISA)
5823079Sstever@eecs.umich.edu    static inline size_t fetchInstSize() {
5833079Sstever@eecs.umich.edu        return sizeof(MachInst);
5846701Sgblack@eecs.umich.edu    }
5855282Srstrong@cs.ucsd.edu
5863079Sstever@eecs.umich.edu    static inline MachInst makeRegisterCopy(int dest, int src) {
5876111Ssteve.reinhardt@amd.com        panic("makeRegisterCopy not implemented");
5886111Ssteve.reinhardt@amd.com        return 0;
5893079Sstever@eecs.umich.edu    }
5903079Sstever@eecs.umich.edu
5913079Sstever@eecs.umich.edu    static inline void setSyscallReturn(SyscallReturn return_value, RegFile *regs)
5923079Sstever@eecs.umich.edu    {
5933114Sgblack@eecs.umich.edu        if (return_value.successful()) {
5942680Sktlim@umich.edu            // no error
5952093SN/A            regs->intRegFile[SyscallSuccessReg] = 0;
5966701Sgblack@eecs.umich.edu            regs->intRegFile[ReturnValueReg1] = return_value.value();
5976701Sgblack@eecs.umich.edu        } else {
5982093SN/A            // got an error, return details
5992093SN/A            regs->intRegFile[SyscallSuccessReg] = (IntReg) -1;
6002093SN/A            regs->intRegFile[ReturnValueReg1] = -return_value.value();
6012093SN/A        }
6026701Sgblack@eecs.umich.edu    }
6032093SN/A
6042093SN/A    // Machine operations
6052093SN/A
6062093SN/A    void saveMachineReg(AnyReg &savereg, const RegFile &reg_file,
6072093SN/A                               int regnum);
6082093SN/A
6092093SN/A    void restoreMachineReg(RegFile &regs, const AnyReg &reg,
6102093SN/A                                  int regnum);
6112093SN/A
6122093SN/A#if 0
6132093SN/A    static void serializeSpecialRegs(const Serializable::Proxy &proxy,
6142093SN/A                                     const RegFile &regs);
6152093SN/A
6162093SN/A    static void unserializeSpecialRegs(const IniFile *db,
6172093SN/A                                       const std::string &category,
6182093SN/A                                       ConfigNode *node,
6192093SN/A                                       RegFile &regs);
6202093SN/A#endif
6212093SN/A
6222093SN/A    /**
6232093SN/A     * Function to insure ISA semantics about 0 registers.
6242093SN/A     * @param xc The execution context.
6252093SN/A     */
6262093SN/A    template <class XC>
6272093SN/A    void zeroRegisters(XC *xc);
6282093SN/A
6292093SN/A    const Addr MaxAddr = (Addr)-1;
6302093SN/A};
6312093SN/A
6322093SN/A#if FULL_SYSTEM
6332093SN/A//typedef TheISA::InternalProcReg InternalProcReg;
6342093SN/A//const int NumInternalProcRegs  = TheISA::NumInternalProcRegs;
6352238SN/A//const int NumInterruptLevels = TheISA::NumInterruptLevels;
6363114Sgblack@eecs.umich.edu
6372687Sksewell@umich.edu#include "arch/mips/mips34k.hh"
6382687Sksewell@umich.edu#endif
6396701Sgblack@eecs.umich.edu
6406701Sgblack@eecs.umich.eduusing namespace MipsISA;
6412687Sksewell@umich.edu
6422687Sksewell@umich.edu#endif // __ARCH_MIPS_ISA_TRAITS_HH__
6432687Sksewell@umich.edu