Deleted Added
sdiff udiff text old ( 10824:308771bd2647 ) new ( 10905:a6ca6831e775 )
full compact
1/*
2 * Copyright (c) 2007-2008 The Hewlett-Packard Development Company
3 * All rights reserved.
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 48 unchanged lines hidden (view full) ---

57#include "mem/packet_access.hh"
58#include "mem/page_table.hh"
59#include "mem/request.hh"
60#include "sim/full_system.hh"
61#include "sim/process.hh"
62
63namespace X86ISA {
64
65TLB::TLB(const Params *p) : BaseTLB(p), configAddress(0), size(p->size),
66 lruSeq(0)
67{
68 if (!size)
69 fatal("TLBs must have a non-zero size.\n");
70 tlb = new TlbEntry[size];
71 std::memset(tlb, 0, sizeof(TlbEntry) * size);
72
73 for (int x = 0; x < size; x++) {
74 tlb[x].trieHandle = NULL;
75 freeList.push_back(&tlb[x]);
76 }
77
78 walker = p->walker;
79 walker->setTLB(this);

--- 366 unchanged lines hidden (view full) ---

446
447Walker *
448TLB::getWalker()
449{
450 return walker;
451}
452
453void
454TLB::serialize(std::ostream &os)
455{
456 // Only store the entries in use.
457 uint32_t _size = size - freeList.size();
458 SERIALIZE_SCALAR(_size);
459 SERIALIZE_SCALAR(lruSeq);
460
461 uint32_t _count = 0;
462
463 for (uint32_t x = 0; x < size; x++) {
464 if (tlb[x].trieHandle != NULL) {
465 os << "\n[" << csprintf("%s.Entry%d", name(), _count) << "]\n";
466 tlb[x].serialize(os);
467 _count++;
468 }
469 }
470}
471
472void
473TLB::unserialize(Checkpoint *cp, const std::string &section)
474{
475 // Do not allow to restore with a smaller tlb.
476 uint32_t _size;
477 UNSERIALIZE_SCALAR(_size);
478 if (_size > size) {
479 fatal("TLB size less than the one in checkpoint!");
480 }
481
482 UNSERIALIZE_SCALAR(lruSeq);
483
484 for (uint32_t x = 0; x < _size; x++) {
485 TlbEntry *newEntry = freeList.front();
486 freeList.pop_front();
487
488 newEntry->unserialize(cp, csprintf("%s.Entry%d", name(), x));
489 newEntry->trieHandle = trie.insert(newEntry->vaddr,
490 TlbEntryTrie::MaxBits - newEntry->logBytes, newEntry);
491 }
492}
493
494BaseMasterPort *
495TLB::getMasterPort()
496{
497 return &walker->getMasterPort("port");
498}
499
500} // namespace X86ISA
501
502X86ISA::TLB *
503X86TLBParams::create()
504{
505 return new X86ISA::TLB(this);
506}