gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Authors: Gabe Black
29  */
30 
31 #ifndef __ARCH_SPARC_ISA_HH__
32 #define __ARCH_SPARC_ISA_HH__
33 
34 #include <ostream>
35 #include <string>
36 
37 #include "arch/sparc/registers.hh"
38 #include "arch/sparc/types.hh"
39 #include "cpu/cpuevent.hh"
40 #include "sim/sim_object.hh"
41 
42 class Checkpoint;
43 class EventManager;
44 struct SparcISAParams;
45 class ThreadContext;
46 
47 namespace SparcISA
48 {
49 class ISA : public SimObject
50 {
51  private:
52 
53  /* ASR Registers */
54  // uint64_t y; // Y (used in obsolete multiplication)
55  // uint8_t ccr; // Condition Code Register
56  uint8_t asi; // Address Space Identifier
57  uint64_t tick; // Hardware clock-tick counter
58  uint8_t fprs; // Floating-Point Register State
59  uint64_t gsr; // General Status Register
60  uint64_t softint;
61  uint64_t tick_cmpr; // Hardware tick compare registers
62  uint64_t stick; // Hardware clock-tick counter
63  uint64_t stick_cmpr; // Hardware tick compare registers
64 
65 
66  /* Privileged Registers */
67  uint64_t tpc[MaxTL]; // Trap Program Counter (value from
68  // previous trap level)
69  uint64_t tnpc[MaxTL]; // Trap Next Program Counter (value from
70  // previous trap level)
71  uint64_t tstate[MaxTL]; // Trap State
72  uint16_t tt[MaxTL]; // Trap Type (Type of trap which occured
73  // on the previous level)
74  uint64_t tba; // Trap Base Address
75 
76  PSTATE pstate; // Process State Register
77  uint8_t tl; // Trap Level
78  uint8_t pil; // Process Interrupt Register
79  uint8_t cwp; // Current Window Pointer
80  // uint8_t cansave; // Savable windows
81  // uint8_t canrestore; // Restorable windows
82  // uint8_t cleanwin; // Clean windows
83  // uint8_t otherwin; // Other windows
84  // uint8_t wstate; // Window State
85  uint8_t gl; // Global level register
86 
88  HPSTATE hpstate; // Hyperprivileged State Register
89  uint64_t htstate[MaxTL];// Hyperprivileged Trap State Register
90  uint64_t hintp;
91  uint64_t htba; // Hyperprivileged Trap Base Address register
92  uint64_t hstick_cmpr; // Hardware tick compare registers
93 
94  uint64_t strandStatusReg;// Per strand status register
95 
97  uint64_t fsr; // Floating-Point State Register
98 
100  uint16_t priContext;
101  uint16_t secContext;
102  uint16_t partId;
103  uint64_t lsuCtrlReg;
104 
105  uint64_t scratchPad[8];
106 
107  uint64_t cpu_mondo_head;
108  uint64_t cpu_mondo_tail;
109  uint64_t dev_mondo_head;
110  uint64_t dev_mondo_tail;
111  uint64_t res_error_head;
112  uint64_t res_error_tail;
113  uint64_t nres_error_head;
114  uint64_t nres_error_tail;
115 
116  // These need to check the int_dis field and if 0 then
117  // set appropriate bit in softint and checkinterrutps on the cpu
118  void setFSReg(int miscReg, const MiscReg &val, ThreadContext *tc);
119  MiscReg readFSReg(int miscReg, ThreadContext * tc);
120 
121  // Update interrupt state on softint or pil change
122  void checkSoftInt(ThreadContext *tc);
123 
129 
130  typedef CpuEventWrapper<ISA,
133 
134  typedef CpuEventWrapper<ISA,
137 
138  typedef CpuEventWrapper<ISA,
141 
142  static const int NumGlobalRegs = 8;
143  static const int NumWindowedRegs = 24;
144  static const int WindowOverlap = 8;
145 
146  static const int TotalGlobals = (MaxGL + 1) * NumGlobalRegs;
148  static const int TotalWindowed = NWindows * RegsPerWindow;
149 
159  };
160 
162  void installWindow(int cwp, int offset);
163  void installGlobals(int gl, int offset);
164  void reloadRegMap();
165 
166  public:
167 
168  void clear();
169 
170  void serialize(CheckpointOut &cp) const override;
171  void unserialize(CheckpointIn &cp) override;
172 
173  void startup(ThreadContext *tc) {}
174 
176  using SimObject::startup;
177 
178  protected:
179  bool isHyperPriv() { return hpstate.hpriv; }
180  bool isPriv() { return hpstate.hpriv || pstate.priv; }
181  bool isNonPriv() { return !isPriv(); }
182 
183  public:
184 
185  MiscReg readMiscRegNoEffect(int miscReg) const;
186  MiscReg readMiscReg(int miscReg, ThreadContext *tc);
187 
188  void setMiscRegNoEffect(int miscReg, const MiscReg val);
189  void setMiscReg(int miscReg, const MiscReg val,
190  ThreadContext *tc);
191 
192  int
193  flattenIntIndex(int reg) const
194  {
195  assert(reg < TotalInstIntRegs);
196  RegIndex flatIndex = intRegMap[reg];
197  assert(flatIndex < NumIntRegs);
198  return flatIndex;
199  }
200 
201  int
203  {
204  return reg;
205  }
206 
207  // dummy
208  int
209  flattenCCIndex(int reg) const
210  {
211  return reg;
212  }
213 
214  int
216  {
217  return reg;
218  }
219 
220 
221  typedef SparcISAParams Params;
222  const Params *params() const;
223 
224  ISA(Params *p);
225 };
226 }
227 
228 #endif
int flattenIntIndex(int reg) const
Definition: isa.hh:193
void setFSReg(int miscReg, const MiscReg &val, ThreadContext *tc)
Definition: ua2005.cc:91
Bitfield< 5, 3 > reg
Definition: types.hh:89
MiscReg readFSReg(int miscReg, ThreadContext *tc)
Definition: ua2005.cc:245
void setMiscReg(int miscReg, const MiscReg val, ThreadContext *tc)
Definition: isa.cc:566
uint64_t htba
Definition: isa.hh:91
void reloadRegMap()
Definition: isa.cc:80
void installGlobals(int gl, int offset)
Definition: isa.cc:104
uint64_t dev_mondo_tail
Definition: isa.hh:110
CpuEventWrapper< ISA,&ISA::processSTickCompare > STickCompareEvent
Definition: isa.hh:135
uint8_t pil
Definition: isa.hh:78
uint16_t RegIndex
Definition: registers.hh:62
const int NumIntRegs
Definition: registers.hh:76
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:642
void processSTickCompare(ThreadContext *tc)
Definition: ua2005.cc:325
uint64_t tnpc[MaxTL]
Definition: isa.hh:69
const int MaxGL
Definition: sparc_traits.hh:39
static const int NumWindowedRegs
Definition: isa.hh:143
int flattenFloatIndex(int reg) const
Definition: isa.hh:202
uint8_t cwp
Definition: isa.hh:79
uint16_t partId
Definition: isa.hh:102
uint64_t htstate[MaxTL]
Definition: isa.hh:89
TickCompareEvent * tickCompare
Definition: isa.hh:132
PSTATE pstate
Definition: isa.hh:76
Bitfield< 23, 0 > offset
Definition: types.hh:149
CpuEventWrapper< ISA,&ISA::processTickCompare > TickCompareEvent
Definition: isa.hh:131
int flattenCCIndex(int reg) const
Definition: isa.hh:209
uint64_t tick
Definition: isa.hh:57
uint64_t tpc[MaxTL]
Definition: isa.hh:67
RegIndex intRegMap[TotalInstIntRegs]
Definition: isa.hh:161
ThreadContext is the external interface to all thread state for anything outside of the CPU...
uint64_t nres_error_tail
Definition: isa.hh:114
uint64_t fsr
Floating point misc registers.
Definition: isa.hh:97
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:718
uint64_t lsuCtrlReg
Definition: isa.hh:103
uint64_t tstate[MaxTL]
Definition: isa.hh:71
Bitfield< 63 > val
Definition: misc.hh:770
uint64_t hstick_cmpr
Definition: isa.hh:92
void processTickCompare(ThreadContext *tc)
Process a tick compare event and generate an interrupt on the cpu if appropriate. ...
Definition: ua2005.cc:319
InstIntRegOffsets
Definition: isa.hh:150
bool isHyperPriv()
Definition: isa.hh:179
void processHSTickCompare(ThreadContext *tc)
Definition: ua2005.cc:349
static const int NumGlobalRegs
Definition: isa.hh:142
uint64_t dev_mondo_head
Definition: isa.hh:109
uint8_t asi
Definition: isa.hh:56
uint64_t tba
Definition: isa.hh:74
uint64_t nres_error_head
Definition: isa.hh:113
MiscReg readMiscReg(int miscReg, ThreadContext *tc)
Definition: isa.cc:338
uint8_t gl
Definition: isa.hh:85
uint64_t res_error_head
Definition: isa.hh:111
HPSTATE hpstate
Hyperprivileged Registers.
Definition: isa.hh:88
CpuEventWrapper< ISA,&ISA::processHSTickCompare > HSTickCompareEvent
Definition: isa.hh:139
uint64_t cpu_mondo_head
Definition: isa.hh:107
static const int RegsPerWindow
Definition: isa.hh:147
void setMiscRegNoEffect(int miscReg, const MiscReg val)
Definition: isa.cc:386
HSTickCompareEvent * hSTickCompare
Definition: isa.hh:140
const Params * params() const
Definition: isa.cc:74
uint16_t secContext
Definition: isa.hh:101
static const int WindowOverlap
Definition: isa.hh:144
uint8_t fprs
Definition: isa.hh:58
uint64_t softint
Definition: isa.hh:60
const int MaxTL
Definition: sparc_traits.hh:38
std::ostream CheckpointOut
Definition: serialize.hh:67
MiscReg readMiscRegNoEffect(int miscReg) const
Definition: isa.cc:177
void startup(ThreadContext *tc)
Definition: isa.hh:173
STickCompareEvent * sTickCompare
Definition: isa.hh:136
const int NWindows
Definition: sparc_traits.hh:43
uint64_t MiscReg
Definition: registers.hh:48
uint64_t cpu_mondo_tail
Definition: isa.hh:108
uint64_t stick
Definition: isa.hh:62
const int NumMicroIntRegs
Definition: sparc_traits.hh:45
uint64_t res_error_tail
Definition: isa.hh:112
uint64_t strandStatusReg
Definition: isa.hh:94
void checkSoftInt(ThreadContext *tc)
Definition: ua2005.cc:46
uint64_t tick_cmpr
Definition: isa.hh:61
bool isNonPriv()
Definition: isa.hh:181
static const int TotalGlobals
Definition: isa.hh:146
static const int TotalWindowed
Definition: isa.hh:148
bool isPriv()
Definition: isa.hh:180
Bitfield< 0 > p
uint8_t tl
Definition: isa.hh:77
uint16_t priContext
MMU Internal Registers.
Definition: isa.hh:100
void clear()
Definition: isa.cc:114
uint16_t tt[MaxTL]
Definition: isa.hh:72
Abstract superclass for simulation objects.
Definition: sim_object.hh:94
SparcISAParams Params
Definition: isa.hh:221
int flattenMiscIndex(int reg) const
Definition: isa.hh:215
uint64_t hintp
Definition: isa.hh:90
ISA(Params *p)
Definition: isa.cc:63
void installWindow(int cwp, int offset)
Definition: isa.cc:94
uint64_t scratchPad[8]
Definition: isa.hh:105
uint64_t stick_cmpr
Definition: isa.hh:63
uint64_t gsr
Definition: isa.hh:59
virtual void startup()
startup() is the final initialization call before simulation.
Definition: sim_object.cc:97

Generated on Fri Jun 9 2017 13:03:35 for gem5 by doxygen 1.8.6