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 #include "arch/alpha/faults.hh"
33 #include "base/misc.hh"
34 #include "config/full_system.hh"
35 #include "sim/host.hh"
43 template <class ISA> class StaticInst;
44 template <class ISA> class StaticInstPtr;
47 int DTB_ASN_ASN(uint64_t reg);
48 int ITB_ASN_ASN(uint64_t reg);
55 typedef uint32_t MachInst;
56 typedef uint64_t Addr;
57 typedef uint8_t RegIndex;
60 MemoryEnd = 0xffffffffffffffffULL,
66 MaxRegsOfAnyType = 32,
67 // Static instruction parameters
71 // semantically meaningful register indices
72 ZeroReg = 31, // architecturally meaningful
73 // the rest of these depend on the ABI
75 GlobalPointerReg = 29,
76 ReturnAddressReg = 26,
85 LogVMPageSize = 13, // 8K bytes
86 VMPageSize = (1 << LogVMPageSize),
88 BranchPredAddrShiftAmt = 2, // instructions are 4-byte aligned
96 // These enumerate all the registers for dependence tracking.
98 // 0..31 are the integer regs 0..31
99 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
101 Ctrl_Base_DepTag = 64,
102 Fpcr_DepTag = 64, // floating point control register
107 typedef uint64_t IntReg;
108 typedef IntReg IntRegFile[NumIntRegs];
110 // floating point register file entry type
117 uint64_t q[NumFloatRegs]; // integer qword view
118 double d[NumFloatRegs]; // double-precision floating point view
121 // control register file contents
122 typedef uint64_t MiscReg;
124 uint64_t fpcr; // floating point condition codes
125 uint64_t uniq; // process-unique register
126 bool lock_flag; // lock flag for LL/SC
127 Addr lock_addr; // lock address for LL/SC
130 static const Addr PageShift = 13;
131 static const Addr PageBytes = ULL(1) << PageShift;
132 static const Addr PageMask = ~(PageBytes - 1);
133 static const Addr PageOffset = PageBytes - 1;
137 typedef uint64_t InternalProcReg;
139 #include "arch/alpha/isa_fullsys_traits.hh"
143 NumInternalProcRegs = 0
149 NumIntRegs + NumFloatRegs + NumMiscRegs + NumInternalProcRegs
153 TotalDataRegs = NumIntRegs + NumFloatRegs
163 IntRegFile intRegFile; // (signed) integer register file
164 FloatRegFile floatRegFile; // floating point register file
165 MiscRegFile miscRegs; // control register file
166 Addr pc; // program counter
167 Addr npc; // next-cycle program counter
169 IntReg palregs[NumIntRegs]; // PAL shadow registers
170 InternalProcReg ipr[NumInternalProcRegs]; // internal processor regs
171 int intrflag; // interrupt flag
172 bool pal_shadow; // using pal_shadow registers
173 inline int instAsid() { return EV5::ITB_ASN_ASN(ipr[IPR_ITB_ASN]); }
174 inline int dataAsid() { return EV5::DTB_ASN_ASN(ipr[IPR_DTB_ASN]); }
175 #endif // FULL_SYSTEM
177 void serialize(std::ostream &os);
178 void unserialize(Checkpoint *cp, const std::string §ion);
181 static StaticInstPtr<AlphaISA> decodeInst(MachInst);
183 // return a no-op instruction... used for instruction fetch faults
184 static const MachInst NoopMachInst;
188 // An impossible number for instruction annotations
189 ITOUCH_ANNOTE = 0xffffffff,
192 static inline bool isCallerSaveIntegerRegister(unsigned int reg) {
193 panic("register classification not implemented");
194 return (reg >= 1 && reg <= 8 || reg >= 22 && reg <= 25 || reg == 27);
197 static inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
198 panic("register classification not implemented");
199 return (reg >= 9 && reg <= 15);
202 static inline bool isCallerSaveFloatRegister(unsigned int reg) {
203 panic("register classification not implemented");
207 static inline bool isCalleeSaveFloatRegister(unsigned int reg) {
208 panic("register classification not implemented");
212 static inline Addr alignAddress(const Addr &addr,
213 unsigned int nbytes) {
214 return (addr & ~(nbytes - 1));
217 // Instruction address compression hooks
218 static inline Addr realPCToFetchPC(const Addr &addr) {
222 static inline Addr fetchPCToRealPC(const Addr &addr) {
226 // the size of "fetched" instructions (not necessarily the size
227 // of real instructions for PISA)
228 static inline size_t fetchInstSize() {
229 return sizeof(MachInst);
232 static inline MachInst makeRegisterCopy(int dest, int src) {
233 panic("makeRegisterCopy not implemented");
237 // Machine operations
239 static void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
242 static void restoreMachineReg(RegFile ®s, const AnyReg ®,
246 static void serializeSpecialRegs(const Serializable::Proxy &proxy,
247 const RegFile ®s);
249 static void unserializeSpecialRegs(const IniFile *db,
250 const std::string &category,
256 * Function to insure ISA semantics about 0 registers.
257 * @param xc The execution context.
260 static void zeroRegisters(XC *xc);
264 typedef AlphaISA TheISA;
266 typedef TheISA::MachInst MachInst;
267 typedef TheISA::Addr Addr;
268 typedef TheISA::RegIndex RegIndex;
269 typedef TheISA::IntReg IntReg;
270 typedef TheISA::IntRegFile IntRegFile;
271 typedef TheISA::FloatReg FloatReg;
272 typedef TheISA::FloatRegFile FloatRegFile;
273 typedef TheISA::MiscReg MiscReg;
274 typedef TheISA::MiscRegFile MiscRegFile;
275 typedef TheISA::AnyReg AnyReg;
276 typedef TheISA::RegFile RegFile;
278 const int NumIntRegs = TheISA::NumIntRegs;
279 const int NumFloatRegs = TheISA::NumFloatRegs;
280 const int NumMiscRegs = TheISA::NumMiscRegs;
281 const int TotalNumRegs = TheISA::TotalNumRegs;
282 const int VMPageSize = TheISA::VMPageSize;
283 const int LogVMPageSize = TheISA::LogVMPageSize;
284 const int ZeroReg = TheISA::ZeroReg;
285 const int StackPointerReg = TheISA::StackPointerReg;
286 const int GlobalPointerReg = TheISA::GlobalPointerReg;
287 const int ReturnAddressReg = TheISA::ReturnAddressReg;
288 const int ReturnValueReg = TheISA::ReturnValueReg;
289 const int ArgumentReg0 = TheISA::ArgumentReg0;
290 const int ArgumentReg1 = TheISA::ArgumentReg1;
291 const int ArgumentReg2 = TheISA::ArgumentReg2;
292 const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
293 const int MaxAddr = (Addr)-1;
296 class SyscallReturn {
299 SyscallReturn(T v, bool s)
301 retval = (uint64_t)v;
309 retval = (uint64_t)v;
314 SyscallReturn& operator=(const SyscallReturn& s) {
320 bool successful() { return success; }
321 uint64_t value() { return retval; }
333 typedef TheISA::InternalProcReg InternalProcReg;
334 const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
335 const int NumInterruptLevels = TheISA::NumInterruptLevels;
337 #include "arch/alpha/ev5.hh"
340 #endif // __ARCH_ALPHA_ISA_TRAITS_HH__