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 "sim/faults.hh"
32 #include "config/full_system.hh"
33 #include "cpu/ozone/dyn_inst.hh"
36 #include "kern/kernel_stats.hh"
40 OzoneDynInst<Impl>::OzoneDynInst(OzoneCPU *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, OzoneCPU *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(PacketPtr pkt)
116 this->fault = this->staticInst->completeAcc(pkt, this, this->traceData);
121 template <class Impl>
123 OzoneDynInst<Impl>::srcInstReady(int regIdx)
125 return srcInsts[regIdx]->isResultReady();
128 template <class Impl>
130 OzoneDynInst<Impl>::addDependent(DynInstPtr &dependent_inst)
132 dependents.push_back(dependent_inst);
135 template <class Impl>
137 OzoneDynInst<Impl>::wakeDependents()
139 for (int i = 0; i < dependents.size(); ++i) {
140 dependents[i]->markSrcRegReady();
144 template <class Impl>
146 OzoneDynInst<Impl>::wakeMemDependents()
148 for (int i = 0; i < memDependents.size(); ++i) {
149 memDependents[i]->markMemInstReady(this);
153 template <class Impl>
155 OzoneDynInst<Impl>::markMemInstReady(OzoneDynInst<Impl> *inst)
157 ListIt mem_it = srcMemInsts.begin();
158 while ((*mem_it) != inst && mem_it != srcMemInsts.end()) {
161 assert(mem_it != srcMemInsts.end());
163 srcMemInsts.erase(mem_it);
166 template <class Impl>
168 OzoneDynInst<Impl>::initInstPtrs()
170 for (int i = 0; i < MaxInstSrcRegs; ++i) {
176 template <class Impl>
178 OzoneDynInst<Impl>::srcsReady()
180 for (int i = 0; i < this->numSrcRegs(); ++i) {
181 if (!srcInsts[i]->isResultReady())
188 template <class Impl>
190 OzoneDynInst<Impl>::eaSrcsReady()
192 for (int i = 1; i < this->numSrcRegs(); ++i) {
193 if (!srcInsts[i]->isResultReady())
200 template <class Impl>
202 OzoneDynInst<Impl>::clearDependents()
205 for (int i = 0; i < this->numSrcRegs(); ++i) {
208 for (int i = 0; i < this->numDestRegs(); ++i) {
209 prevDestInst[i] = NULL;
213 template <class Impl>
215 OzoneDynInst<Impl>::clearMemDependents()
217 memDependents.clear();
220 template <class Impl>
222 OzoneDynInst<Impl>::readMiscRegNoEffect(int misc_reg)
224 return this->thread->readMiscRegNoEffect(misc_reg);
227 template <class Impl>
229 OzoneDynInst<Impl>::readMiscReg(int misc_reg)
231 return this->thread->readMiscReg(misc_reg);
234 template <class Impl>
236 OzoneDynInst<Impl>::setMiscRegNoEffect(int misc_reg, const MiscReg &val)
238 this->setIntResult(val);
239 this->thread->setMiscRegNoEffect(misc_reg, val);
242 template <class Impl>
244 OzoneDynInst<Impl>::setMiscReg(int misc_reg, const MiscReg &val)
246 this->thread->setMiscReg(misc_reg, val);
251 template <class Impl>
253 OzoneDynInst<Impl>::hwrei()
255 if (!(this->readPC() & 0x3))
256 return new AlphaISA::UnimplementedOpcodeFault;
258 this->setNextPC(this->thread->readMiscRegNoEffect(AlphaISA::IPR_EXC_ADDR));
262 // FIXME: XXX check for interrupts? XXX
266 template <class Impl>
268 OzoneDynInst<Impl>::trap(Fault fault)
270 fault->invoke(this->thread->getTC());
273 template <class Impl>
275 OzoneDynInst<Impl>::simPalCheck(int palFunc)
277 return this->cpu->simPalCheck(palFunc);
280 template <class Impl>
282 OzoneDynInst<Impl>::syscall(uint64_t &callnum)
284 this->cpu->syscall(callnum);