2 * Copyright (c) 2003-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.
31 #ifndef __ARCH_ALPHA_REGFILE_HH__
32 #define __ARCH_ALPHA_REGFILE_HH__
34 #include "arch/alpha/types.hh"
35 #include "arch/alpha/isa_traits.hh"
36 #include "sim/faults.hh"
40 //XXX These should be implemented by someone who knows the alpha stuff better
48 static inline std::string getIntRegName(RegIndex)
53 static inline std::string getFloatRegName(RegIndex)
58 static inline std::string getMiscRegName(RegIndex)
66 IntReg regs[NumIntRegs];
70 IntReg readReg(int intReg)
75 Fault setReg(int intReg, const IntReg &val)
81 void serialize(std::ostream &os);
83 void unserialize(Checkpoint *cp, const std::string §ion);
86 { bzero(regs, sizeof(regs)); }
94 uint64_t q[NumFloatRegs]; // integer qword view
95 double d[NumFloatRegs]; // double-precision floating point view
98 void serialize(std::ostream &os);
100 void unserialize(Checkpoint *cp, const std::string §ion);
103 { bzero(d, sizeof(d)); }
108 uint64_t fpcr; // floating point condition codes
109 uint64_t uniq; // process-unique register
110 bool lock_flag; // lock flag for LL/SC
111 Addr lock_addr; // lock address for LL/SC
115 MiscReg readReg(int misc_reg);
117 MiscReg readRegWithEffect(int misc_reg, Fault &fault,
120 //These functions should be removed once the simplescalar cpu model
125 Fault setReg(int misc_reg, const MiscReg &val);
127 Fault setRegWithEffect(int misc_reg, const MiscReg &val,
138 void serialize(std::ostream &os);
140 void unserialize(Checkpoint *cp, const std::string §ion);
143 typedef uint64_t InternalProcReg;
145 InternalProcReg ipr[NumInternalProcRegs]; // Internal processor regs
148 InternalProcReg readIpr(int idx, Fault &fault, ThreadContext *tc);
150 Fault setIpr(int idx, InternalProcReg val, ThreadContext *tc);
152 friend class RegFile;
158 Addr pc; // program counter
159 Addr npc; // next-cycle program counter
178 void setNextPC(Addr val)
188 void setNextNPC(Addr val)
194 IntRegFile intRegFile; // (signed) integer register file
195 FloatRegFile floatRegFile; // floating point register file
196 MiscRegFile miscRegFile; // control register file
201 int intrflag; // interrupt flag
202 inline int instAsid()
203 { return miscRegFile.getInstAsid(); }
204 inline int dataAsid()
205 { return miscRegFile.getDataAsid(); }
206 #endif // FULL_SYSTEM
211 floatRegFile.clear();
215 MiscReg readMiscReg(int miscReg)
217 return miscRegFile.readReg(miscReg);
220 MiscReg readMiscRegWithEffect(int miscReg,
221 Fault &fault, ThreadContext *tc)
224 return miscRegFile.readRegWithEffect(miscReg, fault, tc);
227 Fault setMiscReg(int miscReg, const MiscReg &val)
229 return miscRegFile.setReg(miscReg, val);
232 Fault setMiscRegWithEffect(int miscReg, const MiscReg &val,
235 return miscRegFile.setRegWithEffect(miscReg, val, tc);
238 FloatReg readFloatReg(int floatReg)
240 return floatRegFile.d[floatReg];
243 FloatReg readFloatReg(int floatReg, int width)
245 return readFloatReg(floatReg);
248 FloatRegBits readFloatRegBits(int floatReg)
250 return floatRegFile.q[floatReg];
253 FloatRegBits readFloatRegBits(int floatReg, int width)
255 return readFloatRegBits(floatReg);
258 Fault setFloatReg(int floatReg, const FloatReg &val)
260 floatRegFile.d[floatReg] = val;
264 Fault setFloatReg(int floatReg, const FloatReg &val, int width)
266 return setFloatReg(floatReg, val);
269 Fault setFloatRegBits(int floatReg, const FloatRegBits &val)
271 floatRegFile.q[floatReg] = val;
275 Fault setFloatRegBits(int floatReg, const FloatRegBits &val, int width)
277 return setFloatRegBits(floatReg, val);
280 IntReg readIntReg(int intReg)
282 return intRegFile.readReg(intReg);
285 Fault setIntReg(int intReg, const IntReg &val)
287 return intRegFile.setReg(intReg, val);
290 void serialize(std::ostream &os);
291 void unserialize(Checkpoint *cp, const std::string §ion);
293 void changeContext(RegContextParam param, RegContextVal val)
295 //This would be an alternative place to call/implement
296 //the swapPALShadow function
300 void copyRegs(ThreadContext *src, ThreadContext *dest);
302 void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
305 void copyIprs(ThreadContext *src, ThreadContext *dest);
307 } // namespace AlphaISA