tlb.cc (10824:308771bd2647) | tlb.cc (10905:a6ca6831e775) |
---|---|
1/* 2 * Copyright (c) 2001-2005 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; --- 16 unchanged lines hidden (view full) --- 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: Nathan Binkert 29 * Steve Reinhardt 30 * Andrew Schultz 31 */ 32 | 1/* 2 * Copyright (c) 2001-2005 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; --- 16 unchanged lines hidden (view full) --- 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: Nathan Binkert 29 * Steve Reinhardt 30 * Andrew Schultz 31 */ 32 |
33#include "arch/alpha/tlb.hh" 34 35#include <algorithm> |
|
33#include <memory> 34#include <string> 35#include <vector> 36 37#include "arch/alpha/faults.hh" 38#include "arch/alpha/pagetable.hh" | 36#include <memory> 37#include <string> 38#include <vector> 39 40#include "arch/alpha/faults.hh" 41#include "arch/alpha/pagetable.hh" |
39#include "arch/alpha/tlb.hh" | |
40#include "arch/generic/debugfaults.hh" 41#include "base/inifile.hh" 42#include "base/str.hh" 43#include "base/trace.hh" 44#include "cpu/thread_context.hh" 45#include "debug/TLB.hh" 46#include "sim/full_system.hh" 47 --- 9 unchanged lines hidden (view full) --- 57#ifdef DEBUG 58bool uncacheBit39 = false; 59bool uncacheBit40 = false; 60#endif 61 62#define MODE2MASK(X) (1 << (X)) 63 64TLB::TLB(const Params *p) | 42#include "arch/generic/debugfaults.hh" 43#include "base/inifile.hh" 44#include "base/str.hh" 45#include "base/trace.hh" 46#include "cpu/thread_context.hh" 47#include "debug/TLB.hh" 48#include "sim/full_system.hh" 49 --- 9 unchanged lines hidden (view full) --- 59#ifdef DEBUG 60bool uncacheBit39 = false; 61bool uncacheBit40 = false; 62#endif 63 64#define MODE2MASK(X) (1 << (X)) 65 66TLB::TLB(const Params *p) |
65 : BaseTLB(p), size(p->size), nlu(0) | 67 : BaseTLB(p), table(p->size), nlu(0) |
66{ | 68{ |
67 table = new TlbEntry[size]; 68 memset(table, 0, sizeof(TlbEntry) * size); | |
69 flushCache(); 70} 71 72TLB::~TLB() 73{ | 69 flushCache(); 70} 71 72TLB::~TLB() 73{ |
74 if (table) 75 delete [] table; | |
76} 77 78void 79TLB::regStats() 80{ 81 fetch_hits 82 .name(name() + ".fetch_hits") 83 .desc("ITB hits"); --- 194 unchanged lines hidden (view full) --- 278 lookupTable.insert(make_pair(vaddr.vpn(), nlu)); 279 nextnlu(); 280} 281 282void 283TLB::flushAll() 284{ 285 DPRINTF(TLB, "flushAll\n"); | 74} 75 76void 77TLB::regStats() 78{ 79 fetch_hits 80 .name(name() + ".fetch_hits") 81 .desc("ITB hits"); --- 194 unchanged lines hidden (view full) --- 276 lookupTable.insert(make_pair(vaddr.vpn(), nlu)); 277 nextnlu(); 278} 279 280void 281TLB::flushAll() 282{ 283 DPRINTF(TLB, "flushAll\n"); |
286 memset(table, 0, sizeof(TlbEntry) * size); | 284 std::fill(table.begin(), table.end(), TlbEntry()); |
287 flushCache(); 288 lookupTable.clear(); 289 nlu = 0; 290} 291 292void 293TLB::flushProcesses() 294{ --- 45 unchanged lines hidden (view full) --- 340 } else { 341 ++i; 342 } 343 } 344} 345 346 347void | 285 flushCache(); 286 lookupTable.clear(); 287 nlu = 0; 288} 289 290void 291TLB::flushProcesses() 292{ --- 45 unchanged lines hidden (view full) --- 338 } else { 339 ++i; 340 } 341 } 342} 343 344 345void |
348TLB::serialize(ostream &os) | 346TLB::serialize(CheckpointOut &cp) const |
349{ | 347{ |
348 const unsigned size(table.size()); |
|
350 SERIALIZE_SCALAR(size); 351 SERIALIZE_SCALAR(nlu); 352 | 349 SERIALIZE_SCALAR(size); 350 SERIALIZE_SCALAR(nlu); 351 |
353 for (int i = 0; i < size; i++) { 354 nameOut(os, csprintf("%s.Entry%d", name(), i)); 355 table[i].serialize(os); 356 } | 352 for (int i = 0; i < size; i++) 353 table[i].serializeSection(cp, csprintf("Entry%d", i)); |
357} 358 359void | 354} 355 356void |
360TLB::unserialize(Checkpoint *cp, const string §ion) | 357TLB::unserialize(CheckpointIn &cp) |
361{ | 358{ |
359 unsigned size(0); |
|
362 UNSERIALIZE_SCALAR(size); 363 UNSERIALIZE_SCALAR(nlu); 364 | 360 UNSERIALIZE_SCALAR(size); 361 UNSERIALIZE_SCALAR(nlu); 362 |
363 table.resize(size); |
|
365 for (int i = 0; i < size; i++) { | 364 for (int i = 0; i < size; i++) { |
366 table[i].unserialize(cp, csprintf("%s.Entry%d", section, i)); | 365 table[i].unserializeSection(cp, csprintf("Entry%d", i)); |
367 if (table[i].valid) { 368 lookupTable.insert(make_pair(table[i].tag, i)); 369 } 370 } 371} 372 373Fault 374TLB::translateInst(RequestPtr req, ThreadContext *tc) --- 262 unchanged lines hidden --- | 366 if (table[i].valid) { 367 lookupTable.insert(make_pair(table[i].tag, i)); 368 } 369 } 370} 371 372Fault 373TLB::translateInst(RequestPtr req, ThreadContext *tc) --- 262 unchanged lines hidden --- |