2 * Copyright (c) 2005-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.
31 #include "arch/faults.hh"
32 #include "arch/isa_traits.hh"
33 #include "config/full_system.hh"
34 #include "cpu/ozone/dyn_inst.hh"
35 #include "kern/kernel_stats.hh"
37 using namespace TheISA;
40 OzoneDynInst<Impl>::OzoneDynInst(FullCPU *cpu)
41 : BaseDynInst<Impl>(0, 0, 0, 0, cpu)
43 this->setResultReady();
49 OzoneDynInst<Impl>::OzoneDynInst(ExtMachInst inst, Addr PC, Addr Pred_PC,
50 InstSeqNum seq_num, FullCPU *cpu)
51 : BaseDynInst<Impl>(inst, PC, Pred_PC, seq_num, cpu)
57 OzoneDynInst<Impl>::OzoneDynInst(StaticInstPtr _staticInst)
58 : BaseDynInst<Impl>(_staticInst)
64 OzoneDynInst<Impl>::~OzoneDynInst()
66 DPRINTF(BE, "[sn:%lli] destructor called\n", this->seqNum);
67 for (int i = 0; i < this->numSrcRegs(); ++i) {
71 for (int i = 0; i < this->numDestRegs(); ++i) {
72 prevDestInst[i] = NULL;
80 OzoneDynInst<Impl>::execute()
82 // @todo: Pretty convoluted way to avoid squashing from happening when using
83 // the XC during an instruction's execution (specifically for instructions
84 // that have sideeffects that use the XC). Fix this.
85 bool in_syscall = this->thread->inSyscall;
86 this->thread->inSyscall = true;
88 this->fault = this->staticInst->execute(this, this->traceData);
90 this->thread->inSyscall = in_syscall;
97 OzoneDynInst<Impl>::initiateAcc()
99 // @todo: Pretty convoluted way to avoid squashing from happening when using
100 // the XC during an instruction's execution (specifically for instructions
101 // that have sideeffects that use the XC). Fix this.
102 bool in_syscall = this->thread->inSyscall;
103 this->thread->inSyscall = true;
105 this->fault = this->staticInst->initiateAcc(this, this->traceData);
107 this->thread->inSyscall = in_syscall;
112 template <class Impl>
114 OzoneDynInst<Impl>::completeAcc()
116 if (this->isLoad()) {
117 this->fault = this->staticInst->completeAcc(this->req->data,
120 } else if (this->isStore()) {
121 this->fault = this->staticInst->completeAcc((uint8_t*)&this->req->result,
125 panic("Unknown type!");
131 template <class Impl>
133 OzoneDynInst<Impl>::srcInstReady(int regIdx)
135 return srcInsts[regIdx]->isResultReady();
138 template <class Impl>
140 OzoneDynInst<Impl>::addDependent(DynInstPtr &dependent_inst)
142 dependents.push_back(dependent_inst);
145 template <class Impl>
147 OzoneDynInst<Impl>::wakeDependents()
149 for (int i = 0; i < dependents.size(); ++i) {
150 dependents[i]->markSrcRegReady();
154 template <class Impl>
156 OzoneDynInst<Impl>::wakeMemDependents()
158 for (int i = 0; i < memDependents.size(); ++i) {
159 memDependents[i]->markMemInstReady(this);
163 template <class Impl>
165 OzoneDynInst<Impl>::markMemInstReady(OzoneDynInst<Impl> *inst)
167 ListIt mem_it = srcMemInsts.begin();
168 while ((*mem_it) != inst && mem_it != srcMemInsts.end()) {
171 assert(mem_it != srcMemInsts.end());
173 srcMemInsts.erase(mem_it);
176 template <class Impl>
178 OzoneDynInst<Impl>::initInstPtrs()
180 for (int i = 0; i < MaxInstSrcRegs; ++i) {
186 template <class Impl>
188 OzoneDynInst<Impl>::srcsReady()
190 for (int i = 0; i < this->numSrcRegs(); ++i) {
191 if (!srcInsts[i]->isResultReady())
198 template <class Impl>
200 OzoneDynInst<Impl>::eaSrcsReady()
202 for (int i = 1; i < this->numSrcRegs(); ++i) {
203 if (!srcInsts[i]->isResultReady())
210 template <class Impl>
212 OzoneDynInst<Impl>::clearDependents()
215 for (int i = 0; i < this->numSrcRegs(); ++i) {
218 for (int i = 0; i < this->numDestRegs(); ++i) {
219 prevDestInst[i] = NULL;
223 template <class Impl>
225 OzoneDynInst<Impl>::clearMemDependents()
227 memDependents.clear();
230 template <class Impl>
232 OzoneDynInst<Impl>::readMiscReg(int misc_reg)
234 return this->thread->readMiscReg(misc_reg);
237 template <class Impl>
239 OzoneDynInst<Impl>::readMiscRegWithEffect(int misc_reg, Fault &fault)
241 return this->thread->readMiscRegWithEffect(misc_reg, fault);
244 template <class Impl>
246 OzoneDynInst<Impl>::setMiscReg(int misc_reg, const MiscReg &val)
248 this->setIntResult(val);
249 return this->thread->setMiscReg(misc_reg, val);
252 template <class Impl>
254 OzoneDynInst<Impl>::setMiscRegWithEffect(int misc_reg, const MiscReg &val)
256 return this->thread->setMiscRegWithEffect(misc_reg, val);
261 template <class Impl>
263 OzoneDynInst<Impl>::hwrei()
265 if (!this->cpu->inPalMode(this->readPC()))
266 return new AlphaISA::UnimplementedOpcodeFault;
268 this->setNextPC(this->thread->readMiscReg(AlphaISA::IPR_EXC_ADDR));
272 // FIXME: XXX check for interrupts? XXX
276 template <class Impl>
278 OzoneDynInst<Impl>::readIntrFlag()
280 return this->cpu->readIntrFlag();
283 template <class Impl>
285 OzoneDynInst<Impl>::setIntrFlag(int val)
287 this->cpu->setIntrFlag(val);
290 template <class Impl>
292 OzoneDynInst<Impl>::inPalMode()
294 return this->cpu->inPalMode();
297 template <class Impl>
299 OzoneDynInst<Impl>::trap(Fault fault)
301 fault->invoke(this->thread->getXCProxy());
304 template <class Impl>
306 OzoneDynInst<Impl>::simPalCheck(int palFunc)
308 return this->cpu->simPalCheck(palFunc);
311 template <class Impl>
313 OzoneDynInst<Impl>::syscall()
315 this->cpu->syscall();