2 * Copyright (c) 2003-2006 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 * Copyright (c) 2007 The Hewlett-Packard Development Company
33 * All rights reserved.
35 * Redistribution and use of this software in source and binary forms,
36 * with or without modification, are permitted provided that the
37 * following conditions are met:
39 * The software must be used only for Non-Commercial Use which means any
40 * use which is NOT directed to receiving any direct monetary
41 * compensation for, or commercial advantage from such use. Illustrative
42 * examples of non-commercial use are academic research, personal study,
43 * teaching, education and corporate research & development.
44 * Illustrative examples of commercial use are distributing products for
45 * commercial advantage and providing services using the software for
46 * commercial advantage.
48 * If you wish to use this software or functionality therein that may be
49 * covered by patents for commercial use, please contact:
50 * Director of Intellectual Property Licensing
51 * Office of Strategy and Technology
52 * Hewlett-Packard Company
54 * Palo Alto, California 94304
56 * Redistributions of source code must retain the above copyright notice,
57 * this list of conditions and the following disclaimer. Redistributions
58 * in binary form must reproduce the above copyright notice, this list of
59 * conditions and the following disclaimer in the documentation and/or
60 * other materials provided with the distribution. Neither the name of
61 * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
62 * contributors may be used to endorse or promote products derived from
63 * this software without specific prior written permission. No right of
64 * sublicense is granted herewith. Derivatives of the software and
65 * output created using the software may be prepared, but only for
66 * Non-Commercial Uses. Derivatives of the software may be shared with
67 * others provided: (i) the others agree to abide by the list of
68 * conditions herein which includes the Non-Commercial Use restrictions;
69 * and (ii) such Derivatives of the software include the above copyright
70 * notice to acknowledge the contribution from this software where
71 * applicable, this list of conditions and the disclaimer below.
73 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
74 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
75 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
76 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
77 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
78 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
79 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
80 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
81 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
82 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
83 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88 #include "arch/x86/regfile.hh"
89 #include "sim/serialize.hh"
90 #include "cpu/thread_context.hh"
94 using namespace X86ISA
;
97 //RegFile class methods
98 Addr
RegFile::readPC()
103 void RegFile::setPC(Addr val
)
108 Addr
RegFile::readNextPC()
113 void RegFile::setNextPC(Addr val
)
118 Addr
RegFile::readNextNPC()
120 //There's no way to know how big the -next- instruction will be.
124 void RegFile::setNextNPC(Addr val
)
127 void RegFile::clear()
129 floatRegFile
.clear();
134 MiscReg
RegFile::readMiscRegNoEffect(int miscReg
)
136 return miscRegFile
.readRegNoEffect(miscReg
);
139 MiscReg
RegFile::readMiscReg(int miscReg
, ThreadContext
*tc
)
141 return miscRegFile
.readReg(miscReg
, tc
);
144 void RegFile::setMiscRegNoEffect(int miscReg
, const MiscReg
&val
)
146 miscRegFile
.setRegNoEffect(miscReg
, val
);
149 void RegFile::setMiscReg(int miscReg
, const MiscReg
&val
,
152 miscRegFile
.setReg(miscReg
, val
, tc
);
155 FloatReg
RegFile::readFloatReg(int floatReg
, int width
)
157 return floatRegFile
.readReg(floatReg
, width
);
160 FloatReg
RegFile::readFloatReg(int floatReg
)
162 //Use the "natural" width of a single float
163 return floatRegFile
.readReg(floatReg
, FloatRegFile::SingleWidth
);
166 FloatRegBits
RegFile::readFloatRegBits(int floatReg
, int width
)
168 return floatRegFile
.readRegBits(floatReg
, width
);
171 FloatRegBits
RegFile::readFloatRegBits(int floatReg
)
173 //Use the "natural width of a single float
174 return floatRegFile
.readRegBits(floatReg
,
175 FloatRegFile::SingleWidth
);
178 void RegFile::setFloatReg(int floatReg
, const FloatReg
&val
, int width
)
180 floatRegFile
.setReg(floatReg
, val
, width
);
183 void RegFile::setFloatReg(int floatReg
, const FloatReg
&val
)
185 //Use the "natural" width of a single float
186 setFloatReg(floatReg
, val
, FloatRegFile::SingleWidth
);
189 void RegFile::setFloatRegBits(int floatReg
, const FloatRegBits
&val
, int width
)
191 floatRegFile
.setRegBits(floatReg
, val
, width
);
194 void RegFile::setFloatRegBits(int floatReg
, const FloatRegBits
&val
)
196 //Use the "natural" width of a single float
197 floatRegFile
.setRegBits(floatReg
, val
, FloatRegFile::SingleWidth
);
200 IntReg
RegFile::readIntReg(int intReg
)
202 return intRegFile
.readReg(intReg
);
205 void RegFile::setIntReg(int intReg
, const IntReg
&val
)
207 intRegFile
.setReg(intReg
, val
);
210 int X86ISA::flattenIntIndex(ThreadContext
* tc
, int reg
)
212 //For right now, don't do any flattening
216 void RegFile::serialize(std::ostream
&os
)
218 intRegFile
.serialize(os
);
219 floatRegFile
.serialize(os
);
220 miscRegFile
.serialize(os
);
221 SERIALIZE_SCALAR(rip
);
222 SERIALIZE_SCALAR(nextRip
);
225 void RegFile::unserialize(Checkpoint
*cp
, const std::string
§ion
)
227 intRegFile
.unserialize(cp
, section
);
228 floatRegFile
.unserialize(cp
, section
);
229 miscRegFile
.unserialize(cp
, section
);
230 UNSERIALIZE_SCALAR(rip
);
231 UNSERIALIZE_SCALAR(nextRip
);
234 void RegFile::changeContext(RegContextParam param
, RegContextVal val
)
236 panic("changeContext not implemented for x86!\n");
239 void X86ISA::copyMiscRegs(ThreadContext
*src
, ThreadContext
*dest
)
241 panic("copyMiscRegs not implemented for x86!\n");
244 void X86ISA::copyRegs(ThreadContext
*src
, ThreadContext
*dest
)
246 panic("copyRegs not implemented for x86!\n");
249 copyMiscRegs(src
, dest
);
251 dest
->setPC(src
->readPC());
252 dest
->setNextPC(src
->readNextPC());