gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  * Authors: Gabe Black
29  * Ali Saidi
30  */
31 
32 #include "arch/sparc/utility.hh"
33 
34 #include "arch/sparc/faults.hh"
35 #include "arch/sparc/vtophys.hh"
37 
38 namespace SparcISA {
39 
40 
41 // The caller uses %o0-%05 for the first 6 arguments even if their floating
42 // point. Double precision floating point values take two registers/args.
43 // Quads, structs, and unions are passed as pointers. All arguments beyond
44 // the sixth are passed on the stack past the 16 word window save area,
45 // space for the struct/union return pointer, and space reserved for the
46 // first 6 arguments which the caller may use but doesn't have to.
47 uint64_t
48 getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
49 {
50  if (!FullSystem) {
51  panic("getArgument() only implemented for full system\n");
52  M5_DUMMY_RETURN
53  }
54 
55  const int NumArgumentRegs = 6;
56  if (number < NumArgumentRegs) {
57  return tc->readIntReg(8 + number);
58  } else {
61  uint64_t arg = vp.read<uint64_t>(sp + 92 +
62  (number-NumArgumentRegs) * sizeof(uint64_t));
63  return arg;
64  }
65 }
66 
67 void
69 {
70 
71  uint8_t tl = src->readMiscRegNoEffect(MISCREG_TL);
72 
73  // Read all the trap level dependent registers and save them off
74  for (int i = 1; i <= MaxTL; i++) {
77 
86  }
87 
88  // Save off the traplevel
89  dest->setMiscRegNoEffect(MISCREG_TL, tl);
91 
92 
93  // ASRs
94 // dest->setMiscRegNoEffect(MISCREG_Y,
95 // src->readMiscRegNoEffect(MISCREG_Y));
96 // dest->setMiscRegNoEffect(MISCREG_CCR,
97 // src->readMiscRegNoEffect(MISCREG_CCR));
98  dest->setMiscReg(MISCREG_ASI,
112 
113  // Priv Registers
122  dest->setMiscReg(MISCREG_CWP,
124 // dest->setMiscRegNoEffect(MISCREG_CANSAVE,
125 // src->readMiscRegNoEffect(MISCREG_CANSAVE));
126 // dest->setMiscRegNoEffect(MISCREG_CANRESTORE,
127 // src->readMiscRegNoEffect(MISCREG_CANRESTORE));
128 // dest->setMiscRegNoEffect(MISCREG_OTHERWIN,
129 // src->readMiscRegNoEffect(MISCREG_OTHERWIN));
130 // dest->setMiscRegNoEffect(MISCREG_CLEANWIN,
131 // src->readMiscRegNoEffect(MISCREG_CLEANWIN));
132 // dest->setMiscRegNoEffect(MISCREG_WSTATE,
133 // src->readMiscRegNoEffect(MISCREG_WSTATE));
135 
136  // Hyperprivilged registers
147 
148  // FSR
151 
152  // Strand Status Register
155 
156  // MMU Registers
165 
166  // Scratchpad Registers
183 
184  // Queue Registers
201 }
202 
203 void
205 {
206  // First loop through the integer registers.
207  int old_gl = src->readMiscRegNoEffect(MISCREG_GL);
208  int old_cwp = src->readMiscRegNoEffect(MISCREG_CWP);
209  // Globals
210  for (int x = 0; x < MaxGL; ++x) {
211  src->setMiscReg(MISCREG_GL, x);
212  dest->setMiscReg(MISCREG_GL, x);
213  // Skip %g0 which is always zero.
214  for (int y = 1; y < 8; y++)
215  dest->setIntReg(y, src->readIntReg(y));
216  }
217  // Locals and ins. Outs are all also ins.
218  for (int x = 0; x < NWindows; ++x) {
219  src->setMiscReg(MISCREG_CWP, x);
220  dest->setMiscReg(MISCREG_CWP, x);
221  for (int y = 16; y < 32; y++)
222  dest->setIntReg(y, src->readIntReg(y));
223  }
224  // Microcode reg and pseudo int regs (misc regs in the integer regfile).
225  for (int y = NumIntArchRegs; y < NumIntArchRegs + NumMicroIntRegs; ++y)
226  dest->setIntReg(y, src->readIntReg(y));
227 
228  // Restore src's GL, CWP
229  src->setMiscReg(MISCREG_GL, old_gl);
230  src->setMiscReg(MISCREG_CWP, old_cwp);
231 
232 
233  // Then loop through the floating point registers.
234  for (int i = 0; i < SparcISA::NumFloatArchRegs; ++i) {
235  dest->setFloatRegBits(i, src->readFloatRegBits(i));
236  }
237 
238  // Would need to add condition-code regs if implemented
239  assert(NumCCRegs == 0);
240 
241  // Copy misc. registers
242  copyMiscRegs(src, dest);
243 
244  // Lastly copy PC/NPC
245  dest->pcState(src->pcState());
246 }
247 
248 void
250 {
251  TheISA::PCState newPC = tc->pcState();
252  newPC.set(tc->readIntReg(ReturnAddressReg));
253  tc->pcState(newPC);
254 }
255 
256 
257 void
258 initCPU(ThreadContext *tc, int cpuId)
259 {
260  static Fault por = std::make_shared<PowerOnReset>();
261  if (cpuId == 0)
262  por->invoke(tc);
263 }
264 
265 } // namespace SPARC_ISA
A TranslatingPortProxy in FS mode translates a virtual address to a physical address and then calls t...
Bitfield< 7 > i
Definition: miscregs.hh:1378
#define panic(...)
Definition: misc.hh:153
const int MaxGL
Definition: sparc_traits.hh:39
Bitfield< 0 > fp
virtual MiscReg readMiscRegNoEffect(int misc_reg) const =0
Bitfield< 0 > sp
Definition: miscregs.hh:1386
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition: root.cc:146
virtual void setMiscReg(int misc_reg, const MiscReg &val)=0
virtual void setIntReg(int reg_idx, uint64_t val)=0
const int ReturnAddressReg
Definition: registers.hh:67
virtual FloatRegBits readFloatRegBits(int reg_idx)=0
virtual TheISA::PCState pcState()=0
MMU Internal Registers.
Definition: miscregs.hh:89
ThreadContext is the external interface to all thread state for anything outside of the CPU...
virtual void setFloatRegBits(int reg_idx, FloatRegBits val)=0
void skipFunction(ThreadContext *tc)
Definition: utility.cc:249
const int NumIntArchRegs
Definition: registers.hh:75
void copyRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:204
Bitfield< 23, 20 > tl
uint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
Definition: utility.cc:48
void initCPU(ThreadContext *tc, int cpuId)
Definition: utility.cc:258
virtual uint64_t readIntReg(int reg_idx)=0
Hyper privileged registers.
Definition: miscregs.hh:77
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:146
const int NumFloatArchRegs
Definition: sparc_traits.hh:51
const int NumArgumentRegs
Definition: registers.hh:95
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Ancillary State Registers.
Definition: miscregs.hh:45
virtual FSTranslatingPortProxy & getVirtProxy()=0
int size()
Definition: pagetable.hh:146
const int MaxTL
Definition: sparc_traits.hh:38
Privilged Registers.
Definition: miscregs.hh:59
Scratchpad regiscers.
Definition: miscregs.hh:95
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
const int NWindows
Definition: sparc_traits.hh:43
const int StackPointerReg
Definition: registers.hh:69
TranslatingPortProxy Object Declaration for FS.
const int NumMicroIntRegs
Definition: sparc_traits.hh:45
const int NumCCRegs
Definition: registers.hh:77
void copyMiscRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:68
virtual void setMiscRegNoEffect(int misc_reg, const MiscReg &val)=0
Bitfield< 1 > x
Definition: types.hh:105
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
Floating Point Status Register.
Definition: miscregs.hh:86

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