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 #include "arch/mips/isa_traits.hh"
30 #include "config/full_system.hh"
31 #include "cpu/static_inst.hh"
32 #include "sim/serialize.hh"
33 #include "base/bitfield.hh"
35 using namespace MipsISA
;
40 MipsISA::copyRegs(ExecContext
*src
, ExecContext
*dest
)
42 /*fpcr = xc->readMiscReg(MipsISA::Fpcr_DepTag);
43 uniq = xc->readMiscReg(MipsISA::Uniq_DepTag);
44 lock_flag = xc->readMiscReg(MipsISA::Lock_Flag_DepTag);
45 lock_addr = xc->readMiscReg(MipsISA::Lock_Addr_DepTag);
53 MipsISA::MiscRegFile::copyMiscRegs(ExecContext
*xc
)
55 /*fpcr = xc->readMiscReg(MipsISA::Fpcr_DepTag);
56 uniq = xc->readMiscReg(MipsISA::Uniq_DepTag);
57 lock_flag = xc->readMiscReg(MipsISA::Lock_Flag_DepTag);
58 lock_addr = xc->readMiscReg(MipsISA::Lock_Addr_DepTag);
64 MipsISA::fpConvert(double fp_val
, ConvertType cvt_type
)
69 case SINGLE_TO_DOUBLE
:
70 double sdouble_val
= fp_val
;
71 void *sdouble_ptr
= &sdouble_val
;
72 uint64_t sdp_bits
= *(uint64_t *) sdouble_ptr
;
76 int32_t sword_val
= (int32_t) fp_val
;
77 void *sword_ptr
= &sword_val
;
78 uint64_t sword_bits
= *(uint32_t *) sword_ptr
;
82 float wfloat_val
= fp_val
;
83 void *wfloat_ptr
= &wfloat_val
;
84 uint64_t wfloat_bits
= *(uint32_t *) wfloat_ptr
;
88 double wdouble_val
= fp_val
;
89 void *wdouble_ptr
= &wdouble_val
;
90 uint64_t wdp_bits
= *(uint64_t *) wdouble_ptr
;
94 panic("Invalid Floating Point Conversion Type (%d). See \"types.hh\" for List of Conversions\n",cvt_type
);
100 MipsISA::roundFP(double val
, int digits
)
102 double digit_offset
= pow(10.0,digits
);
103 val
= val
* digit_offset
;
106 val
= val
/ digit_offset
;
111 MipsISA::truncFP(double val
)
113 int trunc_val
= (int) val
;
114 return (double) trunc_val
;
118 MipsISA::getFPConditionCode(uint32_t fcsr_reg
, int cc
)
120 //uint32_t cc_bits = xc->readFloatReg(35);
121 return false;//regFile.floatRegfile.getConditionCode(cc);
125 MipsISA::makeCCVector(uint32_t fcsr
, int num
, bool val
)
127 int shift
= (num
== 0) ? 22 : num
+ 23;
129 fcsr
= fcsr
| (val
<< shift
);
138 { return addr
& ~(MipsISA::PageBytes
- 1); }
142 { return (addr
+ MipsISA::PageBytes
- 1) & ~(MipsISA::PageBytes
- 1); }
146 IntRegFile::serialize(std::ostream
&os
)
148 SERIALIZE_ARRAY(regs
, NumIntRegs
);
152 IntRegFile::unserialize(Checkpoint
*cp
, const std::string
§ion
)
154 UNSERIALIZE_ARRAY(regs
, NumIntRegs
);
158 RegFile::serialize(std::ostream
&os
)
160 intRegFile
.serialize(os
);
161 //SERIALIZE_ARRAY(floatRegFile.q, NumFloatRegs);
162 //SERIALIZE_SCALAR(miscRegs.fpcr);
163 //SERIALIZE_SCALAR(miscRegs.uniq);
164 //SERIALIZE_SCALAR(miscRegs.lock_flag);
165 //SERIALIZE_SCALAR(miscRegs.lock_addr);
166 SERIALIZE_SCALAR(pc
);
167 SERIALIZE_SCALAR(npc
);
168 SERIALIZE_SCALAR(nnpc
);
170 SERIALIZE_ARRAY(palregs
, NumIntRegs
);
171 SERIALIZE_ARRAY(ipr
, NumInternalProcRegs
);
172 SERIALIZE_SCALAR(intrflag
);
173 SERIALIZE_SCALAR(pal_shadow
);
179 RegFile::unserialize(Checkpoint
*cp
, const std::string
§ion
)
181 intRegFile
.unserialize(cp
, section
);
182 //UNSERIALIZE_ARRAY(floatRegFile.q, NumFloatRegs);
183 //UNSERIALIZE_SCALAR(miscRegs.fpcr);
184 //UNSERIALIZE_SCALAR(miscRegs.uniq);
185 //UNSERIALIZE_SCALAR(miscRegs.lock_flag);
186 //UNSERIALIZE_SCALAR(miscRegs.lock_addr);
187 UNSERIALIZE_SCALAR(pc
);
188 UNSERIALIZE_SCALAR(npc
);
189 UNSERIALIZE_SCALAR(nnpc
);
191 UNSERIALIZE_ARRAY(palregs
, NumIntRegs
);
192 UNSERIALIZE_ARRAY(ipr
, NumInternalProcRegs
);
193 UNSERIALIZE_SCALAR(intrflag
);
194 UNSERIALIZE_SCALAR(pal_shadow
);
201 PTE::serialize(std::ostream
&os
)
203 SERIALIZE_SCALAR(tag
);
204 SERIALIZE_SCALAR(ppn
);
205 SERIALIZE_SCALAR(xre
);
206 SERIALIZE_SCALAR(xwe
);
207 SERIALIZE_SCALAR(asn
);
208 SERIALIZE_SCALAR(asma
);
209 SERIALIZE_SCALAR(fonr
);
210 SERIALIZE_SCALAR(fonw
);
211 SERIALIZE_SCALAR(valid
);
216 PTE::unserialize(Checkpoint
*cp
, const std::string
§ion
)
218 UNSERIALIZE_SCALAR(tag
);
219 UNSERIALIZE_SCALAR(ppn
);
220 UNSERIALIZE_SCALAR(xre
);
221 UNSERIALIZE_SCALAR(xwe
);
222 UNSERIALIZE_SCALAR(asn
);
223 UNSERIALIZE_SCALAR(asma
);
224 UNSERIALIZE_SCALAR(fonr
);
225 UNSERIALIZE_SCALAR(fonw
);
226 UNSERIALIZE_SCALAR(valid
);