2 * Copyright (c) 2004-2005 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 // Todo: Find all the stuff in ExecContext and ev5 that needs to be
30 // specifically designed for this CPU.
32 #ifndef __CPU_O3_CPU_ALPHA_FULL_CPU_HH__
33 #define __CPU_O3_CPU_ALPHA_FULL_CPU_HH__
35 #include "cpu/o3/cpu.hh"
36 #include "arch/isa_traits.hh"
37 #include "sim/byteswap.hh"
40 class AlphaFullCPU : public FullO3CPU<Impl>
43 typedef TheISA::IntReg IntReg;
45 typedef typename Impl::Params Params;
48 AlphaFullCPU(Params ¶ms);
59 //Note that the interrupt stuff from the base CPU might be somewhat
60 //ISA specific (ie NumInterruptLevels). These functions might not
61 //be needed in FullCPU though.
62 // void post_interrupt(int int_num, int index);
63 // void clear_interrupt(int int_num, int index);
64 // void clear_interrupts();
66 Fault translateInstReq(MemReqPtr &req)
68 return itb->translate(req);
71 Fault translateDataReadReq(MemReqPtr &req)
73 return dtb->translate(req, false);
76 Fault translateDataWriteReq(MemReqPtr &req)
78 return dtb->translate(req, true);
82 Fault dummyTranslation(MemReqPtr &req)
85 assert((req->vaddr >> 48 & 0xffff) == 0);
88 // put the asid in the upper 16 bits of the paddr
89 req->paddr = req->vaddr & ~((Addr)0xffff << sizeof(Addr) * 8 - 16);
90 req->paddr = req->paddr | (Addr)req->asid << sizeof(Addr) * 8 - 16;
94 Fault translateInstReq(MemReqPtr &req)
96 return dummyTranslation(req);
99 Fault translateDataReadReq(MemReqPtr &req)
101 return dummyTranslation(req);
104 Fault translateDataWriteReq(MemReqPtr &req)
106 return dummyTranslation(req);
111 // Later on may want to remove this misc stuff from the regfile and
112 // have it handled at this level. Might prove to be an issue when
113 // trying to rename source/destination registers...
116 return this->regFile.readUniq();
119 void setUniq(uint64_t val)
121 this->regFile.setUniq(val);
126 return this->regFile.readFpcr();
129 void setFpcr(uint64_t val)
131 this->regFile.setFpcr(val);
134 // Most of the full system code and syscall emulation is not yet
135 // implemented. These functions do show what the final interface will
139 uint64_t readIpr(int idx, Fault &fault);
140 Fault setIpr(int idx, uint64_t val);
142 void setIntrFlag(int val);
144 bool inPalMode() { return AlphaISA::PcPAL(this->regFile.readPC()); }
145 bool inPalMode(uint64_t PC)
146 { return AlphaISA::PcPAL(PC); }
148 void trap(Fault fault);
149 bool simPalCheck(int palFunc);
151 void processInterrupts();
156 // Need to change these into regfile calls that directly set a certain
157 // register. Actually, these functions should handle most of this
158 // functionality by themselves; should look up the rename and then
160 IntReg getSyscallArg(int i)
162 return this->xc->regs.intRegFile[AlphaISA::ArgumentReg0 + i];
165 // used to shift args for indirect syscall
166 void setSyscallArg(int i, IntReg val)
168 this->xc->regs.intRegFile[AlphaISA::ArgumentReg0 + i] = val;
171 void setSyscallReturn(int64_t return_value)
173 // check for error condition. Alpha syscall convention is to
174 // indicate success/failure in reg a3 (r19) and put the
175 // return value itself in the standard return value reg (v0).
176 const int RegA3 = 19; // only place this is used
177 if (return_value >= 0) {
179 this->xc->regs.intRegFile[RegA3] = 0;
180 this->xc->regs.intRegFile[AlphaISA::ReturnValueReg] = return_value;
182 // got an error, return details
183 this->xc->regs.intRegFile[RegA3] = (IntReg) -1;
184 this->xc->regs.intRegFile[AlphaISA::ReturnValueReg] = -return_value;
188 void syscall(short thread_num);
198 bool palShadowEnabled;
200 // Not sure this is used anywhere.
201 void intr_post(RegFile *regs, Fault fault, Addr pc);
202 // Actually used within exec files. Implement properly.
203 void swapPALShadow(bool use_shadow);
204 // Called by CPU constructor. Can implement as I please.
205 void initCPU(RegFile *regs);
206 // Called by initCPU. Implement as I please.
207 void initIPRs(RegFile *regs);
209 void halt() { panic("Halt not implemented!\n"); }
214 Fault read(MemReqPtr &req, T &data)
216 #if FULL_SYSTEM && defined(TARGET_ALPHA)
217 if (req->flags & LOCKED) {
218 MiscRegFile *cregs = &req->xc->regs.miscRegs;
219 cregs->lock_addr = req->paddr;
220 cregs->lock_flag = true;
225 error = this->mem->read(req, data);
231 Fault read(MemReqPtr &req, T &data, int load_idx)
233 return this->iew.ldstQueue.read(req, data, load_idx);
237 Fault write(MemReqPtr &req, T &data)
239 #if FULL_SYSTEM && defined(TARGET_ALPHA)
243 // If this is a store conditional, act appropriately
244 if (req->flags & LOCKED) {
245 cregs = &this->xc->regs.miscRegs;
247 if (req->flags & UNCACHEABLE) {
248 // Don't update result register (see stq_c in isa_desc)
250 req->xc->storeCondFailures = 0;//Needed? [RGD]
252 req->result = cregs->lock_flag;
253 if (!cregs->lock_flag ||
254 ((cregs->lock_addr & ~0xf) != (req->paddr & ~0xf))) {
255 cregs->lock_flag = false;
256 if (((++req->xc->storeCondFailures) % 100000) == 0) {
257 std::cerr << "Warning: "
258 << req->xc->storeCondFailures
259 << " consecutive store conditional failures "
260 << "on cpu " << this->cpu_id
265 else req->xc->storeCondFailures = 0;
269 // Need to clear any locked flags on other proccessors for
270 // this address. Only do this for succsful Store Conditionals
271 // and all other stores (WH64?). Unsuccessful Store
272 // Conditionals would have returned above, and wouldn't fall
274 for (int i = 0; i < this->system->execContexts.size(); i++){
275 cregs = &this->system->execContexts[i]->regs.miscRegs;
276 if ((cregs->lock_addr & ~0xf) == (req->paddr & ~0xf)) {
277 cregs->lock_flag = false;
283 return this->mem->write(req, (T)::htog(data));
287 Fault write(MemReqPtr &req, T &data, int store_idx)
289 return this->iew.ldstQueue.write(req, data, store_idx);
294 #endif // __CPU_O3_CPU_ALPHA_FULL_CPU_HH__