isa.hh revision 6336
16313Sgblack@eecs.umich.edu/*
26313Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan
36313Sgblack@eecs.umich.edu * All rights reserved.
46313Sgblack@eecs.umich.edu *
56313Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
66313Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
76313Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
86313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
96313Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
106313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
116313Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
126313Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
136313Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
146313Sgblack@eecs.umich.edu * this software without specific prior written permission.
156313Sgblack@eecs.umich.edu *
166313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276313Sgblack@eecs.umich.edu *
286313Sgblack@eecs.umich.edu * Authors: Gabe Black
296313Sgblack@eecs.umich.edu */
306313Sgblack@eecs.umich.edu
316313Sgblack@eecs.umich.edu#ifndef __ARCH_SPARC_ISA_HH__
326313Sgblack@eecs.umich.edu#define __ARCH_SPARC_ISA_HH__
336313Sgblack@eecs.umich.edu
346335Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh"
356313Sgblack@eecs.umich.edu#include "arch/sparc/types.hh"
366335Sgblack@eecs.umich.edu#include "config/full_system.hh"
376335Sgblack@eecs.umich.edu#include "cpu/cpuevent.hh"
386335Sgblack@eecs.umich.edu
396335Sgblack@eecs.umich.edu#include <string>
406335Sgblack@eecs.umich.edu#include <ostream>
416313Sgblack@eecs.umich.edu
426313Sgblack@eecs.umich.educlass Checkpoint;
436313Sgblack@eecs.umich.educlass EventManager;
446335Sgblack@eecs.umich.educlass ThreadContext;
456313Sgblack@eecs.umich.edu
466313Sgblack@eecs.umich.edunamespace SparcISA
476313Sgblack@eecs.umich.edu{
486313Sgblack@eecs.umich.edu    class ISA
496313Sgblack@eecs.umich.edu    {
506335Sgblack@eecs.umich.edu      private:
516335Sgblack@eecs.umich.edu
526335Sgblack@eecs.umich.edu        /* ASR Registers */
536335Sgblack@eecs.umich.edu        //uint64_t y;           // Y (used in obsolete multiplication)
546335Sgblack@eecs.umich.edu        //uint8_t ccr;          // Condition Code Register
556335Sgblack@eecs.umich.edu        uint8_t asi;            // Address Space Identifier
566335Sgblack@eecs.umich.edu        uint64_t tick;          // Hardware clock-tick counter
576335Sgblack@eecs.umich.edu        uint8_t fprs;           // Floating-Point Register State
586335Sgblack@eecs.umich.edu        uint64_t gsr;           // General Status Register
596335Sgblack@eecs.umich.edu        uint64_t softint;
606335Sgblack@eecs.umich.edu        uint64_t tick_cmpr;     // Hardware tick compare registers
616335Sgblack@eecs.umich.edu        uint64_t stick;         // Hardware clock-tick counter
626335Sgblack@eecs.umich.edu        uint64_t stick_cmpr;    // Hardware tick compare registers
636335Sgblack@eecs.umich.edu
646335Sgblack@eecs.umich.edu
656335Sgblack@eecs.umich.edu        /* Privileged Registers */
666335Sgblack@eecs.umich.edu        uint64_t tpc[MaxTL];    // Trap Program Counter (value from
676335Sgblack@eecs.umich.edu                                // previous trap level)
686335Sgblack@eecs.umich.edu        uint64_t tnpc[MaxTL];   // Trap Next Program Counter (value from
696335Sgblack@eecs.umich.edu                                // previous trap level)
706335Sgblack@eecs.umich.edu        uint64_t tstate[MaxTL]; // Trap State
716335Sgblack@eecs.umich.edu        uint16_t tt[MaxTL];     // Trap Type (Type of trap which occured
726335Sgblack@eecs.umich.edu                                // on the previous level)
736335Sgblack@eecs.umich.edu        uint64_t tba;           // Trap Base Address
746335Sgblack@eecs.umich.edu
756335Sgblack@eecs.umich.edu        uint16_t pstate;        // Process State Register
766335Sgblack@eecs.umich.edu        uint8_t tl;             // Trap Level
776335Sgblack@eecs.umich.edu        uint8_t pil;            // Process Interrupt Register
786335Sgblack@eecs.umich.edu        uint8_t cwp;            // Current Window Pointer
796335Sgblack@eecs.umich.edu        //uint8_t cansave;      // Savable windows
806335Sgblack@eecs.umich.edu        //uint8_t canrestore;   // Restorable windows
816335Sgblack@eecs.umich.edu        //uint8_t cleanwin;     // Clean windows
826335Sgblack@eecs.umich.edu        //uint8_t otherwin;     // Other windows
836335Sgblack@eecs.umich.edu        //uint8_t wstate;               // Window State
846335Sgblack@eecs.umich.edu        uint8_t gl;             // Global level register
856335Sgblack@eecs.umich.edu
866335Sgblack@eecs.umich.edu        /** Hyperprivileged Registers */
876335Sgblack@eecs.umich.edu        uint64_t hpstate;       // Hyperprivileged State Register
886335Sgblack@eecs.umich.edu        uint64_t htstate[MaxTL];// Hyperprivileged Trap State Register
896335Sgblack@eecs.umich.edu        uint64_t hintp;
906335Sgblack@eecs.umich.edu        uint64_t htba;          // Hyperprivileged Trap Base Address register
916335Sgblack@eecs.umich.edu        uint64_t hstick_cmpr;   // Hardware tick compare registers
926335Sgblack@eecs.umich.edu
936335Sgblack@eecs.umich.edu        uint64_t strandStatusReg;// Per strand status register
946335Sgblack@eecs.umich.edu
956335Sgblack@eecs.umich.edu        /** Floating point misc registers. */
966335Sgblack@eecs.umich.edu        uint64_t fsr;           // Floating-Point State Register
976335Sgblack@eecs.umich.edu
986335Sgblack@eecs.umich.edu        /** MMU Internal Registers */
996335Sgblack@eecs.umich.edu        uint16_t priContext;
1006335Sgblack@eecs.umich.edu        uint16_t secContext;
1016335Sgblack@eecs.umich.edu        uint16_t partId;
1026335Sgblack@eecs.umich.edu        uint64_t lsuCtrlReg;
1036335Sgblack@eecs.umich.edu
1046335Sgblack@eecs.umich.edu        uint64_t scratchPad[8];
1056335Sgblack@eecs.umich.edu
1066335Sgblack@eecs.umich.edu        uint64_t cpu_mondo_head;
1076335Sgblack@eecs.umich.edu        uint64_t cpu_mondo_tail;
1086335Sgblack@eecs.umich.edu        uint64_t dev_mondo_head;
1096335Sgblack@eecs.umich.edu        uint64_t dev_mondo_tail;
1106335Sgblack@eecs.umich.edu        uint64_t res_error_head;
1116335Sgblack@eecs.umich.edu        uint64_t res_error_tail;
1126335Sgblack@eecs.umich.edu        uint64_t nres_error_head;
1136335Sgblack@eecs.umich.edu        uint64_t nres_error_tail;
1146335Sgblack@eecs.umich.edu
1156335Sgblack@eecs.umich.edu        // These need to check the int_dis field and if 0 then
1166335Sgblack@eecs.umich.edu        // set appropriate bit in softint and checkinterrutps on the cpu
1176335Sgblack@eecs.umich.edu#if FULL_SYSTEM
1186335Sgblack@eecs.umich.edu        void  setFSReg(int miscReg, const MiscReg &val, ThreadContext *tc);
1196335Sgblack@eecs.umich.edu        MiscReg readFSReg(int miscReg, ThreadContext * tc);
1206335Sgblack@eecs.umich.edu
1216335Sgblack@eecs.umich.edu        // Update interrupt state on softint or pil change
1226335Sgblack@eecs.umich.edu        void checkSoftInt(ThreadContext *tc);
1236335Sgblack@eecs.umich.edu
1246335Sgblack@eecs.umich.edu        /** Process a tick compare event and generate an interrupt on the cpu if
1256335Sgblack@eecs.umich.edu         * appropriate. */
1266335Sgblack@eecs.umich.edu        void processTickCompare(ThreadContext *tc);
1276335Sgblack@eecs.umich.edu        void processSTickCompare(ThreadContext *tc);
1286335Sgblack@eecs.umich.edu        void processHSTickCompare(ThreadContext *tc);
1296335Sgblack@eecs.umich.edu
1306335Sgblack@eecs.umich.edu        typedef CpuEventWrapper<ISA,
1316335Sgblack@eecs.umich.edu                &ISA::processTickCompare> TickCompareEvent;
1326335Sgblack@eecs.umich.edu        TickCompareEvent *tickCompare;
1336335Sgblack@eecs.umich.edu
1346335Sgblack@eecs.umich.edu        typedef CpuEventWrapper<ISA,
1356335Sgblack@eecs.umich.edu                &ISA::processSTickCompare> STickCompareEvent;
1366335Sgblack@eecs.umich.edu        STickCompareEvent *sTickCompare;
1376335Sgblack@eecs.umich.edu
1386335Sgblack@eecs.umich.edu        typedef CpuEventWrapper<ISA,
1396335Sgblack@eecs.umich.edu                &ISA::processHSTickCompare> HSTickCompareEvent;
1406335Sgblack@eecs.umich.edu        HSTickCompareEvent *hSTickCompare;
1416335Sgblack@eecs.umich.edu#endif
1426335Sgblack@eecs.umich.edu      public:
1436335Sgblack@eecs.umich.edu
1446335Sgblack@eecs.umich.edu        void clear();
1456335Sgblack@eecs.umich.edu
1466335Sgblack@eecs.umich.edu        void serialize(EventManager *em, std::ostream & os);
1476335Sgblack@eecs.umich.edu
1486335Sgblack@eecs.umich.edu        void unserialize(EventManager *em, Checkpoint *cp,
1496335Sgblack@eecs.umich.edu                         const std::string & section);
1506335Sgblack@eecs.umich.edu
1516313Sgblack@eecs.umich.edu      protected:
1526335Sgblack@eecs.umich.edu
1536335Sgblack@eecs.umich.edu        bool isHyperPriv() { return (hpstate & (1 << 2)); }
1546335Sgblack@eecs.umich.edu        bool isPriv() { return (hpstate & (1 << 2)) || (pstate & (1 << 2)); }
1556335Sgblack@eecs.umich.edu        bool isNonPriv() { return !isPriv(); }
1566313Sgblack@eecs.umich.edu
1576313Sgblack@eecs.umich.edu      public:
1586313Sgblack@eecs.umich.edu
1596313Sgblack@eecs.umich.edu        MiscReg readMiscRegNoEffect(int miscReg);
1606313Sgblack@eecs.umich.edu        MiscReg readMiscReg(int miscReg, ThreadContext *tc);
1616313Sgblack@eecs.umich.edu
1626313Sgblack@eecs.umich.edu        void setMiscRegNoEffect(int miscReg, const MiscReg val);
1636313Sgblack@eecs.umich.edu        void setMiscReg(int miscReg, const MiscReg val,
1646313Sgblack@eecs.umich.edu                ThreadContext *tc);
1656313Sgblack@eecs.umich.edu
1666313Sgblack@eecs.umich.edu        int flattenIntIndex(int reg);
1676313Sgblack@eecs.umich.edu
1686313Sgblack@eecs.umich.edu        int
1696313Sgblack@eecs.umich.edu        flattenFloatIndex(int reg)
1706313Sgblack@eecs.umich.edu        {
1716313Sgblack@eecs.umich.edu            return reg;
1726313Sgblack@eecs.umich.edu        }
1736313Sgblack@eecs.umich.edu
1746313Sgblack@eecs.umich.edu        ISA()
1756313Sgblack@eecs.umich.edu        {
1766313Sgblack@eecs.umich.edu            clear();
1776313Sgblack@eecs.umich.edu        }
1786313Sgblack@eecs.umich.edu    };
1796313Sgblack@eecs.umich.edu}
1806313Sgblack@eecs.umich.edu
1816313Sgblack@eecs.umich.edu#endif
182