gem5  v20.1.0.0
isa.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  */
28 
29 #ifndef __ARCH_SPARC_ISA_HH__
30 #define __ARCH_SPARC_ISA_HH__
31 
32 #include <ostream>
33 #include <string>
34 
35 #include "arch/generic/isa.hh"
36 #include "arch/sparc/registers.hh"
37 #include "arch/sparc/types.hh"
38 #include "cpu/reg_class.hh"
39 #include "sim/sim_object.hh"
40 
41 class Checkpoint;
42 class EventManager;
43 struct SparcISAParams;
44 class ThreadContext;
45 
46 namespace SparcISA
47 {
48 class ISA : public BaseISA
49 {
50  private:
51 
52  /* ASR Registers */
53  // uint64_t y; // Y (used in obsolete multiplication)
54  // uint8_t ccr; // Condition Code Register
55  uint8_t asi; // Address Space Identifier
56  uint64_t tick; // Hardware clock-tick counter
57  uint8_t fprs; // Floating-Point Register State
58  uint64_t gsr; // General Status Register
59  uint64_t softint;
60  uint64_t tick_cmpr; // Hardware tick compare registers
61  uint64_t stick; // Hardware clock-tick counter
62  uint64_t stick_cmpr; // Hardware tick compare registers
63 
64 
65  /* Privileged Registers */
66  uint64_t tpc[MaxTL]; // Trap Program Counter (value from
67  // previous trap level)
68  uint64_t tnpc[MaxTL]; // Trap Next Program Counter (value from
69  // previous trap level)
70  uint64_t tstate[MaxTL]; // Trap State
71  uint16_t tt[MaxTL]; // Trap Type (Type of trap which occured
72  // on the previous level)
73  uint64_t tba; // Trap Base Address
74 
75  PSTATE pstate; // Process State Register
76  uint8_t tl; // Trap Level
77  uint8_t pil; // Process Interrupt Register
78  uint8_t cwp; // Current Window Pointer
79  // uint8_t cansave; // Savable windows
80  // uint8_t canrestore; // Restorable windows
81  // uint8_t cleanwin; // Clean windows
82  // uint8_t otherwin; // Other windows
83  // uint8_t wstate; // Window State
84  uint8_t gl; // Global level register
85 
87  HPSTATE hpstate; // Hyperprivileged State Register
88  uint64_t htstate[MaxTL];// Hyperprivileged Trap State Register
89  uint64_t hintp;
90  uint64_t htba; // Hyperprivileged Trap Base Address register
91  uint64_t hstick_cmpr; // Hardware tick compare registers
92 
93  uint64_t strandStatusReg;// Per strand status register
94 
96  uint64_t fsr; // Floating-Point State Register
97 
99  uint16_t priContext;
100  uint16_t secContext;
101  uint16_t partId;
102  uint64_t lsuCtrlReg;
103 
104  uint64_t scratchPad[8];
105 
106  uint64_t cpu_mondo_head;
107  uint64_t cpu_mondo_tail;
108  uint64_t dev_mondo_head;
109  uint64_t dev_mondo_tail;
110  uint64_t res_error_head;
111  uint64_t res_error_tail;
112  uint64_t nres_error_head;
113  uint64_t nres_error_tail;
114 
115  // These need to check the int_dis field and if 0 then
116  // set appropriate bit in softint and checkinterrutps on the cpu
117  void setFSReg(int miscReg, RegVal val);
118  RegVal readFSReg(int miscReg);
119 
120  // Update interrupt state on softint or pil change
121  void checkSoftInt();
122 
125  void processTickCompare();
126  void processSTickCompare();
127  void processHSTickCompare();
128 
131 
134 
137 
138  static const int NumGlobalRegs = 8;
139  static const int NumWindowedRegs = 24;
140  static const int WindowOverlap = 8;
141 
142  static const int TotalGlobals = (MaxGL + 1) * NumGlobalRegs;
144  static const int TotalWindowed = NWindows * RegsPerWindow;
145 
155  };
156 
158  void installWindow(int cwp, int offset);
159  void installGlobals(int gl, int offset);
160  void reloadRegMap();
161 
162  public:
163 
164  void clear();
165 
166  void serialize(CheckpointOut &cp) const override;
167  void unserialize(CheckpointIn &cp) override;
168 
169  protected:
170  bool isHyperPriv() { return hpstate.hpriv; }
171  bool isPriv() { return hpstate.hpriv || pstate.priv; }
172  bool isNonPriv() { return !isPriv(); }
173 
174  public:
175 
176  RegVal readMiscRegNoEffect(int miscReg) const;
177  RegVal readMiscReg(int miscReg);
178 
179  void setMiscRegNoEffect(int miscReg, RegVal val);
180  void setMiscReg(int miscReg, RegVal val);
181 
182  RegId
183  flattenRegId(const RegId& regId) const
184  {
185  switch (regId.classValue()) {
186  case IntRegClass:
187  return RegId(IntRegClass, flattenIntIndex(regId.index()));
188  case FloatRegClass:
189  return RegId(FloatRegClass, flattenFloatIndex(regId.index()));
190  case CCRegClass:
191  return RegId(CCRegClass, flattenCCIndex(regId.index()));
192  case MiscRegClass:
193  return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
194  default:
195  break;
196  }
197  return regId;
198  }
199 
200  int
201  flattenIntIndex(int reg) const
202  {
203  assert(reg < TotalInstIntRegs);
204  RegIndex flatIndex = intRegMap[reg];
205  assert(flatIndex < NumIntRegs);
206  return flatIndex;
207  }
208 
209  int flattenFloatIndex(int reg) const { return reg; }
210  int flattenVecIndex(int reg) const { return reg; }
211  int flattenVecElemIndex(int reg) const { return reg; }
212  int flattenVecPredIndex(int reg) const { return reg; }
213 
214  // dummy
215  int flattenCCIndex(int reg) const { return reg; }
216  int flattenMiscIndex(int reg) const { return reg; }
217 
218 
219  typedef SparcISAParams Params;
220  const Params *params() const;
221 
222  ISA(Params *p);
223 };
224 }
225 
226 #endif
SparcISA::ISA::flattenFloatIndex
int flattenFloatIndex(int reg) const
Definition: isa.hh:209
SparcISA::ISA::reloadRegMap
void reloadRegMap()
Definition: isa.cc:74
SparcISA::ISA::nres_error_tail
uint64_t nres_error_tail
Definition: isa.hh:113
SparcISA::ISA::WindowOverlap
static const int WindowOverlap
Definition: isa.hh:140
SparcISA::ISA::tstate
uint64_t tstate[MaxTL]
Definition: isa.hh:70
SparcISA::NumIntRegs
const int NumIntRegs
Definition: registers.hh:101
SparcISA::ISA::secContext
uint16_t secContext
Definition: isa.hh:100
SparcISA::ISA::NumWindowedRegs
static const int NumWindowedRegs
Definition: isa.hh:139
SparcISA::ISA::sTickCompare
STickCompareEvent * sTickCompare
Definition: isa.hh:133
SparcISA::ISA::cwp
uint8_t cwp
Definition: isa.hh:78
SparcISA::ISA::STickCompareEvent
EventWrapper< ISA, &ISA::processSTickCompare > STickCompareEvent
Definition: isa.hh:132
SparcISA::ISA::tt
uint16_t tt[MaxTL]
Definition: isa.hh:71
SparcISA::ISA::cpu_mondo_head
uint64_t cpu_mondo_head
Definition: isa.hh:106
SparcISA::ISA::PreviousGlobalsOffset
@ PreviousGlobalsOffset
Definition: isa.hh:152
EventWrapper
Definition: eventq.hh:1070
SparcISA::ISA::processSTickCompare
void processSTickCompare()
Definition: ua2005.cc:326
SparcISA::ISA::flattenVecPredIndex
int flattenVecPredIndex(int reg) const
Definition: isa.hh:212
SparcISA::ISA::hintp
uint64_t hintp
Definition: isa.hh:89
SparcISA::ISA::params
const Params * params() const
Definition: isa.cc:68
SparcISA::NumMicroIntRegs
@ NumMicroIntRegs
Definition: registers.hh:88
SparcISA::NWindows
const int NWindows
Definition: sparc_traits.hh:41
SparcISA::ISA::fprs
uint8_t fprs
Definition: isa.hh:57
X86ISA::reg
Bitfield< 5, 3 > reg
Definition: types.hh:87
SparcISA::ISA::setFSReg
void setFSReg(int miscReg, RegVal val)
Definition: ua2005.cc:90
SparcISA::ISA::strandStatusReg
uint64_t strandStatusReg
Definition: isa.hh:93
SparcISA::ISA::isPriv
bool isPriv()
Definition: isa.hh:171
RegId
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:75
SparcISA::ISA::flattenMiscIndex
int flattenMiscIndex(int reg) const
Definition: isa.hh:216
SparcISA::ISA::MicroIntOffset
@ MicroIntOffset
Definition: isa.hh:149
SparcISA::ISA::CurrentWindowOffset
@ CurrentWindowOffset
Definition: isa.hh:148
SparcISA::ISA::processHSTickCompare
void processHSTickCompare()
Definition: ua2005.cc:350
SparcISA::ISA::tpc
uint64_t tpc[MaxTL]
Definition: isa.hh:66
SparcISA::ISA::hpstate
HPSTATE hpstate
Hyperprivileged Registers.
Definition: isa.hh:87
SparcISA::ISA::NextWindowOffset
@ NextWindowOffset
Definition: isa.hh:151
SparcISA::ISA::asi
uint8_t asi
Definition: isa.hh:55
SparcISA::ISA::readMiscRegNoEffect
RegVal readMiscRegNoEffect(int miscReg) const
Definition: isa.cc:171
SparcISA
Definition: asi.cc:31
SparcISA::ISA::stick_cmpr
uint64_t stick_cmpr
Definition: isa.hh:62
SparcISA::ISA::installGlobals
void installGlobals(int gl, int offset)
Definition: isa.cc:98
SparcISA::ISA::fsr
uint64_t fsr
Floating point misc registers.
Definition: isa.hh:96
SparcISA::ISA::flattenIntIndex
int flattenIntIndex(int reg) const
Definition: isa.hh:201
SparcISA::ISA::res_error_head
uint64_t res_error_head
Definition: isa.hh:110
cp
Definition: cprintf.cc:40
FloatRegClass
@ FloatRegClass
Floating-point register.
Definition: reg_class.hh:54
SparcISA::ISA::setMiscRegNoEffect
void setMiscRegNoEffect(int miscReg, RegVal val)
Definition: isa.cc:380
SparcISA::ISA::readMiscReg
RegVal readMiscReg(int miscReg)
Definition: isa.cc:332
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
SparcISA::ISA::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:637
SparcISA::ISA::CurrentGlobalsOffset
@ CurrentGlobalsOffset
Definition: isa.hh:147
SparcISA::ISA::isHyperPriv
bool isHyperPriv()
Definition: isa.hh:170
sim_object.hh
SparcISA::ISA::installWindow
void installWindow(int cwp, int offset)
Definition: isa.cc:88
SparcISA::ISA::gsr
uint64_t gsr
Definition: isa.hh:58
SparcISA::ISA::priContext
uint16_t priContext
MMU Internal Registers.
Definition: isa.hh:99
SparcISA::ISA::TotalWindowed
static const int TotalWindowed
Definition: isa.hh:144
SparcISA::ISA::partId
uint16_t partId
Definition: isa.hh:101
SparcISA::ISA::dev_mondo_head
uint64_t dev_mondo_head
Definition: isa.hh:108
SparcISA::ISA::res_error_tail
uint64_t res_error_tail
Definition: isa.hh:111
SparcISA::ISA::checkSoftInt
void checkSoftInt()
Definition: ua2005.cc:45
SparcISA::ISA::cpu_mondo_tail
uint64_t cpu_mondo_tail
Definition: isa.hh:107
SparcISA::ISA::ISA
ISA(Params *p)
Definition: isa.cc:62
SparcISA::ISA::tick_cmpr
uint64_t tick_cmpr
Definition: isa.hh:60
SparcISA::ISA::pil
uint8_t pil
Definition: isa.hh:77
SparcISA::MaxGL
const int MaxGL
Definition: sparc_traits.hh:37
SparcISA::ISA::tick
uint64_t tick
Definition: isa.hh:56
X86ISA::val
Bitfield< 63 > val
Definition: misc.hh:769
SparcISA::ISA::flattenVecIndex
int flattenVecIndex(int reg) const
Definition: isa.hh:210
types.hh
SparcISA::ISA::setMiscReg
void setMiscReg(int miscReg, RegVal val)
Definition: isa.cc:561
SparcISA::ISA::TotalGlobals
static const int TotalGlobals
Definition: isa.hh:142
SparcISA::ISA::softint
uint64_t softint
Definition: isa.hh:59
SparcISA::ISA::scratchPad
uint64_t scratchPad[8]
Definition: isa.hh:104
SparcISA::ISA::flattenRegId
RegId flattenRegId(const RegId &regId) const
Definition: isa.hh:183
SparcISA::ISA::NextGlobalsOffset
@ NextGlobalsOffset
Definition: isa.hh:150
SparcISA::ISA::htba
uint64_t htba
Definition: isa.hh:90
IntRegClass
@ IntRegClass
Integer register.
Definition: reg_class.hh:53
CCRegClass
@ CCRegClass
Condition-code register.
Definition: reg_class.hh:60
SparcISA::ISA::htstate
uint64_t htstate[MaxTL]
Definition: isa.hh:88
SparcISA::ISA::RegsPerWindow
static const int RegsPerWindow
Definition: isa.hh:143
SparcISA::ISA::clear
void clear()
Definition: isa.cc:108
SparcISA::ISA::lsuCtrlReg
uint64_t lsuCtrlReg
Definition: isa.hh:102
isa.hh
MiscRegClass
@ MiscRegClass
Control (misc) register.
Definition: reg_class.hh:61
SparcISA::ISA::processTickCompare
void processTickCompare()
Process a tick compare event and generate an interrupt on the cpu if appropriate.
Definition: ua2005.cc:320
RegIndex
uint16_t RegIndex
Definition: types.hh:52
SparcISA::ISA::tl
uint8_t tl
Definition: isa.hh:76
reg_class.hh
SparcISA::ISA::isNonPriv
bool isNonPriv()
Definition: isa.hh:172
SparcISA::ISA::tnpc
uint64_t tnpc[MaxTL]
Definition: isa.hh:68
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
SparcISA::ISA::hSTickCompare
HSTickCompareEvent * hSTickCompare
Definition: isa.hh:136
SparcISA::ISA::hstick_cmpr
uint64_t hstick_cmpr
Definition: isa.hh:91
registers.hh
EventManager
Definition: eventq.hh:973
SparcISA::ISA::InstIntRegOffsets
InstIntRegOffsets
Definition: isa.hh:146
SparcISA::ISA::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:692
SparcISA::ISA
Definition: isa.hh:48
RegId::index
const RegIndex & index() const
Index accessors.
Definition: reg_class.hh:173
SparcISA::ISA::tickCompare
TickCompareEvent * tickCompare
Definition: isa.hh:130
SparcISA::ISA::nres_error_head
uint64_t nres_error_head
Definition: isa.hh:112
SparcISA::ISA::Params
SparcISAParams Params
Definition: isa.hh:219
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
SparcISA::ISA::TotalInstIntRegs
@ TotalInstIntRegs
Definition: isa.hh:154
SparcISA::ISA::stick
uint64_t stick
Definition: isa.hh:61
SparcISA::ISA::PreviousWindowOffset
@ PreviousWindowOffset
Definition: isa.hh:153
CheckpointIn
Definition: serialize.hh:67
SparcISA::ISA::TickCompareEvent
EventWrapper< ISA, &ISA::processTickCompare > TickCompareEvent
Definition: isa.hh:129
SparcISA::ISA::readFSReg
RegVal readFSReg(int miscReg)
Definition: ua2005.cc:246
SparcISA::ISA::HSTickCompareEvent
EventWrapper< ISA, &ISA::processHSTickCompare > HSTickCompareEvent
Definition: isa.hh:135
RegId::classValue
const RegClass & classValue() const
Class accessor.
Definition: reg_class.hh:200
SparcISA::ISA::dev_mondo_tail
uint64_t dev_mondo_tail
Definition: isa.hh:109
SparcISA::ISA::pstate
PSTATE pstate
Definition: isa.hh:75
BaseISA
Definition: isa.hh:47
SparcISA::ISA::flattenCCIndex
int flattenCCIndex(int reg) const
Definition: isa.hh:215
SparcISA::ISA::intRegMap
RegIndex intRegMap[TotalInstIntRegs]
Definition: isa.hh:157
RegVal
uint64_t RegVal
Definition: types.hh:168
SparcISA::ISA::gl
uint8_t gl
Definition: isa.hh:84
SparcISA::ISA::flattenVecElemIndex
int flattenVecElemIndex(int reg) const
Definition: isa.hh:211
SparcISA::ISA::tba
uint64_t tba
Definition: isa.hh:73
SparcISA::MaxTL
const int MaxTL
Definition: sparc_traits.hh:36
SparcISA::ISA::NumGlobalRegs
static const int NumGlobalRegs
Definition: isa.hh:138
ArmISA::offset
Bitfield< 23, 0 > offset
Definition: types.hh:153

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17