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 AlphaISA::Addr Addr;
44 typedef TheISA::IntReg IntReg;
46 typedef typename Impl::Params Params;
49 AlphaFullCPU(Params ¶ms);
60 //Note that the interrupt stuff from the base CPU might be somewhat
61 //ISA specific (ie NumInterruptLevels). These functions might not
62 //be needed in FullCPU though.
63 // void post_interrupt(int int_num, int index);
64 // void clear_interrupt(int int_num, int index);
65 // void clear_interrupts();
67 Fault * translateInstReq(MemReqPtr &req)
69 return itb->translate(req);
72 Fault * translateDataReadReq(MemReqPtr &req)
74 return dtb->translate(req, false);
77 Fault * translateDataWriteReq(MemReqPtr &req)
79 return dtb->translate(req, true);
83 Fault * dummyTranslation(MemReqPtr &req)
86 assert((req->vaddr >> 48 & 0xffff) == 0);
89 // put the asid in the upper 16 bits of the paddr
90 req->paddr = req->vaddr & ~((Addr)0xffff << sizeof(Addr) * 8 - 16);
91 req->paddr = req->paddr | (Addr)req->asid << sizeof(Addr) * 8 - 16;
95 Fault * translateInstReq(MemReqPtr &req)
97 return dummyTranslation(req);
100 Fault * translateDataReadReq(MemReqPtr &req)
102 return dummyTranslation(req);
105 Fault * translateDataWriteReq(MemReqPtr &req)
107 return dummyTranslation(req);
112 // Later on may want to remove this misc stuff from the regfile and
113 // have it handled at this level. Might prove to be an issue when
114 // trying to rename source/destination registers...
117 return this->regFile.readUniq();
120 void setUniq(uint64_t val)
122 this->regFile.setUniq(val);
127 return this->regFile.readFpcr();
130 void setFpcr(uint64_t val)
132 this->regFile.setFpcr(val);
135 // Most of the full system code and syscall emulation is not yet
136 // implemented. These functions do show what the final interface will
140 uint64_t readIpr(int idx, Fault * &fault);
141 Fault * setIpr(int idx, uint64_t val);
143 void setIntrFlag(int val);
145 bool inPalMode() { return AlphaISA::PcPAL(this->regFile.readPC()); }
146 bool inPalMode(uint64_t PC)
147 { return AlphaISA::PcPAL(PC); }
149 void trap(Fault * fault);
150 bool simPalCheck(int palFunc);
152 void processInterrupts();
157 // Need to change these into regfile calls that directly set a certain
158 // register. Actually, these functions should handle most of this
159 // functionality by themselves; should look up the rename and then
161 IntReg getSyscallArg(int i)
163 return this->xc->regs.intRegFile[AlphaISA::ArgumentReg0 + i];
166 // used to shift args for indirect syscall
167 void setSyscallArg(int i, IntReg val)
169 this->xc->regs.intRegFile[AlphaISA::ArgumentReg0 + i] = val;
172 void setSyscallReturn(int64_t return_value)
174 // check for error condition. Alpha syscall convention is to
175 // indicate success/failure in reg a3 (r19) and put the
176 // return value itself in the standard return value reg (v0).
177 const int RegA3 = 19; // only place this is used
178 if (return_value >= 0) {
180 this->xc->regs.intRegFile[RegA3] = 0;
181 this->xc->regs.intRegFile[AlphaISA::ReturnValueReg] = return_value;
183 // got an error, return details
184 this->xc->regs.intRegFile[RegA3] = (IntReg) -1;
185 this->xc->regs.intRegFile[AlphaISA::ReturnValueReg] = -return_value;
189 void syscall(short thread_num);
199 bool palShadowEnabled;
201 // Not sure this is used anywhere.
202 void intr_post(RegFile *regs, Fault * fault, Addr pc);
203 // Actually used within exec files. Implement properly.
204 void swapPALShadow(bool use_shadow);
205 // Called by CPU constructor. Can implement as I please.
206 void initCPU(RegFile *regs);
207 // Called by initCPU. Implement as I please.
208 void initIPRs(RegFile *regs);
210 void halt() { panic("Halt not implemented!\n"); }
215 Fault * read(MemReqPtr &req, T &data)
217 #if FULL_SYSTEM && defined(TARGET_ALPHA)
218 if (req->flags & LOCKED) {
219 MiscRegFile *cregs = &req->xc->regs.miscRegs;
220 cregs->lock_addr = req->paddr;
221 cregs->lock_flag = true;
226 error = this->mem->read(req, data);
232 Fault * read(MemReqPtr &req, T &data, int load_idx)
234 return this->iew.ldstQueue.read(req, data, load_idx);
238 Fault * write(MemReqPtr &req, T &data)
240 #if FULL_SYSTEM && defined(TARGET_ALPHA)
244 // If this is a store conditional, act appropriately
245 if (req->flags & LOCKED) {
246 cregs = &this->xc->regs.miscRegs;
248 if (req->flags & UNCACHEABLE) {
249 // Don't update result register (see stq_c in isa_desc)
251 req->xc->storeCondFailures = 0;//Needed? [RGD]
253 req->result = cregs->lock_flag;
254 if (!cregs->lock_flag ||
255 ((cregs->lock_addr & ~0xf) != (req->paddr & ~0xf))) {
256 cregs->lock_flag = false;
257 if (((++req->xc->storeCondFailures) % 100000) == 0) {
258 std::cerr << "Warning: "
259 << req->xc->storeCondFailures
260 << " consecutive store conditional failures "
261 << "on cpu " << this->cpu_id
266 else req->xc->storeCondFailures = 0;
270 // Need to clear any locked flags on other proccessors for
271 // this address. Only do this for succsful Store Conditionals
272 // and all other stores (WH64?). Unsuccessful Store
273 // Conditionals would have returned above, and wouldn't fall
275 for (int i = 0; i < this->system->execContexts.size(); i++){
276 cregs = &this->system->execContexts[i]->regs.miscRegs;
277 if ((cregs->lock_addr & ~0xf) == (req->paddr & ~0xf)) {
278 cregs->lock_flag = false;
284 return this->mem->write(req, (T)::htog(data));
288 Fault * write(MemReqPtr &req, T &data, int store_idx)
290 return this->iew.ldstQueue.write(req, data, store_idx);
295 #endif // __CPU_O3_CPU_ALPHA_FULL_CPU_HH__