tlb.cc (10824:308771bd2647) tlb.cc (10905:a6ca6831e775)
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
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)
65TLB::TLB(const Params *p)
66 : BaseTLB(p), configAddress(0), size(p->size),
67 tlb(size), lruSeq(0)
67{
68 if (!size)
69 fatal("TLBs must have a non-zero size.\n");
68{
69 if (!size)
70 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
71
72 for (int x = 0; x < size; x++) {
73 tlb[x].trieHandle = NULL;
74 freeList.push_back(&tlb[x]);
75 }
76
77 walker = p->walker;
78 walker->setTLB(this);

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

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