gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
85  dest->setMiscRegNoEffect(MISCREG_TL, tl);
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
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
Bitfield< 7 > i
virtual TheISA::PCState pcState() const =0
virtual RegVal readIntReg(RegIndex reg_idx) const =0
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
const int MaxGL
Definition: sparc_traits.hh:37
virtual PortProxy & getVirtProxy()=0
Bitfield< 0 > sp
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:282
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:132
MMU Internal Registers.
Definition: miscregs.hh:86
virtual void setFloatReg(RegIndex reg_idx, RegVal val)=0
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Bitfield< 3 > x
Definition: pagetable.hh:69
void copyRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:200
Bitfield< 23, 20 > tl
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
Definition: utility.cc:44
PortProxy Object Declaration.
virtual RegVal readFloatReg(RegIndex reg_idx) const =0
Hyper privileged registers.
Definition: miscregs.hh:74
const int NumFloatArchRegs
Definition: registers.hh:109
const int NumArgumentRegs
Definition: registers.hh:107
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Ancillary State Registers.
Definition: miscregs.hh:42
This object is a proxy for a port or other object which implements the functional response protocol...
Definition: port_proxy.hh:80
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
const int MaxTL
Definition: sparc_traits.hh:36
Definition: asi.cc:31
Privilged Registers.
Definition: miscregs.hh:56
Scratchpad regiscers.
Definition: miscregs.hh:92
const int NWindows
Definition: sparc_traits.hh:41
const int StackPointerReg
Definition: registers.hh:95
const int NumCCRegs
Definition: registers.hh:106
void copyMiscRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:64
Bitfield< 19, 16 > fp
Floating Point Status Register.
Definition: miscregs.hh:83

Generated on Thu May 28 2020 16:11:03 for gem5 by doxygen 1.8.13