isa.hh revision 7629
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 1426337Sgblack@eecs.umich.edu 1436337Sgblack@eecs.umich.edu static const int NumGlobalRegs = 8; 1446337Sgblack@eecs.umich.edu static const int NumWindowedRegs = 24; 1456337Sgblack@eecs.umich.edu static const int WindowOverlap = 8; 1466337Sgblack@eecs.umich.edu 1476337Sgblack@eecs.umich.edu static const int TotalGlobals = (MaxGL + 1) * NumGlobalRegs; 1486337Sgblack@eecs.umich.edu static const int RegsPerWindow = NumWindowedRegs - WindowOverlap; 1496337Sgblack@eecs.umich.edu static const int TotalWindowed = NWindows * RegsPerWindow; 1506337Sgblack@eecs.umich.edu 1516337Sgblack@eecs.umich.edu enum InstIntRegOffsets { 1526337Sgblack@eecs.umich.edu CurrentGlobalsOffset = 0, 1536337Sgblack@eecs.umich.edu CurrentWindowOffset = CurrentGlobalsOffset + NumGlobalRegs, 1546337Sgblack@eecs.umich.edu MicroIntOffset = CurrentWindowOffset + NumWindowedRegs, 1556337Sgblack@eecs.umich.edu NextGlobalsOffset = MicroIntOffset + NumMicroIntRegs, 1566337Sgblack@eecs.umich.edu NextWindowOffset = NextGlobalsOffset + NumGlobalRegs, 1576337Sgblack@eecs.umich.edu PreviousGlobalsOffset = NextWindowOffset + NumWindowedRegs, 1586337Sgblack@eecs.umich.edu PreviousWindowOffset = PreviousGlobalsOffset + NumGlobalRegs, 1596337Sgblack@eecs.umich.edu TotalInstIntRegs = PreviousWindowOffset + NumWindowedRegs 1606337Sgblack@eecs.umich.edu }; 1616337Sgblack@eecs.umich.edu 1626337Sgblack@eecs.umich.edu RegIndex intRegMap[TotalInstIntRegs]; 1636337Sgblack@eecs.umich.edu void installWindow(int cwp, int offset); 1646337Sgblack@eecs.umich.edu void installGlobals(int gl, int offset); 1656337Sgblack@eecs.umich.edu void reloadRegMap(); 1666337Sgblack@eecs.umich.edu 1676335Sgblack@eecs.umich.edu public: 1686335Sgblack@eecs.umich.edu 1696335Sgblack@eecs.umich.edu void clear(); 1706335Sgblack@eecs.umich.edu 1716335Sgblack@eecs.umich.edu void serialize(EventManager *em, std::ostream & os); 1726335Sgblack@eecs.umich.edu 1736335Sgblack@eecs.umich.edu void unserialize(EventManager *em, Checkpoint *cp, 1746335Sgblack@eecs.umich.edu const std::string & section); 1756335Sgblack@eecs.umich.edu 1766313Sgblack@eecs.umich.edu protected: 1776335Sgblack@eecs.umich.edu 1786335Sgblack@eecs.umich.edu bool isHyperPriv() { return (hpstate & (1 << 2)); } 1796335Sgblack@eecs.umich.edu bool isPriv() { return (hpstate & (1 << 2)) || (pstate & (1 << 2)); } 1806335Sgblack@eecs.umich.edu bool isNonPriv() { return !isPriv(); } 1816313Sgblack@eecs.umich.edu 1826313Sgblack@eecs.umich.edu public: 1836313Sgblack@eecs.umich.edu 1846313Sgblack@eecs.umich.edu MiscReg readMiscRegNoEffect(int miscReg); 1856313Sgblack@eecs.umich.edu MiscReg readMiscReg(int miscReg, ThreadContext *tc); 1866313Sgblack@eecs.umich.edu 1876313Sgblack@eecs.umich.edu void setMiscRegNoEffect(int miscReg, const MiscReg val); 1886313Sgblack@eecs.umich.edu void setMiscReg(int miscReg, const MiscReg val, 1896313Sgblack@eecs.umich.edu ThreadContext *tc); 1906313Sgblack@eecs.umich.edu 1916337Sgblack@eecs.umich.edu int 1926337Sgblack@eecs.umich.edu flattenIntIndex(int reg) 1936337Sgblack@eecs.umich.edu { 1946337Sgblack@eecs.umich.edu assert(reg < TotalInstIntRegs); 1956337Sgblack@eecs.umich.edu RegIndex flatIndex = intRegMap[reg]; 1966337Sgblack@eecs.umich.edu assert(flatIndex < NumIntRegs); 1976337Sgblack@eecs.umich.edu return flatIndex; 1986337Sgblack@eecs.umich.edu } 1996313Sgblack@eecs.umich.edu 2006313Sgblack@eecs.umich.edu int 2016313Sgblack@eecs.umich.edu flattenFloatIndex(int reg) 2026313Sgblack@eecs.umich.edu { 2036313Sgblack@eecs.umich.edu return reg; 2046313Sgblack@eecs.umich.edu } 2056313Sgblack@eecs.umich.edu 2066313Sgblack@eecs.umich.edu ISA() 2076313Sgblack@eecs.umich.edu { 2086313Sgblack@eecs.umich.edu clear(); 2096313Sgblack@eecs.umich.edu } 2106313Sgblack@eecs.umich.edu }; 2116313Sgblack@eecs.umich.edu} 2126313Sgblack@eecs.umich.edu 2136313Sgblack@eecs.umich.edu#endif 214