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 ExtMachInst;
61 // typedef uint64_t Addr;
62 typedef uint8_t RegIndex;
65 MemoryEnd = 0xffffffffffffffffULL,
69 NumFloatArchRegs = 32,
70 // @todo: Figure out what this number really should be.
73 MaxRegsOfAnyType = 32,
74 // Static instruction parameters
78 // semantically meaningful register indices
79 ZeroReg = 31, // architecturally meaningful
80 // the rest of these depend on the ABI
82 GlobalPointerReg = 29,
83 ProcedureValueReg = 27,
84 ReturnAddressReg = 26,
94 LogVMPageSize = 13, // 8K bytes
95 VMPageSize = (1 << LogVMPageSize),
97 BranchPredAddrShiftAmt = 2, // instructions are 4-byte aligned
106 NumIntRegs = NumIntArchRegs + NumPALShadowRegs,
107 NumFloatRegs = NumFloatArchRegs,
108 NumMiscRegs = NumMiscArchRegs
111 // These enumerate all the registers for dependence tracking.
112 enum DependenceTags {
113 // 0..31 are the integer regs 0..31
114 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
116 Ctrl_Base_DepTag = 72,
117 Fpcr_DepTag = 72, // floating point control register
119 Lock_Flag_DepTag = 74,
120 Lock_Addr_DepTag = 75,
124 typedef uint64_t IntReg;
125 typedef IntReg IntRegFile[NumIntRegs];
127 // floating point register file entry type
134 uint64_t q[NumFloatRegs]; // integer qword view
135 double d[NumFloatRegs]; // double-precision floating point view
138 extern const Addr PageShift;
139 extern const Addr PageBytes;
140 extern const Addr PageMask;
141 extern const Addr PageOffset;
143 // redirected register map, really only used for the full system case.
144 extern const int reg_redir[NumIntRegs];
148 typedef uint64_t InternalProcReg;
150 #include "arch/alpha/isa_fullsys_traits.hh"
154 NumInternalProcRegs = 0
158 // control register file contents
159 typedef uint64_t MiscReg;
162 uint64_t fpcr; // floating point condition codes
163 uint64_t uniq; // process-unique register
164 bool lock_flag; // lock flag for LL/SC
165 Addr lock_addr; // lock address for LL/SC
168 MiscReg readReg(int misc_reg);
170 MiscReg readRegWithEffect(int misc_reg, Fault &fault, ExecContext *xc);
172 Fault setReg(int misc_reg, const MiscReg &val);
174 Fault setRegWithEffect(int misc_reg, const MiscReg &val,
181 InternalProcReg ipr[NumInternalProcRegs]; // Internal processor regs
184 MiscReg readIpr(int idx, Fault &fault, ExecContext *xc);
186 Fault setIpr(int idx, uint64_t val, ExecContext *xc);
188 friend class RegFile;
193 NumIntRegs + NumFloatRegs + NumMiscRegs + NumInternalProcRegs
197 TotalDataRegs = NumIntRegs + NumFloatRegs
207 IntRegFile intRegFile; // (signed) integer register file
208 FloatRegFile floatRegFile; // floating point register file
209 MiscRegFile miscRegs; // control register file
210 Addr pc; // program counter
211 Addr npc; // next-cycle program counter
213 int intrflag; // interrupt flag
214 inline int instAsid()
215 { return EV5::ITB_ASN_ASN(miscRegs.ipr[IPR_ITB_ASN]); }
216 inline int dataAsid()
217 { return EV5::DTB_ASN_ASN(miscRegs.ipr[IPR_DTB_ASN]); }
218 #endif // FULL_SYSTEM
220 void serialize(std::ostream &os);
221 void unserialize(Checkpoint *cp, const std::string §ion);
224 static inline ExtMachInst makeExtMI(MachInst inst, const uint64_t &pc);
226 StaticInstPtr decodeInst(ExtMachInst);
228 // return a no-op instruction... used for instruction fetch faults
229 extern const ExtMachInst NoopMachInst;
233 // An impossible number for instruction annotations
234 ITOUCH_ANNOTE = 0xffffffff,
237 static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
238 panic("register classification not implemented");
239 return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
242 static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
243 panic("register classification not implemented");
244 return (reg >= 9 && reg <= 15);
247 static inline bool isCallerSaveFloatRegister(unsigned int reg) {
248 panic("register classification not implemented");
252 static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
253 panic("register classification not implemented");
257 static inline Addr alignAddress(const Addr &addr,
258 unsigned int nbytes) {
259 return (addr & ~(nbytes - 1));
262 // Instruction address compression hooks
263 static inline Addr realPCToFetchPC(const Addr &addr) {
267 static inline Addr fetchPCToRealPC(const Addr &addr) {
271 // the size of "fetched" instructions (not necessarily the size
272 // of real instructions for PISA)
273 static inline size_t fetchInstSize() {
274 return sizeof(MachInst);
277 static inline MachInst makeRegisterCopy(int dest, int src) {
278 panic("makeRegisterCopy not implemented");
282 // Machine operations
284 void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
287 void restoreMachineReg(RegFile ®s, const AnyReg ®,
291 static void serializeSpecialRegs(const Serializable::Proxy &proxy,
292 const RegFile ®s);
294 static void unserializeSpecialRegs(const IniFile *db,
295 const std::string &category,
301 * Function to insure ISA semantics about 0 registers.
302 * @param xc The execution context.
305 void zeroRegisters(XC *xc);
308 //typedef AlphaISA TheISA;
310 //typedef TheISA::MachInst MachInst;
311 //typedef TheISA::Addr Addr;
312 //typedef TheISA::RegIndex RegIndex;
313 //typedef TheISA::IntReg IntReg;
314 //typedef TheISA::IntRegFile IntRegFile;
315 //typedef TheISA::FloatReg FloatReg;
316 //typedef TheISA::FloatRegFile FloatRegFile;
317 //typedef TheISA::MiscReg MiscReg;
318 //typedef TheISA::MiscRegFile MiscRegFile;
319 //typedef TheISA::AnyReg AnyReg;
320 //typedef TheISA::RegFile RegFile;
322 //const int NumIntRegs = TheISA::NumIntRegs;
323 //const int NumFloatRegs = TheISA::NumFloatRegs;
324 //const int NumMiscRegs = TheISA::NumMiscRegs;
325 //const int TotalNumRegs = TheISA::TotalNumRegs;
326 //const int VMPageSize = TheISA::VMPageSize;
327 //const int LogVMPageSize = TheISA::LogVMPageSize;
328 //const int ZeroReg = TheISA::ZeroReg;
329 //const int StackPointerReg = TheISA::StackPointerReg;
330 //const int GlobalPointerReg = TheISA::GlobalPointerReg;
331 //const int ReturnAddressReg = TheISA::ReturnAddressReg;
332 //const int ReturnValueReg = TheISA::ReturnValueReg;
333 //const int ArgumentReg0 = TheISA::ArgumentReg0;
334 //const int ArgumentReg1 = TheISA::ArgumentReg1;
335 //const int ArgumentReg2 = TheISA::ArgumentReg2;
336 //const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
337 const Addr MaxAddr = (Addr)-1;
341 class SyscallReturn {
344 SyscallReturn(T v, bool s)
346 retval = (uint64_t)v;
354 retval = (uint64_t)v;
359 SyscallReturn& operator=(const SyscallReturn& s) {
365 bool successful() { return success; }
366 uint64_t value() { return retval; }
376 static inline AlphaISA::ExtMachInst
377 AlphaISA::makeExtMI(AlphaISA::MachInst inst, const uint64_t &pc) {
379 AlphaISA::ExtMachInst ext_inst = inst;
381 return ext_inst|=(static_cast<AlphaISA::ExtMachInst>(pc & 0x1) << 32);
385 return AlphaISA::ExtMachInst(inst);
390 //typedef TheISA::InternalProcReg InternalProcReg;
391 //const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
392 //const int NumInterruptLevels = TheISA::NumInterruptLevels;
394 #include "arch/alpha/ev5.hh"
397 #endif // __ARCH_ALPHA_ISA_TRAITS_HH__