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.
32 #ifndef __ARCH_MIPS_ISA_TRAITS_HH__
33 #define __ARCH_MIPS_ISA_TRAITS_HH__
35 #include "arch/mips/constants.hh"
36 #include "arch/mips/types.hh"
37 #include "arch/mips/regfile/regfile.hh"
38 #include "arch/mips/faults.hh"
39 #include "arch/mips/utility.hh"
40 #include "base/misc.hh"
41 #include "config/full_system.hh"
42 #include "sim/byteswap.hh"
43 #include "sim/host.hh"
44 #include "sim/faults.hh"
53 namespace LittleEndianGuest {};
61 int DTB_ASN_ASN(uint64_t reg);
62 int ITB_ASN_ASN(uint64_t reg);
69 SyscallReturn(T v, bool s)
84 SyscallReturn& operator=(const SyscallReturn& s) {
90 bool successful() { return success; }
91 uint64_t value() { return retval; }
102 using namespace LittleEndianGuest;
104 static inline void setSyscallReturn(SyscallReturn return_value, RegFile *regs)
106 if (return_value.successful()) {
108 regs->setIntReg(SyscallSuccessReg, 0);
109 regs->setIntReg(ReturnValueReg1, return_value.value());
111 // got an error, return details
112 regs->setIntReg(SyscallSuccessReg, (IntReg) -1);
113 regs->setIntReg(ReturnValueReg1, -return_value.value());
117 StaticInstPtr decodeInst(ExtMachInst);
119 static inline ExtMachInst
120 makeExtMI(MachInst inst, const uint64_t &pc) {
122 ExtMachInst ext_inst = inst;
124 return ext_inst|=(static_cast<ExtMachInst>(pc & 0x1) << 32);
128 return ExtMachInst(inst);
133 * Function to insure ISA semantics about 0 registers.
134 * @param tc The thread context.
137 void zeroRegisters(TC *tc);
139 const Addr MaxAddr = (Addr)-1;
141 void copyRegs(ThreadContext *src, ThreadContext *dest);
143 uint64_t fpConvert(double fp_val, ConvertType cvt_type);
144 double roundFP(double val, int digits);
145 double truncFP(double val);
146 bool getFPConditionCode(uint32_t fcsr_reg, int cc);
147 uint32_t makeCCVector(uint32_t fcsr, int num, bool val);
149 // Machine operations
151 void saveMachineReg(AnyReg &savereg, const RegFile ®_file,
154 void restoreMachineReg(RegFile ®s, const AnyReg ®,
158 static void serializeSpecialRegs(const Serializable::Proxy &proxy,
159 const RegFile ®s);
161 static void unserializeSpecialRegs(const IniFile *db,
162 const std::string &category,
167 static inline Addr alignAddress(const Addr &addr,
168 unsigned int nbytes) {
169 return (addr & ~(nbytes - 1));
172 // Instruction address compression hooks
173 static inline Addr realPCToFetchPC(const Addr &addr) {
177 static inline Addr fetchPCToRealPC(const Addr &addr) {
181 // the size of "fetched" instructions (not necessarily the size
182 // of real instructions for PISA)
183 static inline size_t fetchInstSize() {
184 return sizeof(MachInst);
187 static inline MachInst makeRegisterCopy(int dest, int src) {
188 panic("makeRegisterCopy not implemented");
196 #include "arch/mips/mips34k.hh"
200 using namespace MipsISA;
202 #endif // __ARCH_MIPS_ISA_TRAITS_HH__