gem5  v20.1.0.0
utility.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2005 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 #include "arch/sparc/utility.hh"
30 
31 #include "arch/sparc/faults.hh"
32 #include "mem/port_proxy.hh"
33 
34 namespace SparcISA {
35 
36 
37 // The caller uses %o0-%05 for the first 6 arguments even if their floating
38 // point. Double precision floating point values take two registers/args.
39 // Quads, structs, and unions are passed as pointers. All arguments beyond
40 // the sixth are passed on the stack past the 16 word window save area,
41 // space for the struct/union return pointer, and space reserved for the
42 // first 6 arguments which the caller may use but doesn't have to.
43 uint64_t
44 getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
45 {
46  if (!FullSystem) {
47  panic("getArgument() only implemented for full system\n");
48  M5_DUMMY_RETURN
49  }
50 
51  const int NumArgumentRegs = 6;
52  if (number < NumArgumentRegs) {
53  return tc->readIntReg(8 + number);
54  } else {
56  PortProxy &vp = tc->getVirtProxy();
57  uint64_t arg = vp.read<uint64_t>(sp + 92 +
58  (number-NumArgumentRegs) * sizeof(uint64_t));
59  return arg;
60  }
61 }
62 
63 void
65 {
66 
67  uint8_t tl = src->readMiscRegNoEffect(MISCREG_TL);
68 
69  // Read all the trap level dependent registers and save them off
70  for (int i = 1; i <= MaxTL; i++) {
73 
82  }
83 
84  // Save off the traplevel
87 
88 
89  // ASRs
90 // dest->setMiscRegNoEffect(MISCREG_Y,
91 // src->readMiscRegNoEffect(MISCREG_Y));
92 // dest->setMiscRegNoEffect(MISCREG_CCR,
93 // src->readMiscRegNoEffect(MISCREG_CCR));
94  dest->setMiscReg(MISCREG_ASI,
108 
109  // Priv Registers
118  dest->setMiscReg(MISCREG_CWP,
120 // dest->setMiscRegNoEffect(MISCREG_CANSAVE,
121 // src->readMiscRegNoEffect(MISCREG_CANSAVE));
122 // dest->setMiscRegNoEffect(MISCREG_CANRESTORE,
123 // src->readMiscRegNoEffect(MISCREG_CANRESTORE));
124 // dest->setMiscRegNoEffect(MISCREG_OTHERWIN,
125 // src->readMiscRegNoEffect(MISCREG_OTHERWIN));
126 // dest->setMiscRegNoEffect(MISCREG_CLEANWIN,
127 // src->readMiscRegNoEffect(MISCREG_CLEANWIN));
128 // dest->setMiscRegNoEffect(MISCREG_WSTATE,
129 // src->readMiscRegNoEffect(MISCREG_WSTATE));
131 
132  // Hyperprivilged registers
143 
144  // FSR
147 
148  // Strand Status Register
151 
152  // MMU Registers
161 
162  // Scratchpad Registers
179 
180  // Queue Registers
197 }
198 
199 void
201 {
202  // First loop through the integer registers.
203  int old_gl = src->readMiscRegNoEffect(MISCREG_GL);
204  int old_cwp = src->readMiscRegNoEffect(MISCREG_CWP);
205  // Globals
206  for (int x = 0; x < MaxGL; ++x) {
207  src->setMiscReg(MISCREG_GL, x);
208  dest->setMiscReg(MISCREG_GL, x);
209  // Skip %g0 which is always zero.
210  for (int y = 1; y < 8; y++)
211  dest->setIntReg(y, src->readIntReg(y));
212  }
213  // Locals and ins. Outs are all also ins.
214  for (int x = 0; x < NWindows; ++x) {
215  src->setMiscReg(MISCREG_CWP, x);
216  dest->setMiscReg(MISCREG_CWP, x);
217  for (int y = 16; y < 32; y++)
218  dest->setIntReg(y, src->readIntReg(y));
219  }
220  // Microcode reg and pseudo int regs (misc regs in the integer regfile).
221  for (int y = NumIntArchRegs; y < NumIntArchRegs + NumMicroIntRegs; ++y)
222  dest->setIntReg(y, src->readIntReg(y));
223 
224  // Restore src's GL, CWP
225  src->setMiscReg(MISCREG_GL, old_gl);
226  src->setMiscReg(MISCREG_CWP, old_cwp);
227 
228 
229  // Then loop through the floating point registers.
230  for (int i = 0; i < SparcISA::NumFloatArchRegs; ++i) {
231  dest->setFloatReg(i, src->readFloatReg(i));
232  }
233 
234  // Would need to add condition-code regs if implemented
235  assert(NumCCRegs == 0);
236 
237  // Copy misc. registers
238  copyMiscRegs(src, dest);
239 
240  // Lastly copy PC/NPC
241  dest->pcState(src->pcState());
242 }
243 
244 } // namespace SPARC_ISA
ThreadContext::readMiscRegNoEffect
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
SparcISA::MISCREG_PSTATE
@ MISCREG_PSTATE
Definition: miscregs.hh:62
SparcISA::NumFloatArchRegs
const int NumFloatArchRegs
Definition: registers.hh:109
ArmISA::fp
Bitfield< 19, 16 > fp
Definition: miscregs_types.hh:173
SparcISA::MISCREG_TSTATE
@ MISCREG_TSTATE
Definition: miscregs.hh:58
SparcISA::MISCREG_QUEUE_CPU_MONDO_TAIL
@ MISCREG_QUEUE_CPU_MONDO_TAIL
Definition: miscregs.hh:103
SparcISA::MISCREG_TICK_CMPR
@ MISCREG_TICK_CMPR
Definition: miscregs.hh:51
SparcISA::MISCREG_PIL
@ MISCREG_PIL
Definition: miscregs.hh:64
SparcISA::MISCREG_SCRATCHPAD_R3
@ MISCREG_SCRATCHPAD_R3
Definition: miscregs.hh:95
SparcISA::MISCREG_HINTP
@ MISCREG_HINTP
Definition: miscregs.hh:76
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
SparcISA::MISCREG_SCRATCHPAD_R5
@ MISCREG_SCRATCHPAD_R5
Definition: miscregs.hh:97
SparcISA::MISCREG_SCRATCHPAD_R1
@ MISCREG_SCRATCHPAD_R1
Definition: miscregs.hh:93
SparcISA::NumIntArchRegs
@ NumIntArchRegs
Definition: registers.hh:76
ThreadContext::setIntReg
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
SparcISA::MISCREG_SOFTINT
@ MISCREG_SOFTINT
Definition: miscregs.hh:50
SparcISA::MISCREG_FSR
@ MISCREG_FSR
Floating Point Status Register.
Definition: miscregs.hh:83
SparcISA::MISCREG_QUEUE_DEV_MONDO_HEAD
@ MISCREG_QUEUE_DEV_MONDO_HEAD
Definition: miscregs.hh:104
SparcISA::NumMicroIntRegs
@ NumMicroIntRegs
Definition: registers.hh:88
FullSystem
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:132
SparcISA::MISCREG_TPC
@ MISCREG_TPC
Privilged Registers.
Definition: miscregs.hh:56
SparcISA::NWindows
const int NWindows
Definition: sparc_traits.hh:41
SparcISA::MISCREG_SCRATCHPAD_R6
@ MISCREG_SCRATCHPAD_R6
Definition: miscregs.hh:98
SparcISA::MISCREG_QUEUE_DEV_MONDO_TAIL
@ MISCREG_QUEUE_DEV_MONDO_TAIL
Definition: miscregs.hh:105
SparcISA
Definition: asi.cc:31
ThreadContext::readFloatReg
virtual RegVal readFloatReg(RegIndex reg_idx) const =0
SparcISA::MISCREG_GL
@ MISCREG_GL
Definition: miscregs.hh:71
SparcISA::copyRegs
void copyRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:200
SparcISA::MISCREG_TT
@ MISCREG_TT
Definition: miscregs.hh:59
SparcISA::MISCREG_TICK
@ MISCREG_TICK
Definition: miscregs.hh:43
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
SparcISA::MISCREG_QUEUE_NRES_ERROR_TAIL
@ MISCREG_QUEUE_NRES_ERROR_TAIL
Definition: miscregs.hh:109
faults.hh
SparcISA::MISCREG_TL
@ MISCREG_TL
Definition: miscregs.hh:63
port_proxy.hh
ArmISA::NumArgumentRegs
const int NumArgumentRegs
Definition: registers.hh:107
MipsISA::tl
Bitfield< 23, 20 > tl
Definition: pra_constants.hh:251
SparcISA::MISCREG_QUEUE_CPU_MONDO_HEAD
@ MISCREG_QUEUE_CPU_MONDO_HEAD
Definition: miscregs.hh:102
RiscvISA::x
Bitfield< 3 > x
Definition: pagetable.hh:69
SparcISA::MISCREG_QUEUE_RES_ERROR_HEAD
@ MISCREG_QUEUE_RES_ERROR_HEAD
Definition: miscregs.hh:106
SparcISA::MaxGL
const int MaxGL
Definition: sparc_traits.hh:37
SparcISA::MISCREG_MMU_LSU_CTRL
@ MISCREG_MMU_LSU_CTRL
Definition: miscregs.hh:89
SparcISA::MISCREG_STRAND_STS_REG
@ MISCREG_STRAND_STS_REG
Definition: miscregs.hh:79
SparcISA::MISCREG_STICK_CMPR
@ MISCREG_STICK_CMPR
Definition: miscregs.hh:53
ArmISA::sp
Bitfield< 0 > sp
Definition: miscregs_types.hh:71
SparcISA::MISCREG_HSTICK_CMPR
@ MISCREG_HSTICK_CMPR
Definition: miscregs.hh:80
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
SparcISA::MISCREG_MMU_PART_ID
@ MISCREG_MMU_PART_ID
Definition: miscregs.hh:88
SparcISA::getArgument
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
Definition: utility.cc:44
ThreadContext::pcState
virtual TheISA::PCState pcState() const =0
SparcISA::MISCREG_SCRATCHPAD_R0
@ MISCREG_SCRATCHPAD_R0
Scratchpad regiscers.
Definition: miscregs.hh:92
ThreadContext::getVirtProxy
virtual PortProxy & getVirtProxy()=0
SparcISA::copyMiscRegs
void copyMiscRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:64
SparcISA::MISCREG_HPSTATE
@ MISCREG_HPSTATE
Hyper privileged registers.
Definition: miscregs.hh:74
SparcISA::MISCREG_STICK
@ MISCREG_STICK
Definition: miscregs.hh:52
SparcISA::MISCREG_ASI
@ MISCREG_ASI
Ancillary State Registers.
Definition: miscregs.hh:42
PortProxy
This object is a proxy for a port or other object which implements the functional response protocol,...
Definition: port_proxy.hh:80
ThreadContext::setFloatReg
virtual void setFloatReg(RegIndex reg_idx, RegVal val)=0
PortProxy::read
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:282
SparcISA::MISCREG_SCRATCHPAD_R7
@ MISCREG_SCRATCHPAD_R7
Definition: miscregs.hh:99
SparcISA::MISCREG_QUEUE_NRES_ERROR_HEAD
@ MISCREG_QUEUE_NRES_ERROR_HEAD
Definition: miscregs.hh:108
SparcISA::MISCREG_HTBA
@ MISCREG_HTBA
Definition: miscregs.hh:77
ThreadContext::setMiscReg
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
utility.hh
SparcISA::MISCREG_QUEUE_RES_ERROR_TAIL
@ MISCREG_QUEUE_RES_ERROR_TAIL
Definition: miscregs.hh:107
SparcISA::MISCREG_SCRATCHPAD_R4
@ MISCREG_SCRATCHPAD_R4
Definition: miscregs.hh:96
ThreadContext::setMiscRegNoEffect
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
SparcISA::MISCREG_MMU_P_CONTEXT
@ MISCREG_MMU_P_CONTEXT
MMU Internal Registers.
Definition: miscregs.hh:86
ThreadContext::readIntReg
virtual RegVal readIntReg(RegIndex reg_idx) const =0
SparcISA::MISCREG_TNPC
@ MISCREG_TNPC
Definition: miscregs.hh:57
SparcISA::NumCCRegs
const int NumCCRegs
Definition: registers.hh:106
SparcISA::MISCREG_SCRATCHPAD_R2
@ MISCREG_SCRATCHPAD_R2
Definition: miscregs.hh:94
SparcISA::MISCREG_MMU_S_CONTEXT
@ MISCREG_MMU_S_CONTEXT
Definition: miscregs.hh:87
SparcISA::MISCREG_FPRS
@ MISCREG_FPRS
Definition: miscregs.hh:44
SparcISA::MISCREG_CWP
@ MISCREG_CWP
Definition: miscregs.hh:65
SparcISA::MISCREG_TBA
@ MISCREG_TBA
Definition: miscregs.hh:61
SparcISA::MaxTL
const int MaxTL
Definition: sparc_traits.hh:36
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
SparcISA::StackPointerReg
const int StackPointerReg
Definition: registers.hh:95

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