f577a1c94652637ecdaeb9cd207d20ba2a38f935
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 #include "arch/mips/isa_traits.hh"
33 #include "config/full_system.hh"
34 #include "cpu/static_inst.hh"
35 #include "sim/serialize.hh"
36 #include "base/bitfield.hh"
38 using namespace MipsISA
;
43 MipsISA::copyRegs(ExecContext
*src
, ExecContext
*dest
)
45 /*fpcr = xc->readMiscReg(MipsISA::Fpcr_DepTag);
46 uniq = xc->readMiscReg(MipsISA::Uniq_DepTag);
47 lock_flag = xc->readMiscReg(MipsISA::Lock_Flag_DepTag);
48 lock_addr = xc->readMiscReg(MipsISA::Lock_Addr_DepTag);
56 MipsISA::MiscRegFile::copyMiscRegs(ExecContext
*xc
)
58 /*fpcr = xc->readMiscReg(MipsISA::Fpcr_DepTag);
59 uniq = xc->readMiscReg(MipsISA::Uniq_DepTag);
60 lock_flag = xc->readMiscReg(MipsISA::Lock_Flag_DepTag);
61 lock_addr = xc->readMiscReg(MipsISA::Lock_Addr_DepTag);
67 MipsISA::fpConvert(double fp_val
, ConvertType cvt_type
)
72 case SINGLE_TO_DOUBLE
:
73 double sdouble_val
= fp_val
;
74 void *sdouble_ptr
= &sdouble_val
;
75 uint64_t sdp_bits
= *(uint64_t *) sdouble_ptr
;
79 int32_t sword_val
= (int32_t) fp_val
;
80 void *sword_ptr
= &sword_val
;
81 uint64_t sword_bits
= *(uint32_t *) sword_ptr
;
85 float wfloat_val
= fp_val
;
86 void *wfloat_ptr
= &wfloat_val
;
87 uint64_t wfloat_bits
= *(uint32_t *) wfloat_ptr
;
91 double wdouble_val
= fp_val
;
92 void *wdouble_ptr
= &wdouble_val
;
93 uint64_t wdp_bits
= *(uint64_t *) wdouble_ptr
;
97 panic("Invalid Floating Point Conversion Type (%d). See \"types.hh\" for List of Conversions\n",cvt_type
);
103 MipsISA::roundFP(double val
, int digits
)
105 double digit_offset
= pow(10.0,digits
);
106 val
= val
* digit_offset
;
109 val
= val
/ digit_offset
;
114 MipsISA::truncFP(double val
)
116 int trunc_val
= (int) val
;
117 return (double) trunc_val
;
121 MipsISA::getFPConditionCode(uint32_t fcsr_reg
, int cc
)
123 //uint32_t cc_bits = xc->readFloatReg(35);
124 return false;//regFile.floatRegfile.getConditionCode(cc);
128 MipsISA::makeCCVector(uint32_t fcsr
, int num
, bool val
)
130 int shift
= (num
== 0) ? 22 : num
+ 23;
132 fcsr
= fcsr
| (val
<< shift
);
141 { return addr
& ~(MipsISA::PageBytes
- 1); }
145 { return (addr
+ MipsISA::PageBytes
- 1) & ~(MipsISA::PageBytes
- 1); }
149 IntRegFile::serialize(std::ostream
&os
)
151 SERIALIZE_ARRAY(regs
, NumIntRegs
);
155 IntRegFile::unserialize(Checkpoint
*cp
, const std::string
§ion
)
157 UNSERIALIZE_ARRAY(regs
, NumIntRegs
);
161 RegFile::serialize(std::ostream
&os
)
163 intRegFile
.serialize(os
);
164 //SERIALIZE_ARRAY(floatRegFile.q, NumFloatRegs);
165 //SERIALIZE_SCALAR(miscRegs.fpcr);
166 //SERIALIZE_SCALAR(miscRegs.uniq);
167 //SERIALIZE_SCALAR(miscRegs.lock_flag);
168 //SERIALIZE_SCALAR(miscRegs.lock_addr);
169 SERIALIZE_SCALAR(pc
);
170 SERIALIZE_SCALAR(npc
);
171 SERIALIZE_SCALAR(nnpc
);
173 SERIALIZE_ARRAY(palregs
, NumIntRegs
);
174 SERIALIZE_ARRAY(ipr
, NumInternalProcRegs
);
175 SERIALIZE_SCALAR(intrflag
);
176 SERIALIZE_SCALAR(pal_shadow
);
182 RegFile::unserialize(Checkpoint
*cp
, const std::string
§ion
)
184 intRegFile
.unserialize(cp
, section
);
185 //UNSERIALIZE_ARRAY(floatRegFile.q, NumFloatRegs);
186 //UNSERIALIZE_SCALAR(miscRegs.fpcr);
187 //UNSERIALIZE_SCALAR(miscRegs.uniq);
188 //UNSERIALIZE_SCALAR(miscRegs.lock_flag);
189 //UNSERIALIZE_SCALAR(miscRegs.lock_addr);
190 UNSERIALIZE_SCALAR(pc
);
191 UNSERIALIZE_SCALAR(npc
);
192 UNSERIALIZE_SCALAR(nnpc
);
194 UNSERIALIZE_ARRAY(palregs
, NumIntRegs
);
195 UNSERIALIZE_ARRAY(ipr
, NumInternalProcRegs
);
196 UNSERIALIZE_SCALAR(intrflag
);
197 UNSERIALIZE_SCALAR(pal_shadow
);
204 PTE::serialize(std::ostream
&os
)
206 SERIALIZE_SCALAR(tag
);
207 SERIALIZE_SCALAR(ppn
);
208 SERIALIZE_SCALAR(xre
);
209 SERIALIZE_SCALAR(xwe
);
210 SERIALIZE_SCALAR(asn
);
211 SERIALIZE_SCALAR(asma
);
212 SERIALIZE_SCALAR(fonr
);
213 SERIALIZE_SCALAR(fonw
);
214 SERIALIZE_SCALAR(valid
);
219 PTE::unserialize(Checkpoint
*cp
, const std::string
§ion
)
221 UNSERIALIZE_SCALAR(tag
);
222 UNSERIALIZE_SCALAR(ppn
);
223 UNSERIALIZE_SCALAR(xre
);
224 UNSERIALIZE_SCALAR(xwe
);
225 UNSERIALIZE_SCALAR(asn
);
226 UNSERIALIZE_SCALAR(asma
);
227 UNSERIALIZE_SCALAR(fonr
);
228 UNSERIALIZE_SCALAR(fonw
);
229 UNSERIALIZE_SCALAR(valid
);