2 * Copyright (c) 2007 MIPS Technologies, Inc.
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.
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.
28 * Authors: Korey Sewell
32 #include "arch/isa_traits.hh"
33 #include "config/the_isa.hh"
34 #include "cpu/exetrace.hh"
35 #include "cpu/inorder/thread_context.hh"
37 using namespace TheISA
;
42 InOrderThreadContext::getVirtPort()
44 return thread
->getVirtPort();
49 InOrderThreadContext::dumpFuncProfile()
51 thread
->dumpFuncProfile();
56 InOrderThreadContext::readLastActivate()
58 return thread
->lastActivate
;
63 InOrderThreadContext::readLastSuspend()
65 return thread
->lastSuspend
;
70 InOrderThreadContext::profileClear()
72 thread
->profileClear();
77 InOrderThreadContext::profileSample()
79 thread
->profileSample();
84 InOrderThreadContext::takeOverFrom(ThreadContext
*old_context
)
86 // some things should already be set up
87 assert(getSystemPtr() == old_context
->getSystemPtr());
89 assert(getProcessPtr() == old_context
->getProcessPtr());
94 // copy over functional state
95 setStatus(old_context
->status());
96 copyArchRegs(old_context
);
99 thread
->funcExeInst
= old_context
->readFuncExeInst();
102 old_context
->setStatus(ThreadContext::Halted
);
104 thread
->inSyscall
= false;
105 thread
->trapPending
= false;
109 InOrderThreadContext::activate(int delay
)
111 DPRINTF(InOrderCPU
, "Calling activate on Thread Context %d\n",
114 if (thread
->status() == ThreadContext::Active
)
117 thread
->setStatus(ThreadContext::Active
);
119 cpu
->activateContext(thread
->readTid(), delay
);
124 InOrderThreadContext::suspend(int delay
)
126 DPRINTF(InOrderCPU
, "Calling suspend on Thread Context %d\n",
129 if (thread
->status() == ThreadContext::Suspended
)
132 thread
->setStatus(ThreadContext::Suspended
);
133 cpu
->suspendContext(thread
->readTid(), delay
);
137 InOrderThreadContext::halt(int delay
)
139 DPRINTF(InOrderCPU
, "Calling halt on Thread Context %d\n",
142 if (thread
->status() == ThreadContext::Halted
)
145 thread
->setStatus(ThreadContext::Halted
);
146 cpu
->haltContext(thread
->readTid(), delay
);
151 InOrderThreadContext::regStats(const std::string
&name
)
154 //thread->kernelStats = new Kernel::Statistics(cpu->system);
155 //thread->kernelStats->regStats(name + ".kern");
162 InOrderThreadContext::serialize(std::ostream
&os
)
164 panic("serialize unimplemented");
169 InOrderThreadContext::unserialize(Checkpoint
*cp
, const std::string
§ion
)
171 panic("unserialize unimplemented");
175 InOrderThreadContext:: getInst()
177 return thread
->getInst();
182 InOrderThreadContext::copyArchRegs(ThreadContext
*src_tc
)
184 TheISA::copyRegs(src_tc
, this);
189 InOrderThreadContext::clearArchRegs()
194 InOrderThreadContext::readIntReg(int reg_idx
)
196 return cpu
->readIntReg(reg_idx
, thread
->readTid());
200 InOrderThreadContext::readFloatReg(int reg_idx
)
202 return cpu
->readFloatReg(reg_idx
, thread
->readTid());
206 InOrderThreadContext::readFloatRegBits(int reg_idx
)
208 return cpu
->readFloatRegBits(reg_idx
, thread
->readTid());
212 InOrderThreadContext::readRegOtherThread(int reg_idx
, ThreadID tid
)
214 return cpu
->readRegOtherThread(reg_idx
, tid
);
218 InOrderThreadContext::setIntReg(int reg_idx
, uint64_t val
)
220 cpu
->setIntReg(reg_idx
, val
, thread
->readTid());
224 InOrderThreadContext::setFloatReg(int reg_idx
, FloatReg val
)
226 cpu
->setFloatReg(reg_idx
, val
, thread
->readTid());
230 InOrderThreadContext::setFloatRegBits(int reg_idx
, FloatRegBits val
)
232 cpu
->setFloatRegBits(reg_idx
, val
, thread
->readTid());
236 InOrderThreadContext::setRegOtherThread(int misc_reg
, const MiscReg
&val
,
239 cpu
->setRegOtherThread(misc_reg
, val
, tid
);
243 InOrderThreadContext::setPC(uint64_t val
)
245 DPRINTF(InOrderCPU
, "[tid:%i] Setting PC to %08p\n", thread
->readTid(), val
);
246 cpu
->setPC(val
, thread
->readTid());
250 InOrderThreadContext::setNextPC(uint64_t val
)
252 DPRINTF(InOrderCPU
, "[tid:%i] Setting NPC to %08p\n", thread
->readTid(), val
);
253 cpu
->setNextPC(val
, thread
->readTid());
257 InOrderThreadContext::setNextNPC(uint64_t val
)
259 DPRINTF(InOrderCPU
, "[tid:%i] Setting NNPC to %08p\n", thread
->readTid(), val
);
260 cpu
->setNextNPC(val
, thread
->readTid());
264 InOrderThreadContext::setMiscRegNoEffect(int misc_reg
, const MiscReg
&val
)
266 cpu
->setMiscRegNoEffect(misc_reg
, val
, thread
->readTid());
270 InOrderThreadContext::setMiscReg(int misc_reg
, const MiscReg
&val
)
272 cpu
->setMiscReg(misc_reg
, val
, thread
->readTid());