gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
isa.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  *
28  * Authors: Gabe Black
29  */
30 
31 #ifndef __ARCH_X86_ISA_HH__
32 #define __ARCH_X86_ISA_HH__
33 
34 #include <iostream>
35 #include <string>
36 
37 #include "arch/generic/isa.hh"
38 #include "arch/x86/registers.hh"
39 #include "arch/x86/regs/float.hh"
40 #include "arch/x86/regs/misc.hh"
41 #include "base/types.hh"
42 #include "cpu/reg_class.hh"
43 #include "sim/sim_object.hh"
44 
45 class Checkpoint;
46 class EventManager;
47 class ThreadContext;
48 struct X86ISAParams;
49 
50 namespace X86ISA
51 {
52  class ISA : public BaseISA
53  {
54  protected:
56  void updateHandyM5Reg(Efer efer, CR0 cr0,
57  SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags,
58  ThreadContext *tc);
59 
60  public:
61  typedef X86ISAParams Params;
62 
63  void clear();
64 
65  ISA(Params *p);
66  const Params *params() const;
67 
68  RegVal readMiscRegNoEffect(int miscReg) const;
69  RegVal readMiscReg(int miscReg, ThreadContext *tc);
70 
71  void setMiscRegNoEffect(int miscReg, RegVal val);
72  void setMiscReg(int miscReg, RegVal val, ThreadContext *tc);
73 
74  RegId
75  flattenRegId(const RegId& regId) const
76  {
77  switch (regId.classValue()) {
78  case IntRegClass:
79  return RegId(IntRegClass, flattenIntIndex(regId.index()));
80  case FloatRegClass:
81  return RegId(FloatRegClass, flattenFloatIndex(regId.index()));
82  case CCRegClass:
83  return RegId(CCRegClass, flattenCCIndex(regId.index()));
84  case MiscRegClass:
85  return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
86  default:
87  break;
88  }
89  return regId;
90  }
91 
92  int
93  flattenIntIndex(int reg) const
94  {
95  return reg & ~IntFoldBit;
96  }
97 
98  int
100  {
101  if (reg >= NUM_FLOATREGS) {
102  reg = FLOATREG_STACK(reg - NUM_FLOATREGS,
103  regVal[MISCREG_X87_TOP]);
104  }
105  return reg;
106  }
107 
108  int
109  flattenVecIndex(int reg) const
110  {
111  return reg;
112  }
113 
114  int
116  {
117  return reg;
118  }
119 
120  int
122  {
123  return reg;
124  }
125 
126  int
127  flattenCCIndex(int reg) const
128  {
129  return reg;
130  }
131 
132  int
134  {
135  return reg;
136  }
137 
138  void serialize(CheckpointOut &cp) const override;
139  void unserialize(CheckpointIn &cp) override;
140 
141  void startup(ThreadContext *tc);
142 
144  using BaseISA::startup;
145 
146  };
147 }
148 
149 #endif
RegVal readMiscReg(int miscReg, ThreadContext *tc)
Definition: isa.cc:159
Bitfield< 5, 3 > reg
Definition: types.hh:89
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: isa.cc:424
Floating-point register.
Definition: reg_class.hh:58
int flattenVecIndex(int reg) const
Definition: isa.hh:109
const Params * params() const
Definition: isa.cc:142
Control (misc) register.
Definition: reg_class.hh:65
int flattenIntIndex(int reg) const
Definition: isa.hh:93
void updateHandyM5Reg(Efer efer, CR0 cr0, SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags, ThreadContext *tc)
Definition: isa.cc:44
int flattenCCIndex(int reg) const
Definition: isa.hh:127
uint64_t RegVal
Definition: types.hh:168
Definition: cprintf.cc:42
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Bitfield< 63 > val
Definition: misc.hh:771
void clear()
Definition: isa.cc:106
void setMiscReg(int miscReg, RegVal val, ThreadContext *tc)
Definition: isa.cc:223
RegVal readMiscRegNoEffect(int miscReg) const
Definition: isa.cc:148
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: isa.cc:430
void setMiscRegNoEffect(int miscReg, RegVal val)
Definition: isa.cc:181
Condition-code register.
Definition: reg_class.hh:64
RegId flattenRegId(const RegId &regId) const
Definition: isa.hh:75
static FloatRegIndex FLOATREG_STACK(int index, int top)
Definition: float.hh:149
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
RegVal regVal[NUM_MISCREGS]
Definition: isa.hh:55
int flattenVecPredIndex(int reg) const
Definition: isa.hh:121
static const IntRegIndex IntFoldBit
Definition: int.hh:153
std::ostream CheckpointOut
Definition: serialize.hh:68
This is exposed globally, independent of the ISA.
Definition: acpi.hh:57
const RegClass & classValue() const
Class accessor.
Definition: reg_class.hh:206
const RegIndex & index() const
Index accessors.
Definition: reg_class.hh:179
Register ID: describe an architectural register with its class and index.
Definition: reg_class.hh:79
Integer register.
Definition: reg_class.hh:57
Definition: isa.hh:35
Bitfield< 0 > p
Definition: pagetable.hh:152
int flattenMiscIndex(int reg) const
Definition: isa.hh:133
X86ISAParams Params
Definition: isa.hh:61
ISA(Params *p)
Definition: isa.cc:136
int flattenFloatIndex(int reg) const
Definition: isa.hh:99
int flattenVecElemIndex(int reg) const
Definition: isa.hh:115
virtual void startup()
startup() is the final initialization call before simulation.
Definition: sim_object.cc:99

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13