gem5  v21.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 void
39 {
40 
41  uint8_t tl = src->readMiscRegNoEffect(MISCREG_TL);
42 
43  // Read all the trap level dependent registers and save them off
44  for (int i = 1; i <= MaxTL; i++) {
47 
56  }
57 
58  // Save off the traplevel
61 
62 
63  // ASRs
64 // dest->setMiscRegNoEffect(MISCREG_Y,
65 // src->readMiscRegNoEffect(MISCREG_Y));
66 // dest->setMiscRegNoEffect(MISCREG_CCR,
67 // src->readMiscRegNoEffect(MISCREG_CCR));
68  dest->setMiscReg(MISCREG_ASI,
82 
83  // Priv Registers
92  dest->setMiscReg(MISCREG_CWP,
94 // dest->setMiscRegNoEffect(MISCREG_CANSAVE,
95 // src->readMiscRegNoEffect(MISCREG_CANSAVE));
96 // dest->setMiscRegNoEffect(MISCREG_CANRESTORE,
97 // src->readMiscRegNoEffect(MISCREG_CANRESTORE));
98 // dest->setMiscRegNoEffect(MISCREG_OTHERWIN,
99 // src->readMiscRegNoEffect(MISCREG_OTHERWIN));
100 // dest->setMiscRegNoEffect(MISCREG_CLEANWIN,
101 // src->readMiscRegNoEffect(MISCREG_CLEANWIN));
102 // dest->setMiscRegNoEffect(MISCREG_WSTATE,
103 // src->readMiscRegNoEffect(MISCREG_WSTATE));
105 
106  // Hyperprivilged registers
117 
118  // FSR
121 
122  // Strand Status Register
125 
126  // MMU Registers
135 
136  // Scratchpad Registers
153 
154  // Queue Registers
171 }
172 
173 void
175 {
176  // First loop through the integer registers.
177  int old_gl = src->readMiscRegNoEffect(MISCREG_GL);
178  int old_cwp = src->readMiscRegNoEffect(MISCREG_CWP);
179  // Globals
180  for (int x = 0; x < MaxGL; ++x) {
181  src->setMiscReg(MISCREG_GL, x);
182  dest->setMiscReg(MISCREG_GL, x);
183  // Skip %g0 which is always zero.
184  for (int y = 1; y < 8; y++)
185  dest->setIntReg(y, src->readIntReg(y));
186  }
187  // Locals and ins. Outs are all also ins.
188  for (int x = 0; x < NWindows; ++x) {
189  src->setMiscReg(MISCREG_CWP, x);
190  dest->setMiscReg(MISCREG_CWP, x);
191  for (int y = 16; y < 32; y++)
192  dest->setIntReg(y, src->readIntReg(y));
193  }
194  // Microcode reg and pseudo int regs (misc regs in the integer regfile).
195  for (int y = NumIntArchRegs; y < NumIntArchRegs + NumMicroIntRegs; ++y)
196  dest->setIntReg(y, src->readIntReg(y));
197 
198  // Restore src's GL, CWP
199  src->setMiscReg(MISCREG_GL, old_gl);
200  src->setMiscReg(MISCREG_CWP, old_cwp);
201 
202 
203  // Then loop through the floating point registers.
204  for (int i = 0; i < SparcISA::NumFloatArchRegs; ++i) {
205  dest->setFloatReg(i, src->readFloatReg(i));
206  }
207 
208  // Would need to add condition-code regs if implemented
209  assert(NumCCRegs == 0);
210 
211  // Copy misc. registers
212  copyMiscRegs(src, dest);
213 
214  // Lastly copy PC/NPC
215  dest->pcState(src->pcState());
216 }
217 
218 } // 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:104
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:71
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::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:174
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
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:70
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
SparcISA::MISCREG_HSTICK_CMPR
@ MISCREG_HSTICK_CMPR
Definition: miscregs.hh:80
SparcISA::MISCREG_MMU_PART_ID
@ MISCREG_MMU_PART_ID
Definition: miscregs.hh:88
ThreadContext::pcState
virtual TheISA::PCState pcState() const =0
SparcISA::MISCREG_SCRATCHPAD_R0
@ MISCREG_SCRATCHPAD_R0
Scratchpad regiscers.
Definition: miscregs.hh:92
SparcISA::copyMiscRegs
void copyMiscRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:38
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
ThreadContext::setFloatReg
virtual void setFloatReg(RegIndex reg_idx, RegVal val)=0
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
SparcISA::NumMicroIntRegs
@ NumMicroIntRegs
Definition: registers.hh:83
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:101
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

Generated on Tue Mar 23 2021 19:41:20 for gem5 by doxygen 1.8.17