tlb.hh (5242:280a99136427) | tlb.hh (5245:d94bb8af9f76) |
---|---|
1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * All rights reserved. 4 * 5 * Redistribution and use of this software in source and binary forms, 6 * with or without modification, are permitted provided that the 7 * following conditions are met: 8 * --- 63 unchanged lines hidden (view full) --- 72#include "sim/faults.hh" 73#include "sim/sim_object.hh" 74 75class ThreadContext; 76class Packet; 77 78namespace X86ISA 79{ | 1/* 2 * Copyright (c) 2007 The Hewlett-Packard Development Company 3 * All rights reserved. 4 * 5 * Redistribution and use of this software in source and binary forms, 6 * with or without modification, are permitted provided that the 7 * following conditions are met: 8 * --- 63 unchanged lines hidden (view full) --- 72#include "sim/faults.hh" 73#include "sim/sim_object.hh" 74 75class ThreadContext; 76class Packet; 77 78namespace X86ISA 79{ |
80 class Walker; 81 |
|
80 static const unsigned StoreCheck = 1 << NUM_SEGMENTREGS; 81 82 class TLB; 83 | 82 static const unsigned StoreCheck = 1 << NUM_SEGMENTREGS; 83 84 class TLB; 85 |
84 class TLB : public MemObject | 86 class TLB : public SimObject |
85 { 86 protected: 87 friend class FakeITLBFault; 88 friend class FakeDTLBFault; 89 | 87 { 88 protected: 89 friend class FakeITLBFault; 90 friend class FakeDTLBFault; 91 |
90 System * sys; | 92 bool _allowNX; |
91 | 93 |
92 bool allowNX; 93 | |
94 public: | 94 public: |
95 bool allowNX() const 96 { 97 return _allowNX; 98 } 99 |
|
95 typedef X86TLBParams Params; 96 TLB(const Params *p); 97 98 void dumpAll(); 99 100 TlbEntry *lookup(Addr va, bool update_lru = true); 101 102#if FULL_SYSTEM 103 protected: | 100 typedef X86TLBParams Params; 101 TLB(const Params *p); 102 103 void dumpAll(); 104 105 TlbEntry *lookup(Addr va, bool update_lru = true); 106 107#if FULL_SYSTEM 108 protected: |
104 class Walker 105 { 106 public: 107 enum State { 108 Ready, 109 Waiting, 110 LongPML4, 111 LongPDP, 112 LongPD, 113 LongPTE, 114 PAEPDP, 115 PAEPD, 116 PAEPTE, 117 PSEPD, 118 PD, 119 PTE 120 }; | |
121 | 109 |
122 // Act on the current state and determine what to do next. read 123 // should be the packet that just came back from a read and write 124 // should be NULL. When the function returns, read is either NULL 125 // if the machine is finished, or points to a packet to initiate 126 // the next read. If any write is required to update an "accessed" 127 // bit, write will point to a packet to do the write. Otherwise it 128 // will be NULL. 129 void doNext(PacketPtr &read, PacketPtr &write); | 110 Walker * walker; |
130 | 111 |
131 // Kick off the state machine. 132 void start(ThreadContext * _tc, Addr vaddr); 133 134 protected: 135 friend class TLB; 136 137 /* 138 * State having to do with sending packets. 139 */ 140 PacketPtr read; 141 std::vector<PacketPtr> writes; 142 143 // How many memory operations are in flight. 144 unsigned inflight; 145 146 bool retrying; 147 148 /* 149 * Functions for dealing with packets. 150 */ 151 bool recvTiming(PacketPtr pkt); 152 void recvRetry(); 153 154 void sendPackets(); 155 156 /* 157 * Port for accessing memory 158 */ 159 class WalkerPort : public Port 160 { 161 public: 162 WalkerPort(const std::string &_name, Walker * _walker) : 163 Port(_name, _walker->tlb), walker(_walker), 164 snoopRangeSent(false) 165 {} 166 167 protected: 168 Walker * walker; 169 170 bool snoopRangeSent; 171 172 bool recvTiming(PacketPtr pkt); 173 Tick recvAtomic(PacketPtr pkt); 174 void recvFunctional(PacketPtr pkt); 175 void recvStatusChange(Status status); 176 void recvRetry(); 177 void getDeviceAddressRanges(AddrRangeList &resp, 178 bool &snoop) 179 { 180 resp.clear(); 181 snoop = true; 182 } 183 }; 184 185 friend class WalkerPort; 186 187 WalkerPort port; 188 189 // The TLB we're supposed to load. 190 TLB * tlb; 191 192 /* 193 * State machine state. 194 */ 195 ThreadContext * tc; 196 State state; 197 State nextState; 198 int size; 199 bool enableNX; 200 TlbEntry entry; 201 202 public: 203 Walker(const std::string &_name, TLB * _tlb) : 204 read(NULL), inflight(0), retrying(false), 205 port(_name + "-walker_port", this), 206 tlb(_tlb), 207 tc(NULL), state(Ready), nextState(Ready) 208 { 209 } 210 }; 211 212 Walker walker; 213 | 112 void walk(ThreadContext * _tc, Addr vaddr); |
214#endif 215 | 113#endif 114 |
216 Port *getPort(const std::string &if_name, int idx = -1); 217 | |
218 public: 219 void invalidateAll(); 220 221 void invalidateNonGlobal(); 222 223 void demapPage(Addr va); 224 225 protected: 226 int size; 227 228 TlbEntry * tlb; 229 230 typedef std::list<TlbEntry *> EntryList; 231 EntryList freeList; 232 EntryList entryList; 233 | 115 public: 116 void invalidateAll(); 117 118 void invalidateNonGlobal(); 119 120 void demapPage(Addr va); 121 122 protected: 123 int size; 124 125 TlbEntry * tlb; 126 127 typedef std::list<TlbEntry *> EntryList; 128 EntryList freeList; 129 EntryList entryList; 130 |
234 void insert(Addr vpn, TlbEntry &entry); 235 | |
236 template<class TlbFault> 237 Fault translate(RequestPtr &req, ThreadContext *tc, 238 bool write, bool execute); 239 240 public: | 131 template<class TlbFault> 132 Fault translate(RequestPtr &req, ThreadContext *tc, 133 bool write, bool execute); 134 135 public: |
136 137 void insert(Addr vpn, TlbEntry &entry); 138 |
|
241 // Checkpointing 242 virtual void serialize(std::ostream &os); 243 virtual void unserialize(Checkpoint *cp, const std::string §ion); 244 }; 245 246 class ITB : public TLB 247 { 248 public: 249 typedef X86ITBParams Params; 250 ITB(const Params *p) : TLB(p) 251 { | 139 // Checkpointing 140 virtual void serialize(std::ostream &os); 141 virtual void unserialize(Checkpoint *cp, const std::string §ion); 142 }; 143 144 class ITB : public TLB 145 { 146 public: 147 typedef X86ITBParams Params; 148 ITB(const Params *p) : TLB(p) 149 { |
252 sys = p->system; 253 allowNX = false; | 150 _allowNX = false; |
254 } 255 256 Fault translate(RequestPtr &req, ThreadContext *tc); 257 258 friend class DTB; 259 }; 260 261 class DTB : public TLB 262 { 263 public: 264 typedef X86DTBParams Params; 265 DTB(const Params *p) : TLB(p) 266 { | 151 } 152 153 Fault translate(RequestPtr &req, ThreadContext *tc); 154 155 friend class DTB; 156 }; 157 158 class DTB : public TLB 159 { 160 public: 161 typedef X86DTBParams Params; 162 DTB(const Params *p) : TLB(p) 163 { |
267 sys = p->system; 268 allowNX = true; | 164 _allowNX = true; |
269 } 270 Fault translate(RequestPtr &req, ThreadContext *tc, bool write); 271#if FULL_SYSTEM 272 Tick doMmuRegRead(ThreadContext *tc, Packet *pkt); 273 Tick doMmuRegWrite(ThreadContext *tc, Packet *pkt); 274#endif 275 276 // Checkpointing 277 virtual void serialize(std::ostream &os); 278 virtual void unserialize(Checkpoint *cp, const std::string §ion); 279 }; 280} 281 282#endif // __ARCH_X86_TLB_HH__ | 165 } 166 Fault translate(RequestPtr &req, ThreadContext *tc, bool write); 167#if FULL_SYSTEM 168 Tick doMmuRegRead(ThreadContext *tc, Packet *pkt); 169 Tick doMmuRegWrite(ThreadContext *tc, Packet *pkt); 170#endif 171 172 // Checkpointing 173 virtual void serialize(std::ostream &os); 174 virtual void unserialize(Checkpoint *cp, const std::string §ion); 175 }; 176} 177 178#endif // __ARCH_X86_TLB_HH__ |