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_SPARC_ISA_TRAITS_HH__
30 #define __ARCH_SPARC_ISA_TRAITS_HH__
32 #include "base/misc.hh"
33 #include "config/full_system.hh"
34 #include "sim/host.hh"
44 namespace BigEndianGuest {}
51 SyscallReturn(T v, bool s)
66 SyscallReturn& operator=(const SyscallReturn& s)
73 bool successful() { return success; }
74 uint64_t value() { return retval; }
87 // These enumerate all the registers for dependence tracking.
89 // 0..31 are the integer regs 0..31
90 // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
92 Ctrl_Base_DepTag = 96,
93 //XXX These are here solely to get compilation and won't work
98 //This makes sure the big endian versions of certain functions are used.
99 using namespace BigEndianGuest;
101 typedef uint32_t MachInst;
102 typedef uint64_t ExtMachInst;
104 const int NumIntRegs = 32;
105 const int NumFloatRegs = 64;
106 const int NumMiscRegs = 32;
108 // semantically meaningful register indices
109 const int ZeroReg = 0; // architecturally meaningful
110 // the rest of these depend on the ABI
111 const int StackPointerReg = 14;
112 const int ReturnAddressReg = 31; // post call, precall is 15
113 const int ReturnValueReg = 8; // Post return, 24 is pre-return.
114 const int FramePointerReg = 30;
115 const int ArgumentReg0 = 8;
116 const int ArgumentReg1 = 9;
117 const int ArgumentReg2 = 10;
118 const int ArgumentReg3 = 11;
119 const int ArgumentReg4 = 12;
120 const int ArgumentReg5 = 13;
121 // Some OS syscall use a second register (o1) to return a second value
122 const int SyscallPseudoReturnReg = ArgumentReg1;
124 //XXX These numbers are bogus
125 const int MaxInstSrcRegs = 8;
126 const int MaxInstDestRegs = 9;
128 typedef uint64_t IntReg;
130 // control register file contents
131 typedef uint64_t MiscReg;
133 typedef double FloatReg;
134 typedef uint64_t FloatRegBits;
136 //8K. This value is implmentation specific; and should probably
138 const int LogVMPageSize = 13;
139 const int VMPageSize = (1 << LogVMPageSize);
141 //Why does both the previous set of constants and this one exist?
142 const int PageShift = 13;
143 const int PageBytes = ULL(1) << PageShift;
145 const int BranchPredAddrShiftAmt = 2;
147 const int MachineBytes = 8;
148 const int WordBytes = 4;
149 const int HalfwordBytes = 2;
150 const int ByteBytes = 1;
152 void serialize(std::ostream & os);
154 void unserialize(Checkpoint *cp, const std::string §ion);
156 StaticInstPtr decodeInst(ExtMachInst);
158 // return a no-op instruction... used for instruction fetch faults
159 extern const MachInst NoopMachInst;
162 #include "arch/sparc/regfile.hh"
168 static inline void setSyscallReturn(SyscallReturn return_value,
171 // check for error condition. SPARC syscall convention is to
172 // indicate success/failure in reg the carry bit of the ccr
173 // and put the return value itself in the standard return value reg ().
174 if (return_value.successful()) {
176 regs->setMiscReg(MISCREG_CCR_XCC_C, 0);
177 regs->setIntReg(ReturnValueReg, return_value.value());
179 // got an error, return details
180 regs->setMiscReg(MISCREG_CCR_XCC_C, 1);
181 regs->setIntReg(ReturnValueReg, return_value.value());
187 #endif // __ARCH_SPARC_ISA_TRAITS_HH__