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.
29 #ifndef __ARCH_ALPHA_ISA_TRAITS_HH__
30 #define __ARCH_ALPHA_ISA_TRAITS_HH__
32 namespace LittleEndianGuest {}
33 using namespace LittleEndianGuest;
35 //#include "arch/alpha/faults.hh"
36 #include "base/misc.hh"
37 #include "config/full_system.hh"
38 #include "sim/host.hh"
39 #include "sim/faults.hh"
52 int DTB_ASN_ASN(uint64_t reg);
53 int ITB_ASN_ASN(uint64_t reg);
59 typedef uint32_t MachInst;
60 // typedef uint64_t Addr;
61 typedef uint8_t RegIndex;
64 MemoryEnd = 0xffffffffffffffffULL,
68 // @todo: Figure out what this number really should be.
71 MaxRegsOfAnyType = 32,
72 // Static instruction parameters
76 // semantically meaningful register indices
77 ZeroReg = 31, // architecturally meaningful
78 // the rest of these depend on the ABI
80 GlobalPointerReg = 29,
81 ProcedureValueReg = 27,
82 ReturnAddressReg = 26,
92 LogVMPageSize = 13, // 8K bytes
93 VMPageSize = (1 << LogVMPageSize),
95 BranchPredAddrShiftAmt = 2, // instructions are 4-byte aligned
103 // These enumerate all the registers for dependence tracking.
104 enum DependenceTags {
105 // 0..31 are the integer regs 0..31
106 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
108 Ctrl_Base_DepTag = 64,
109 Fpcr_DepTag = 64, // floating point control register
111 Lock_Flag_DepTag = 66,
112 Lock_Addr_DepTag = 67,
116 typedef uint64_t IntReg;
117 typedef IntReg IntRegFile[NumIntRegs];
119 // floating point register file entry type
126 uint64_t q[NumFloatRegs]; // integer qword view
127 double d[NumFloatRegs]; // double-precision floating point view
130 extern const Addr PageShift;
131 extern const Addr PageBytes;
132 extern const Addr PageMask;
133 extern const Addr PageOffset;
137 typedef uint64_t InternalProcReg;
139 #include "arch/alpha/isa_fullsys_traits.hh"
143 NumInternalProcRegs = 0
147 // control register file contents
148 typedef uint64_t MiscReg;
151 uint64_t fpcr; // floating point condition codes
152 uint64_t uniq; // process-unique register
153 bool lock_flag; // lock flag for LL/SC
154 Addr lock_addr; // lock address for LL/SC
157 MiscReg readReg(int misc_reg);
159 MiscReg readRegWithEffect(int misc_reg, Fault &fault, ExecContext *xc);
161 Fault setReg(int misc_reg, const MiscReg &val);
163 Fault setRegWithEffect(int misc_reg, const MiscReg &val,
170 InternalProcReg ipr[NumInternalProcRegs]; // Internal processor regs
173 MiscReg readIpr(int idx, Fault &fault, ExecContext *xc);
175 Fault setIpr(int idx, uint64_t val, ExecContext *xc);
177 friend class RegFile;
182 NumIntRegs + NumFloatRegs + NumMiscRegs + NumInternalProcRegs
186 TotalDataRegs = NumIntRegs + NumFloatRegs
196 IntRegFile intRegFile; // (signed) integer register file
197 FloatRegFile floatRegFile; // floating point register file
198 MiscRegFile miscRegs; // control register file
199 Addr pc; // program counter
200 Addr npc; // next-cycle program counter
202 IntReg palregs[NumIntRegs]; // PAL shadow registers
203 int intrflag; // interrupt flag
204 bool pal_shadow; // using pal_shadow registers
205 inline int instAsid()
206 { return EV5::ITB_ASN_ASN(miscRegs.ipr[IPR_ITB_ASN]); }
207 inline int dataAsid()
208 { return EV5::DTB_ASN_ASN(miscRegs.ipr[IPR_DTB_ASN]); }
209 #endif // FULL_SYSTEM
211 void serialize(std::ostream &os);
212 void unserialize(Checkpoint *cp, const std::string §ion);
215 StaticInstPtr decodeInst(MachInst);
217 // return a no-op instruction... used for instruction fetch faults
218 extern const MachInst NoopMachInst;
222 // An impossible number for instruction annotations
223 ITOUCH_ANNOTE = 0xffffffff,
226 static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
227 panic("register classification not implemented");
228 return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
231 static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
232 panic("register classification not implemented");
233 return (reg >= 9 && reg <= 15);
236 static inline bool isCallerSaveFloatRegister(unsigned int reg) {
237 panic("register classification not implemented");
241 static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
242 panic("register classification not implemented");
246 static inline Addr alignAddress(const Addr &addr,
247 unsigned int nbytes) {
248 return (addr & ~(nbytes - 1));
251 // Instruction address compression hooks
252 static inline Addr realPCToFetchPC(const Addr &addr) {
256 static inline Addr fetchPCToRealPC(const Addr &addr) {
260 // the size of "fetched" instructions (not necessarily the size
261 // of real instructions for PISA)
262 static inline size_t fetchInstSize() {
263 return sizeof(MachInst);
266 static inline MachInst makeRegisterCopy(int dest, int src) {
267 panic("makeRegisterCopy not implemented");
271 // Machine operations
273 void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
276 void restoreMachineReg(RegFile ®s, const AnyReg ®,
280 static void serializeSpecialRegs(const Serializable::Proxy &proxy,
281 const RegFile ®s);
283 static void unserializeSpecialRegs(const IniFile *db,
284 const std::string &category,
290 * Function to insure ISA semantics about 0 registers.
291 * @param xc The execution context.
294 void zeroRegisters(XC *xc);
297 //typedef AlphaISA TheISA;
299 //typedef TheISA::MachInst MachInst;
300 //typedef TheISA::Addr Addr;
301 //typedef TheISA::RegIndex RegIndex;
302 //typedef TheISA::IntReg IntReg;
303 //typedef TheISA::IntRegFile IntRegFile;
304 //typedef TheISA::FloatReg FloatReg;
305 //typedef TheISA::FloatRegFile FloatRegFile;
306 //typedef TheISA::MiscReg MiscReg;
307 //typedef TheISA::MiscRegFile MiscRegFile;
308 //typedef TheISA::AnyReg AnyReg;
309 //typedef TheISA::RegFile RegFile;
311 //const int NumIntRegs = TheISA::NumIntRegs;
312 //const int NumFloatRegs = TheISA::NumFloatRegs;
313 //const int NumMiscRegs = TheISA::NumMiscRegs;
314 //const int TotalNumRegs = TheISA::TotalNumRegs;
315 //const int VMPageSize = TheISA::VMPageSize;
316 //const int LogVMPageSize = TheISA::LogVMPageSize;
317 //const int ZeroReg = TheISA::ZeroReg;
318 //const int StackPointerReg = TheISA::StackPointerReg;
319 //const int GlobalPointerReg = TheISA::GlobalPointerReg;
320 //const int ReturnAddressReg = TheISA::ReturnAddressReg;
321 //const int ReturnValueReg = TheISA::ReturnValueReg;
322 //const int ArgumentReg0 = TheISA::ArgumentReg0;
323 //const int ArgumentReg1 = TheISA::ArgumentReg1;
324 //const int ArgumentReg2 = TheISA::ArgumentReg2;
325 //const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
326 const Addr MaxAddr = (Addr)-1;
330 class SyscallReturn {
333 SyscallReturn(T v, bool s)
335 retval = (uint64_t)v;
343 retval = (uint64_t)v;
348 SyscallReturn& operator=(const SyscallReturn& s) {
354 bool successful() { return success; }
355 uint64_t value() { return retval; }
367 //typedef TheISA::InternalProcReg InternalProcReg;
368 //const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
369 //const int NumInterruptLevels = TheISA::NumInterruptLevels;
371 #include "arch/alpha/ev5.hh"
374 #endif // __ARCH_ALPHA_ISA_TRAITS_HH__