2 * Copyright (c) 2006 The Regents of The University of Michigan
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.
29 #ifndef __CPU_CHECKER_EXEC_CONTEXT_HH__
30 #define __CPU_CHECKER_EXEC_CONTEXT_HH__
32 #include "cpu/checker/cpu.hh"
33 #include "cpu/cpu_exec_context.hh"
34 #include "cpu/thread_context.hh"
36 class EndQuiesceEvent;
42 * Derived ThreadContext class for use with the Checker. The template
43 * parameter is the ThreadContext class used by the specific CPU being
44 * verified. This CheckerThreadContext is then used by the main CPU in
45 * place of its usual ThreadContext class. It handles updating the
46 * checker's state any time state is updated through the ThreadContext.
49 class CheckerThreadContext : public ThreadContext
52 CheckerThreadContext(TC *actual_tc,
53 CheckerCPU *checker_cpu)
54 : actualTC(actual_tc), checkerTC(checker_cpu->cpuXC),
55 checkerCPU(checker_cpu)
60 CPUExecContext *checkerTC;
61 CheckerCPU *checkerCPU;
65 BaseCPU *getCpuPtr() { return actualTC->getCpuPtr(); }
69 actualTC->setCpuId(id);
70 checkerTC->setCpuId(id);
73 int readCpuId() { return actualTC->readCpuId(); }
75 TranslatingPort *getMemPort() { return actualTC->getMemPort(); }
78 System *getSystemPtr() { return actualTC->getSystemPtr(); }
80 PhysicalMemory *getPhysMemPtr() { return actualTC->getPhysMemPtr(); }
82 AlphaITB *getITBPtr() { return actualTC->getITBPtr(); }
84 AlphaDTB *getDTBPtr() { return actualTC->getDTBPtr(); }
86 Kernel::Statistics *getKernelStats() { return actualTC->getKernelStats(); }
88 Process *getProcessPtr() { return actualTC->getProcessPtr(); }
91 Status status() const { return actualTC->status(); }
93 void setStatus(Status new_status)
95 actualTC->setStatus(new_status);
96 checkerTC->setStatus(new_status);
99 /// Set the status to Active. Optional delay indicates number of
100 /// cycles to wait before beginning execution.
101 void activate(int delay = 1) { actualTC->activate(delay); }
103 /// Set the status to Suspended.
104 void suspend() { actualTC->suspend(); }
106 /// Set the status to Unallocated.
107 void deallocate() { actualTC->deallocate(); }
109 /// Set the status to Halted.
110 void halt() { actualTC->halt(); }
113 void dumpFuncProfile() { actualTC->dumpFuncProfile(); }
116 void takeOverFrom(ThreadContext *oldContext)
118 actualTC->takeOverFrom(oldContext);
119 checkerTC->takeOverFrom(oldContext);
122 void regStats(const std::string &name) { actualTC->regStats(name); }
124 void serialize(std::ostream &os) { actualTC->serialize(os); }
125 void unserialize(Checkpoint *cp, const std::string §ion)
126 { actualTC->unserialize(cp, section); }
129 EndQuiesceEvent *getQuiesceEvent() { return actualTC->getQuiesceEvent(); }
131 Tick readLastActivate() { return actualTC->readLastActivate(); }
132 Tick readLastSuspend() { return actualTC->readLastSuspend(); }
134 void profileClear() { return actualTC->profileClear(); }
135 void profileSample() { return actualTC->profileSample(); }
138 int getThreadNum() { return actualTC->getThreadNum(); }
140 // @todo: Do I need this?
141 MachInst getInst() { return actualTC->getInst(); }
143 // @todo: Do I need this?
144 void copyArchRegs(ThreadContext *tc)
146 actualTC->copyArchRegs(tc);
147 checkerTC->copyArchRegs(tc);
152 actualTC->clearArchRegs();
153 checkerTC->clearArchRegs();
157 // New accessors for new decoder.
159 uint64_t readIntReg(int reg_idx)
160 { return actualTC->readIntReg(reg_idx); }
162 FloatReg readFloatReg(int reg_idx, int width)
163 { return actualTC->readFloatReg(reg_idx, width); }
165 FloatReg readFloatReg(int reg_idx)
166 { return actualTC->readFloatReg(reg_idx); }
168 FloatRegBits readFloatRegBits(int reg_idx, int width)
169 { return actualTC->readFloatRegBits(reg_idx, width); }
171 FloatRegBits readFloatRegBits(int reg_idx)
172 { return actualTC->readFloatRegBits(reg_idx); }
174 void setIntReg(int reg_idx, uint64_t val)
176 actualTC->setIntReg(reg_idx, val);
177 checkerTC->setIntReg(reg_idx, val);
180 void setFloatReg(int reg_idx, FloatReg val, int width)
182 actualTC->setFloatReg(reg_idx, val, width);
183 checkerTC->setFloatReg(reg_idx, val, width);
186 void setFloatReg(int reg_idx, FloatReg val)
188 actualTC->setFloatReg(reg_idx, val);
189 checkerTC->setFloatReg(reg_idx, val);
192 void setFloatRegBits(int reg_idx, FloatRegBits val, int width)
194 actualTC->setFloatRegBits(reg_idx, val, width);
195 checkerTC->setFloatRegBits(reg_idx, val, width);
198 void setFloatRegBits(int reg_idx, FloatRegBits val)
200 actualTC->setFloatRegBits(reg_idx, val);
201 checkerTC->setFloatRegBits(reg_idx, val);
204 uint64_t readPC() { return actualTC->readPC(); }
206 void setPC(uint64_t val)
208 actualTC->setPC(val);
209 checkerTC->setPC(val);
210 checkerCPU->recordPCChange(val);
213 uint64_t readNextPC() { return actualTC->readNextPC(); }
215 void setNextPC(uint64_t val)
217 actualTC->setNextPC(val);
218 checkerTC->setNextPC(val);
219 checkerCPU->recordNextPCChange(val);
222 uint64_t readNextNPC() { return actualTC->readNextNPC(); }
224 void setNextNPC(uint64_t val)
226 actualTC->setNextNPC(val);
227 checkerTC->setNextNPC(val);
228 checkerCPU->recordNextPCChange(val);
231 MiscReg readMiscReg(int misc_reg)
232 { return actualTC->readMiscReg(misc_reg); }
234 MiscReg readMiscRegWithEffect(int misc_reg, Fault &fault)
235 { return actualTC->readMiscRegWithEffect(misc_reg, fault); }
237 Fault setMiscReg(int misc_reg, const MiscReg &val)
239 checkerTC->setMiscReg(misc_reg, val);
240 return actualTC->setMiscReg(misc_reg, val);
243 Fault setMiscRegWithEffect(int misc_reg, const MiscReg &val)
245 checkerTC->setMiscRegWithEffect(misc_reg, val);
246 return actualTC->setMiscRegWithEffect(misc_reg, val);
249 unsigned readStCondFailures()
250 { return actualTC->readStCondFailures(); }
252 void setStCondFailures(unsigned sc_failures)
254 checkerTC->setStCondFailures(sc_failures);
255 actualTC->setStCondFailures(sc_failures);
258 bool inPalMode() { return actualTC->inPalMode(); }
262 bool misspeculating() { return actualTC->misspeculating(); }
265 IntReg getSyscallArg(int i) { return actualTC->getSyscallArg(i); }
267 // used to shift args for indirect syscall
268 void setSyscallArg(int i, IntReg val)
270 checkerTC->setSyscallArg(i, val);
271 actualTC->setSyscallArg(i, val);
274 void setSyscallReturn(SyscallReturn return_value)
276 checkerTC->setSyscallReturn(return_value);
277 actualTC->setSyscallReturn(return_value);
280 Counter readFuncExeInst() { return actualTC->readFuncExeInst(); }
282 void changeRegFileContext(RegFile::ContextParam param,
283 RegFile::ContextVal val)
285 actualTC->changeRegFileContext(param, val);
286 checkerTC->changeRegFileContext(param, val);
290 #endif // __CPU_CHECKER_EXEC_CONTEXT_HH__