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"
51 int DTB_ASN_ASN(uint64_t reg);
52 int ITB_ASN_ASN(uint64_t reg);
58 typedef uint32_t MachInst;
59 typedef uint64_t Addr;
60 typedef uint8_t RegIndex;
63 MemoryEnd = 0xffffffffffffffffULL,
69 MaxRegsOfAnyType = 32,
70 // Static instruction parameters
74 // semantically meaningful register indices
75 ZeroReg = 31, // architecturally meaningful
76 // the rest of these depend on the ABI
78 GlobalPointerReg = 29,
79 ProcedureValueReg = 27,
80 ReturnAddressReg = 26,
90 LogVMPageSize = 13, // 8K bytes
91 VMPageSize = (1 << LogVMPageSize),
93 BranchPredAddrShiftAmt = 2, // instructions are 4-byte aligned
101 // These enumerate all the registers for dependence tracking.
102 enum DependenceTags {
103 // 0..31 are the integer regs 0..31
104 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
106 Ctrl_Base_DepTag = 64,
107 Fpcr_DepTag = 64, // floating point control register
112 typedef uint64_t IntReg;
113 typedef IntReg IntRegFile[NumIntRegs];
115 // floating point register file entry type
122 uint64_t q[NumFloatRegs]; // integer qword view
123 double d[NumFloatRegs]; // double-precision floating point view
126 // control register file contents
127 typedef uint64_t MiscReg;
129 uint64_t fpcr; // floating point condition codes
130 uint64_t uniq; // process-unique register
131 bool lock_flag; // lock flag for LL/SC
132 Addr lock_addr; // lock address for LL/SC
135 extern const Addr PageShift;
136 extern const Addr PageBytes;
137 extern const Addr PageMask;
138 extern const Addr PageOffset;
142 typedef uint64_t InternalProcReg;
144 #include "arch/alpha/isa_fullsys_traits.hh"
148 NumInternalProcRegs = 0
154 NumIntRegs + NumFloatRegs + NumMiscRegs + NumInternalProcRegs
158 TotalDataRegs = NumIntRegs + NumFloatRegs
168 IntRegFile intRegFile; // (signed) integer register file
169 FloatRegFile floatRegFile; // floating point register file
170 MiscRegFile miscRegs; // control register file
171 Addr pc; // program counter
172 Addr npc; // next-cycle program counter
174 IntReg palregs[NumIntRegs]; // PAL shadow registers
175 InternalProcReg ipr[NumInternalProcRegs]; // internal processor regs
176 int intrflag; // interrupt flag
177 bool pal_shadow; // using pal_shadow registers
178 inline int instAsid() { return EV5::ITB_ASN_ASN(ipr[IPR_ITB_ASN]); }
179 inline int dataAsid() { return EV5::DTB_ASN_ASN(ipr[IPR_DTB_ASN]); }
180 #endif // FULL_SYSTEM
182 void serialize(std::ostream &os);
183 void unserialize(Checkpoint *cp, const std::string §ion);
186 StaticInstPtr decodeInst(MachInst);
188 // return a no-op instruction... used for instruction fetch faults
189 extern const MachInst NoopMachInst;
193 // An impossible number for instruction annotations
194 ITOUCH_ANNOTE = 0xffffffff,
197 static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
198 panic("register classification not implemented");
199 return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
202 static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
203 panic("register classification not implemented");
204 return (reg >= 9 && reg <= 15);
207 static inline bool isCallerSaveFloatRegister(unsigned int reg) {
208 panic("register classification not implemented");
212 static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
213 panic("register classification not implemented");
217 static inline Addr alignAddress(const Addr &addr,
218 unsigned int nbytes) {
219 return (addr & ~(nbytes - 1));
222 // Instruction address compression hooks
223 static inline Addr realPCToFetchPC(const Addr &addr) {
227 static inline Addr fetchPCToRealPC(const Addr &addr) {
231 // the size of "fetched" instructions (not necessarily the size
232 // of real instructions for PISA)
233 static inline size_t fetchInstSize() {
234 return sizeof(MachInst);
237 static inline MachInst makeRegisterCopy(int dest, int src) {
238 panic("makeRegisterCopy not implemented");
242 // Machine operations
244 void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
247 void restoreMachineReg(RegFile ®s, const AnyReg ®,
251 static void serializeSpecialRegs(const Serializable::Proxy &proxy,
252 const RegFile ®s);
254 static void unserializeSpecialRegs(const IniFile *db,
255 const std::string &category,
261 * Function to insure ISA semantics about 0 registers.
262 * @param xc The execution context.
265 void zeroRegisters(XC *xc);
268 //typedef AlphaISA TheISA;
270 //typedef TheISA::MachInst MachInst;
271 //typedef TheISA::Addr Addr;
272 //typedef TheISA::RegIndex RegIndex;
273 //typedef TheISA::IntReg IntReg;
274 //typedef TheISA::IntRegFile IntRegFile;
275 //typedef TheISA::FloatReg FloatReg;
276 //typedef TheISA::FloatRegFile FloatRegFile;
277 //typedef TheISA::MiscReg MiscReg;
278 //typedef TheISA::MiscRegFile MiscRegFile;
279 //typedef TheISA::AnyReg AnyReg;
280 //typedef TheISA::RegFile RegFile;
282 //const int NumIntRegs = TheISA::NumIntRegs;
283 //const int NumFloatRegs = TheISA::NumFloatRegs;
284 //const int NumMiscRegs = TheISA::NumMiscRegs;
285 //const int TotalNumRegs = TheISA::TotalNumRegs;
286 //const int VMPageSize = TheISA::VMPageSize;
287 //const int LogVMPageSize = TheISA::LogVMPageSize;
288 //const int ZeroReg = TheISA::ZeroReg;
289 //const int StackPointerReg = TheISA::StackPointerReg;
290 //const int GlobalPointerReg = TheISA::GlobalPointerReg;
291 //const int ReturnAddressReg = TheISA::ReturnAddressReg;
292 //const int ReturnValueReg = TheISA::ReturnValueReg;
293 //const int ArgumentReg0 = TheISA::ArgumentReg0;
294 //const int ArgumentReg1 = TheISA::ArgumentReg1;
295 //const int ArgumentReg2 = TheISA::ArgumentReg2;
296 //const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
297 const Addr MaxAddr = (Addr)-1;
301 class SyscallReturn {
304 SyscallReturn(T v, bool s)
306 retval = (uint64_t)v;
314 retval = (uint64_t)v;
319 SyscallReturn& operator=(const SyscallReturn& s) {
325 bool successful() { return success; }
326 uint64_t value() { return retval; }
338 //typedef TheISA::InternalProcReg InternalProcReg;
339 //const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
340 //const int NumInterruptLevels = TheISA::NumInterruptLevels;
342 #include "arch/alpha/ev5.hh"
345 #endif // __ARCH_ALPHA_ISA_TRAITS_HH__