isa.hh revision 8232
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 348229Snate@binkert.org#include <ostream> 358229Snate@binkert.org#include <string> 368229Snate@binkert.org 376335Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh" 386313Sgblack@eecs.umich.edu#include "arch/sparc/types.hh" 396335Sgblack@eecs.umich.edu#include "config/full_system.hh" 406335Sgblack@eecs.umich.edu#include "cpu/cpuevent.hh" 416335Sgblack@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{ 487741Sgblack@eecs.umich.educlass ISA 497741Sgblack@eecs.umich.edu{ 507741Sgblack@eecs.umich.edu private: 516335Sgblack@eecs.umich.edu 527741Sgblack@eecs.umich.edu /* ASR Registers */ 537741Sgblack@eecs.umich.edu // uint64_t y; // Y (used in obsolete multiplication) 547741Sgblack@eecs.umich.edu // uint8_t ccr; // Condition Code Register 557741Sgblack@eecs.umich.edu uint8_t asi; // Address Space Identifier 567741Sgblack@eecs.umich.edu uint64_t tick; // Hardware clock-tick counter 577741Sgblack@eecs.umich.edu uint8_t fprs; // Floating-Point Register State 587741Sgblack@eecs.umich.edu uint64_t gsr; // General Status Register 597741Sgblack@eecs.umich.edu uint64_t softint; 607741Sgblack@eecs.umich.edu uint64_t tick_cmpr; // Hardware tick compare registers 617741Sgblack@eecs.umich.edu uint64_t stick; // Hardware clock-tick counter 627741Sgblack@eecs.umich.edu uint64_t stick_cmpr; // Hardware tick compare registers 636335Sgblack@eecs.umich.edu 646335Sgblack@eecs.umich.edu 657741Sgblack@eecs.umich.edu /* Privileged Registers */ 667741Sgblack@eecs.umich.edu uint64_t tpc[MaxTL]; // Trap Program Counter (value from 677741Sgblack@eecs.umich.edu // previous trap level) 687741Sgblack@eecs.umich.edu uint64_t tnpc[MaxTL]; // Trap Next Program Counter (value from 697741Sgblack@eecs.umich.edu // previous trap level) 707741Sgblack@eecs.umich.edu uint64_t tstate[MaxTL]; // Trap State 717741Sgblack@eecs.umich.edu uint16_t tt[MaxTL]; // Trap Type (Type of trap which occured 727741Sgblack@eecs.umich.edu // on the previous level) 737741Sgblack@eecs.umich.edu uint64_t tba; // Trap Base Address 746335Sgblack@eecs.umich.edu 757741Sgblack@eecs.umich.edu uint16_t pstate; // Process State Register 767741Sgblack@eecs.umich.edu uint8_t tl; // Trap Level 777741Sgblack@eecs.umich.edu uint8_t pil; // Process Interrupt Register 787741Sgblack@eecs.umich.edu uint8_t cwp; // Current Window Pointer 797741Sgblack@eecs.umich.edu // uint8_t cansave; // Savable windows 807741Sgblack@eecs.umich.edu // uint8_t canrestore; // Restorable windows 817741Sgblack@eecs.umich.edu // uint8_t cleanwin; // Clean windows 827741Sgblack@eecs.umich.edu // uint8_t otherwin; // Other windows 837741Sgblack@eecs.umich.edu // uint8_t wstate; // Window State 847741Sgblack@eecs.umich.edu uint8_t gl; // Global level register 856335Sgblack@eecs.umich.edu 867741Sgblack@eecs.umich.edu /** Hyperprivileged Registers */ 877741Sgblack@eecs.umich.edu uint64_t hpstate; // Hyperprivileged State Register 887741Sgblack@eecs.umich.edu uint64_t htstate[MaxTL];// Hyperprivileged Trap State Register 897741Sgblack@eecs.umich.edu uint64_t hintp; 907741Sgblack@eecs.umich.edu uint64_t htba; // Hyperprivileged Trap Base Address register 917741Sgblack@eecs.umich.edu uint64_t hstick_cmpr; // Hardware tick compare registers 926335Sgblack@eecs.umich.edu 937741Sgblack@eecs.umich.edu uint64_t strandStatusReg;// Per strand status register 946335Sgblack@eecs.umich.edu 957741Sgblack@eecs.umich.edu /** Floating point misc registers. */ 967741Sgblack@eecs.umich.edu uint64_t fsr; // Floating-Point State Register 976335Sgblack@eecs.umich.edu 987741Sgblack@eecs.umich.edu /** MMU Internal Registers */ 997741Sgblack@eecs.umich.edu uint16_t priContext; 1007741Sgblack@eecs.umich.edu uint16_t secContext; 1017741Sgblack@eecs.umich.edu uint16_t partId; 1027741Sgblack@eecs.umich.edu uint64_t lsuCtrlReg; 1036335Sgblack@eecs.umich.edu 1047741Sgblack@eecs.umich.edu uint64_t scratchPad[8]; 1056335Sgblack@eecs.umich.edu 1067741Sgblack@eecs.umich.edu uint64_t cpu_mondo_head; 1077741Sgblack@eecs.umich.edu uint64_t cpu_mondo_tail; 1087741Sgblack@eecs.umich.edu uint64_t dev_mondo_head; 1097741Sgblack@eecs.umich.edu uint64_t dev_mondo_tail; 1107741Sgblack@eecs.umich.edu uint64_t res_error_head; 1117741Sgblack@eecs.umich.edu uint64_t res_error_tail; 1127741Sgblack@eecs.umich.edu uint64_t nres_error_head; 1137741Sgblack@eecs.umich.edu uint64_t nres_error_tail; 1146335Sgblack@eecs.umich.edu 1157741Sgblack@eecs.umich.edu // These need to check the int_dis field and if 0 then 1167741Sgblack@eecs.umich.edu // set appropriate bit in softint and checkinterrutps on the cpu 1176335Sgblack@eecs.umich.edu#if FULL_SYSTEM 1187741Sgblack@eecs.umich.edu void setFSReg(int miscReg, const MiscReg &val, ThreadContext *tc); 1197741Sgblack@eecs.umich.edu MiscReg readFSReg(int miscReg, ThreadContext * tc); 1206335Sgblack@eecs.umich.edu 1217741Sgblack@eecs.umich.edu // Update interrupt state on softint or pil change 1227741Sgblack@eecs.umich.edu void checkSoftInt(ThreadContext *tc); 1236335Sgblack@eecs.umich.edu 1247741Sgblack@eecs.umich.edu /** Process a tick compare event and generate an interrupt on the cpu if 1257741Sgblack@eecs.umich.edu * appropriate. */ 1267741Sgblack@eecs.umich.edu void processTickCompare(ThreadContext *tc); 1277741Sgblack@eecs.umich.edu void processSTickCompare(ThreadContext *tc); 1287741Sgblack@eecs.umich.edu void processHSTickCompare(ThreadContext *tc); 1296335Sgblack@eecs.umich.edu 1307741Sgblack@eecs.umich.edu typedef CpuEventWrapper<ISA, 1317741Sgblack@eecs.umich.edu &ISA::processTickCompare> TickCompareEvent; 1327741Sgblack@eecs.umich.edu TickCompareEvent *tickCompare; 1336335Sgblack@eecs.umich.edu 1347741Sgblack@eecs.umich.edu typedef CpuEventWrapper<ISA, 1357741Sgblack@eecs.umich.edu &ISA::processSTickCompare> STickCompareEvent; 1367741Sgblack@eecs.umich.edu STickCompareEvent *sTickCompare; 1376335Sgblack@eecs.umich.edu 1387741Sgblack@eecs.umich.edu typedef CpuEventWrapper<ISA, 1397741Sgblack@eecs.umich.edu &ISA::processHSTickCompare> HSTickCompareEvent; 1407741Sgblack@eecs.umich.edu HSTickCompareEvent *hSTickCompare; 1416335Sgblack@eecs.umich.edu#endif 1426337Sgblack@eecs.umich.edu 1437741Sgblack@eecs.umich.edu static const int NumGlobalRegs = 8; 1447741Sgblack@eecs.umich.edu static const int NumWindowedRegs = 24; 1457741Sgblack@eecs.umich.edu static const int WindowOverlap = 8; 1466337Sgblack@eecs.umich.edu 1477741Sgblack@eecs.umich.edu static const int TotalGlobals = (MaxGL + 1) * NumGlobalRegs; 1487741Sgblack@eecs.umich.edu static const int RegsPerWindow = NumWindowedRegs - WindowOverlap; 1497741Sgblack@eecs.umich.edu static const int TotalWindowed = NWindows * RegsPerWindow; 1506337Sgblack@eecs.umich.edu 1517741Sgblack@eecs.umich.edu enum InstIntRegOffsets { 1527741Sgblack@eecs.umich.edu CurrentGlobalsOffset = 0, 1537741Sgblack@eecs.umich.edu CurrentWindowOffset = CurrentGlobalsOffset + NumGlobalRegs, 1547741Sgblack@eecs.umich.edu MicroIntOffset = CurrentWindowOffset + NumWindowedRegs, 1557741Sgblack@eecs.umich.edu NextGlobalsOffset = MicroIntOffset + NumMicroIntRegs, 1567741Sgblack@eecs.umich.edu NextWindowOffset = NextGlobalsOffset + NumGlobalRegs, 1577741Sgblack@eecs.umich.edu PreviousGlobalsOffset = NextWindowOffset + NumWindowedRegs, 1587741Sgblack@eecs.umich.edu PreviousWindowOffset = PreviousGlobalsOffset + NumGlobalRegs, 1597741Sgblack@eecs.umich.edu TotalInstIntRegs = PreviousWindowOffset + NumWindowedRegs 1607741Sgblack@eecs.umich.edu }; 1616337Sgblack@eecs.umich.edu 1627741Sgblack@eecs.umich.edu RegIndex intRegMap[TotalInstIntRegs]; 1637741Sgblack@eecs.umich.edu void installWindow(int cwp, int offset); 1647741Sgblack@eecs.umich.edu void installGlobals(int gl, int offset); 1657741Sgblack@eecs.umich.edu void reloadRegMap(); 1666337Sgblack@eecs.umich.edu 1677741Sgblack@eecs.umich.edu public: 1686335Sgblack@eecs.umich.edu 1697741Sgblack@eecs.umich.edu void clear(); 1706335Sgblack@eecs.umich.edu 1717741Sgblack@eecs.umich.edu void serialize(EventManager *em, std::ostream & os); 1726335Sgblack@eecs.umich.edu 1737741Sgblack@eecs.umich.edu void unserialize(EventManager *em, Checkpoint *cp, 1747741Sgblack@eecs.umich.edu const std::string & section); 1756335Sgblack@eecs.umich.edu 1767741Sgblack@eecs.umich.edu protected: 1776335Sgblack@eecs.umich.edu 1787741Sgblack@eecs.umich.edu bool isHyperPriv() { return (hpstate & (1 << 2)); } 1797741Sgblack@eecs.umich.edu bool isPriv() { return (hpstate & (1 << 2)) || (pstate & (1 << 2)); } 1807741Sgblack@eecs.umich.edu bool isNonPriv() { return !isPriv(); } 1816313Sgblack@eecs.umich.edu 1827741Sgblack@eecs.umich.edu public: 1836313Sgblack@eecs.umich.edu 1847741Sgblack@eecs.umich.edu MiscReg readMiscRegNoEffect(int miscReg); 1857741Sgblack@eecs.umich.edu MiscReg readMiscReg(int miscReg, ThreadContext *tc); 1866313Sgblack@eecs.umich.edu 1877741Sgblack@eecs.umich.edu void setMiscRegNoEffect(int miscReg, const MiscReg val); 1887741Sgblack@eecs.umich.edu void setMiscReg(int miscReg, const MiscReg val, 1897741Sgblack@eecs.umich.edu ThreadContext *tc); 1906313Sgblack@eecs.umich.edu 1917741Sgblack@eecs.umich.edu int 1927741Sgblack@eecs.umich.edu flattenIntIndex(int reg) 1937741Sgblack@eecs.umich.edu { 1947741Sgblack@eecs.umich.edu assert(reg < TotalInstIntRegs); 1957741Sgblack@eecs.umich.edu RegIndex flatIndex = intRegMap[reg]; 1967741Sgblack@eecs.umich.edu assert(flatIndex < NumIntRegs); 1977741Sgblack@eecs.umich.edu return flatIndex; 1987741Sgblack@eecs.umich.edu } 1996313Sgblack@eecs.umich.edu 2007741Sgblack@eecs.umich.edu int 2017741Sgblack@eecs.umich.edu flattenFloatIndex(int reg) 2027741Sgblack@eecs.umich.edu { 2037741Sgblack@eecs.umich.edu return reg; 2047741Sgblack@eecs.umich.edu } 2056313Sgblack@eecs.umich.edu 2067741Sgblack@eecs.umich.edu ISA() 2077741Sgblack@eecs.umich.edu { 2087703Sgblack@eecs.umich.edu#if FULL_SYSTEM 2097741Sgblack@eecs.umich.edu tickCompare = NULL; 2107741Sgblack@eecs.umich.edu sTickCompare = NULL; 2117741Sgblack@eecs.umich.edu hSTickCompare = NULL; 2127703Sgblack@eecs.umich.edu#endif 2137703Sgblack@eecs.umich.edu 2147741Sgblack@eecs.umich.edu clear(); 2157741Sgblack@eecs.umich.edu } 2167741Sgblack@eecs.umich.edu}; 2176313Sgblack@eecs.umich.edu} 2186313Sgblack@eecs.umich.edu 2196313Sgblack@eecs.umich.edu#endif 220