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.
29 #include "arch/faults.hh"
30 #include "arch/isa_traits.hh"
31 #include "config/full_system.hh"
32 #include "cpu/ozone/dyn_inst.hh"
33 #include "kern/kernel_stats.hh"
35 using namespace TheISA;
38 OzoneDynInst<Impl>::OzoneDynInst(FullCPU *cpu)
39 : BaseDynInst<Impl>(0, 0, 0, 0, cpu)
41 this->setResultReady();
47 OzoneDynInst<Impl>::OzoneDynInst(ExtMachInst inst, Addr PC, Addr Pred_PC,
48 InstSeqNum seq_num, FullCPU *cpu)
49 : BaseDynInst<Impl>(inst, PC, Pred_PC, seq_num, cpu)
55 OzoneDynInst<Impl>::OzoneDynInst(StaticInstPtr _staticInst)
56 : BaseDynInst<Impl>(_staticInst)
62 OzoneDynInst<Impl>::~OzoneDynInst()
64 DPRINTF(BE, "[sn:%lli] destructor called\n", this->seqNum);
65 for (int i = 0; i < this->numSrcRegs(); ++i) {
69 for (int i = 0; i < this->numDestRegs(); ++i) {
70 prevDestInst[i] = NULL;
78 OzoneDynInst<Impl>::execute()
80 // @todo: Pretty convoluted way to avoid squashing from happening when using
81 // the XC during an instruction's execution (specifically for instructions
82 // that have sideeffects that use the XC). Fix this.
83 bool in_syscall = this->thread->inSyscall;
84 this->thread->inSyscall = true;
86 this->fault = this->staticInst->execute(this, this->traceData);
88 this->thread->inSyscall = in_syscall;
95 OzoneDynInst<Impl>::initiateAcc()
97 // @todo: Pretty convoluted way to avoid squashing from happening when using
98 // the XC during an instruction's execution (specifically for instructions
99 // that have sideeffects that use the XC). Fix this.
100 bool in_syscall = this->thread->inSyscall;
101 this->thread->inSyscall = true;
103 this->fault = this->staticInst->initiateAcc(this, this->traceData);
105 this->thread->inSyscall = in_syscall;
110 template <class Impl>
112 OzoneDynInst<Impl>::completeAcc()
114 if (this->isLoad()) {
115 this->fault = this->staticInst->completeAcc(this->req->data,
118 } else if (this->isStore()) {
119 this->fault = this->staticInst->completeAcc((uint8_t*)&this->req->result,
123 panic("Unknown type!");
129 template <class Impl>
131 OzoneDynInst<Impl>::srcInstReady(int regIdx)
133 return srcInsts[regIdx]->isResultReady();
136 template <class Impl>
138 OzoneDynInst<Impl>::addDependent(DynInstPtr &dependent_inst)
140 dependents.push_back(dependent_inst);
143 template <class Impl>
145 OzoneDynInst<Impl>::wakeDependents()
147 for (int i = 0; i < dependents.size(); ++i) {
148 dependents[i]->markSrcRegReady();
152 template <class Impl>
154 OzoneDynInst<Impl>::wakeMemDependents()
156 for (int i = 0; i < memDependents.size(); ++i) {
157 memDependents[i]->markMemInstReady(this);
161 template <class Impl>
163 OzoneDynInst<Impl>::markMemInstReady(OzoneDynInst<Impl> *inst)
165 ListIt mem_it = srcMemInsts.begin();
166 while ((*mem_it) != inst && mem_it != srcMemInsts.end()) {
169 assert(mem_it != srcMemInsts.end());
171 srcMemInsts.erase(mem_it);
174 template <class Impl>
176 OzoneDynInst<Impl>::initInstPtrs()
178 for (int i = 0; i < MaxInstSrcRegs; ++i) {
184 template <class Impl>
186 OzoneDynInst<Impl>::srcsReady()
188 for (int i = 0; i < this->numSrcRegs(); ++i) {
189 if (!srcInsts[i]->isResultReady())
196 template <class Impl>
198 OzoneDynInst<Impl>::eaSrcsReady()
200 for (int i = 1; i < this->numSrcRegs(); ++i) {
201 if (!srcInsts[i]->isResultReady())
208 template <class Impl>
210 OzoneDynInst<Impl>::clearDependents()
213 for (int i = 0; i < this->numSrcRegs(); ++i) {
216 for (int i = 0; i < this->numDestRegs(); ++i) {
217 prevDestInst[i] = NULL;
221 template <class Impl>
223 OzoneDynInst<Impl>::clearMemDependents()
225 memDependents.clear();
228 template <class Impl>
230 OzoneDynInst<Impl>::readMiscReg(int misc_reg)
232 return this->thread->readMiscReg(misc_reg);
235 template <class Impl>
237 OzoneDynInst<Impl>::readMiscRegWithEffect(int misc_reg, Fault &fault)
239 return this->thread->readMiscRegWithEffect(misc_reg, fault);
242 template <class Impl>
244 OzoneDynInst<Impl>::setMiscReg(int misc_reg, const MiscReg &val)
246 this->setIntResult(val);
247 return this->thread->setMiscReg(misc_reg, val);
250 template <class Impl>
252 OzoneDynInst<Impl>::setMiscRegWithEffect(int misc_reg, const MiscReg &val)
254 return this->thread->setMiscRegWithEffect(misc_reg, val);
259 template <class Impl>
261 OzoneDynInst<Impl>::hwrei()
263 if (!this->cpu->inPalMode(this->readPC()))
264 return new AlphaISA::UnimplementedOpcodeFault;
266 this->setNextPC(this->thread->readMiscReg(AlphaISA::IPR_EXC_ADDR));
270 // FIXME: XXX check for interrupts? XXX
274 template <class Impl>
276 OzoneDynInst<Impl>::readIntrFlag()
278 return this->cpu->readIntrFlag();
281 template <class Impl>
283 OzoneDynInst<Impl>::setIntrFlag(int val)
285 this->cpu->setIntrFlag(val);
288 template <class Impl>
290 OzoneDynInst<Impl>::inPalMode()
292 return this->cpu->inPalMode();
295 template <class Impl>
297 OzoneDynInst<Impl>::trap(Fault fault)
299 fault->invoke(this->thread->getXCProxy());
302 template <class Impl>
304 OzoneDynInst<Impl>::simPalCheck(int palFunc)
306 return this->cpu->simPalCheck(palFunc);
309 template <class Impl>
311 OzoneDynInst<Impl>::syscall()
313 this->cpu->syscall();