gem5  v22.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/pcstate.hh"
37 #include "arch/sparc/regs/float.hh"
38 #include "arch/sparc/regs/int.hh"
39 #include "arch/sparc/regs/misc.hh"
41 #include "arch/sparc/types.hh"
42 #include "cpu/reg_class.hh"
43 #include "sim/sim_object.hh"
44 
45 namespace gem5
46 {
47 
48 class Checkpoint;
49 class EventManager;
50 struct SparcISAParams;
51 class ThreadContext;
52 
53 namespace SparcISA
54 {
55 class ISA : public BaseISA
56 {
57  private:
58 
59  /* ASR Registers */
60  // uint64_t y; // Y (used in obsolete multiplication)
61  // uint8_t ccr; // Condition Code Register
62  uint8_t asi; // Address Space Identifier
63  uint64_t tick; // Hardware clock-tick counter
64  uint8_t fprs; // Floating-Point Register State
65  uint64_t gsr; // General Status Register
66  uint64_t softint;
67  uint64_t tick_cmpr; // Hardware tick compare registers
68  uint64_t stick; // Hardware clock-tick counter
69  uint64_t stick_cmpr; // Hardware tick compare registers
70 
71 
72  /* Privileged Registers */
73  uint64_t tpc[MaxTL]; // Trap Program Counter (value from
74  // previous trap level)
75  uint64_t tnpc[MaxTL]; // Trap Next Program Counter (value from
76  // previous trap level)
77  uint64_t tstate[MaxTL]; // Trap State
78  uint16_t tt[MaxTL]; // Trap Type (Type of trap which occured
79  // on the previous level)
80  uint64_t tba; // Trap Base Address
81 
82  PSTATE pstate; // Process State Register
83  uint8_t tl; // Trap Level
84  uint8_t pil; // Process Interrupt Register
85  uint8_t cwp; // Current Window Pointer
86  // uint8_t cansave; // Savable windows
87  // uint8_t canrestore; // Restorable windows
88  // uint8_t cleanwin; // Clean windows
89  // uint8_t otherwin; // Other windows
90  // uint8_t wstate; // Window State
91  uint8_t gl; // Global level register
92 
94  HPSTATE hpstate; // Hyperprivileged State Register
95  uint64_t htstate[MaxTL];// Hyperprivileged Trap State Register
96  uint64_t hintp;
97  uint64_t htba; // Hyperprivileged Trap Base Address register
98  uint64_t hstick_cmpr; // Hardware tick compare registers
99 
100  uint64_t strandStatusReg;// Per strand status register
101 
103  uint64_t fsr; // Floating-Point State Register
104 
106  uint16_t priContext;
107  uint16_t secContext;
108  uint16_t partId;
109  uint64_t lsuCtrlReg;
110 
111  uint64_t scratchPad[8];
112 
113  uint64_t cpu_mondo_head;
114  uint64_t cpu_mondo_tail;
115  uint64_t dev_mondo_head;
116  uint64_t dev_mondo_tail;
117  uint64_t res_error_head;
118  uint64_t res_error_tail;
119  uint64_t nres_error_head;
120  uint64_t nres_error_tail;
121 
122  // These need to check the int_dis field and if 0 then
123  // set appropriate bit in softint and checkinterrutps on the cpu
124  void setFSReg(int miscReg, RegVal val);
125  RegVal readFSReg(int miscReg);
126 
127  // Update interrupt state on softint or pil change
128  void checkSoftInt();
129 
132  void processTickCompare();
133  void processSTickCompare();
134  void processHSTickCompare();
135 
138 
141 
144 
145  static const int NumGlobalRegs = 8;
146  static const int NumWindowedRegs = 24;
147  static const int WindowOverlap = 8;
148 
149  static const int TotalGlobals = (MaxGL + 1) * NumGlobalRegs;
151  static const int TotalWindowed = NWindows * RegsPerWindow;
152 
154  {
163  };
164 
166  void installWindow(int cwp, int offset);
167  void installGlobals(int gl, int offset);
168  void reloadRegMap();
169 
170  public:
171  const RegIndex &mapIntRegId(RegIndex idx) const { return intRegMap[idx]; }
172 
173  void clear() override;
174 
175  PCStateBase *
176  newPCState(Addr new_inst_addr=0) const override
177  {
178  return new PCState(new_inst_addr);
179  }
180 
181  void serialize(CheckpointOut &cp) const override;
182  void unserialize(CheckpointIn &cp) override;
183 
184  protected:
185  bool isHyperPriv() { return hpstate.hpriv; }
186  bool isPriv() { return hpstate.hpriv || pstate.priv; }
187  bool isNonPriv() { return !isPriv(); }
188 
189  public:
190 
191  RegVal readMiscRegNoEffect(RegIndex idx) const override;
192  RegVal readMiscReg(RegIndex idx) override;
193 
194  void setMiscRegNoEffect(RegIndex idx, RegVal val) override;
195  void setMiscReg(RegIndex idx, RegVal val) override;
196 
197  uint64_t
198  getExecutingAsid() const override
199  {
201  }
202 
203  using Params = SparcISAParams;
204 
205  bool
206  inUserMode() const override
207  {
210  return !(pstate.priv || hpstate.hpriv);
211  }
212 
213  void copyRegsFrom(ThreadContext *src) override;
214 
215  ISA(const Params &p);
216 };
217 
218 } // namespace SparcISA
219 } // namespace gem5
220 
221 #endif
void reloadRegMap()
Definition: isa.cc:279
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:897
void installWindow(int cwp, int offset)
Definition: isa.cc:293
const RegIndex & mapIntRegId(RegIndex idx) const
Definition: isa.hh:171
static const int RegsPerWindow
Definition: isa.hh:150
uint64_t softint
Definition: isa.hh:66
ISA(const Params &p)
Definition: isa.cc:80
uint64_t dev_mondo_head
Definition: isa.hh:115
STickCompareEvent * sTickCompare
Definition: isa.hh:140
uint64_t tstate[MaxTL]
Definition: isa.hh:77
@ PreviousWindowOffset
Definition: isa.hh:161
@ CurrentGlobalsOffset
Definition: isa.hh:155
@ PreviousGlobalsOffset
Definition: isa.hh:160
uint64_t cpu_mondo_head
Definition: isa.hh:113
uint16_t priContext
MMU Internal Registers.
Definition: isa.hh:106
void copyRegsFrom(ThreadContext *src) override
Definition: isa.cc:229
static const int NumWindowedRegs
Definition: isa.hh:146
static const int WindowOverlap
Definition: isa.hh:147
uint8_t fprs
Definition: isa.hh:64
uint64_t res_error_head
Definition: isa.hh:117
uint64_t fsr
Floating point misc registers.
Definition: isa.hh:103
static const int TotalGlobals
Definition: isa.hh:149
bool isNonPriv()
Definition: isa.hh:187
void setMiscReg(RegIndex idx, RegVal val) override
Definition: isa.cc:766
TickCompareEvent * tickCompare
Definition: isa.hh:137
uint8_t asi
Definition: isa.hh:62
uint8_t pil
Definition: isa.hh:84
RegVal readMiscReg(RegIndex idx) override
Definition: isa.cc:537
SparcISAParams Params
Definition: isa.hh:203
RegIndex intRegMap[TotalInstIntRegs]
Definition: isa.hh:165
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:842
uint64_t strandStatusReg
Definition: isa.hh:100
uint64_t tick
Definition: isa.hh:63
uint64_t dev_mondo_tail
Definition: isa.hh:116
bool isHyperPriv()
Definition: isa.hh:185
uint64_t scratchPad[8]
Definition: isa.hh:111
HSTickCompareEvent * hSTickCompare
Definition: isa.hh:143
void checkSoftInt()
Definition: ua2005.cc:47
bool inUserMode() const override
Definition: isa.hh:206
uint16_t partId
Definition: isa.hh:108
uint64_t cpu_mondo_tail
Definition: isa.hh:114
EventWrapper< ISA, &ISA::processSTickCompare > STickCompareEvent
Definition: isa.hh:139
PCStateBase * newPCState(Addr new_inst_addr=0) const override
Definition: isa.hh:176
static const int TotalWindowed
Definition: isa.hh:151
uint8_t cwp
Definition: isa.hh:85
uint16_t tt[MaxTL]
Definition: isa.hh:78
uint64_t gsr
Definition: isa.hh:65
uint64_t hintp
Definition: isa.hh:96
HPSTATE hpstate
Hyperprivileged Registers.
Definition: isa.hh:94
static const int NumGlobalRegs
Definition: isa.hh:145
uint64_t nres_error_head
Definition: isa.hh:119
uint64_t tpc[MaxTL]
Definition: isa.hh:73
uint64_t htba
Definition: isa.hh:97
uint64_t getExecutingAsid() const override
Definition: isa.hh:198
void setFSReg(int miscReg, RegVal val)
Definition: ua2005.cc:92
uint64_t nres_error_tail
Definition: isa.hh:120
PSTATE pstate
Definition: isa.hh:82
void processHSTickCompare()
Definition: ua2005.cc:352
uint64_t stick
Definition: isa.hh:68
uint64_t tick_cmpr
Definition: isa.hh:67
RegVal readMiscRegNoEffect(RegIndex idx) const override
Definition: isa.cc:376
uint64_t res_error_tail
Definition: isa.hh:118
uint8_t gl
Definition: isa.hh:91
uint8_t tl
Definition: isa.hh:83
uint64_t hstick_cmpr
Definition: isa.hh:98
uint64_t stick_cmpr
Definition: isa.hh:69
uint64_t tnpc[MaxTL]
Definition: isa.hh:75
EventWrapper< ISA, &ISA::processHSTickCompare > HSTickCompareEvent
Definition: isa.hh:142
uint64_t tba
Definition: isa.hh:80
void installGlobals(int gl, int offset)
Definition: isa.cc:303
void processSTickCompare()
Definition: ua2005.cc:328
void processTickCompare()
Process a tick compare event and generate an interrupt on the cpu if appropriate.
Definition: ua2005.cc:322
uint16_t secContext
Definition: isa.hh:107
uint64_t lsuCtrlReg
Definition: isa.hh:109
RegVal readFSReg(int miscReg)
Definition: ua2005.cc:248
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
Definition: isa.cc:585
void clear() override
Definition: isa.cc:313
uint64_t htstate[MaxTL]
Definition: isa.hh:95
EventWrapper< ISA, &ISA::processTickCompare > TickCompareEvent
Definition: isa.hh:136
bool isPriv()
Definition: isa.hh:186
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Bitfield< 23, 0 > offset
Definition: types.hh:144
@ MISCREG_HPSTATE
Hyper privileged registers.
Definition: misc.hh:79
@ MISCREG_PSTATE
Definition: misc.hh:67
@ MISCREG_MMU_P_CONTEXT
MMU Internal Registers.
Definition: misc.hh:91
const int NWindows
Definition: sparc_traits.hh:44
GenericISA::DelaySlotUPCState< 4 > PCState
Definition: pcstate.hh:40
const int MaxGL
Definition: sparc_traits.hh:40
const int MaxTL
Definition: sparc_traits.hh:39
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 63 > val
Definition: misc.hh:776
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint16_t RegIndex
Definition: types.hh:176
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t RegVal
Definition: types.hh:173

Generated on Wed Dec 21 2022 10:22:24 for gem5 by doxygen 1.9.1