Deleted Added
sdiff udiff text old ( 4762:c94e103c83ad ) new ( 4957:f858d0b8ef99 )
full compact
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;

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

59
60#define MODE2MASK(X) (1 << (X))
61
62TLB::TLB(const string &name, int s)
63 : SimObject(name), size(s), nlu(0)
64{
65 table = new PTE[size];
66 memset(table, 0, sizeof(PTE[size]));
67}
68
69TLB::~TLB()
70{
71 if (table)
72 delete [] table;
73}
74
75// look up an entry in the TLB
76PTE *
77TLB::lookup(Addr vpn, uint8_t asn) const
78{
79 // assume not found...
80 PTE *retval = NULL;
81
82 PageTable::const_iterator i = lookupTable.find(vpn);
83 if (i != lookupTable.end()) {
84 while (i->first == vpn) {
85 int index = i->second;
86 PTE *pte = &table[index];
87 assert(pte->valid);
88 if (vpn == pte->tag && (pte->asma || pte->asn == asn)) {
89 retval = pte;
90 break;
91 }
92
93 ++i;
94 }
95 }
96
97 DPRINTF(TLB, "lookup %#x, asn %#x -> %s ppn %#x\n", vpn, (int)asn,
98 retval ? "hit" : "miss", retval ? retval->ppn : 0);
99 return retval;
100}
101

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

137 return NoFault;
138}
139
140
141// insert a new TLB entry
142void
143TLB::insert(Addr addr, PTE &pte)
144{
145 VAddr vaddr = addr;
146 if (table[nlu].valid) {
147 Addr oldvpn = table[nlu].tag;
148 PageTable::iterator i = lookupTable.find(oldvpn);
149
150 if (i == lookupTable.end())
151 panic("TLB entry not found in lookupTable");
152

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

173 nextnlu();
174}
175
176void
177TLB::flushAll()
178{
179 DPRINTF(TLB, "flushAll\n");
180 memset(table, 0, sizeof(PTE[size]));
181 lookupTable.clear();
182 nlu = 0;
183}
184
185void
186TLB::flushProcesses()
187{
188 PageTable::iterator i = lookupTable.begin();
189 PageTable::iterator end = lookupTable.end();
190 while (i != end) {
191 int index = i->second;
192 PTE *pte = &table[index];
193 assert(pte->valid);
194
195 // we can't increment i after we erase it, so save a copy and

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

203 lookupTable.erase(cur);
204 }
205 }
206}
207
208void
209TLB::flushAddr(Addr addr, uint8_t asn)
210{
211 VAddr vaddr = addr;
212
213 PageTable::iterator i = lookupTable.find(vaddr.vpn());
214 if (i == lookupTable.end())
215 return;
216
217 while (i != lookupTable.end() && i->first == vaddr.vpn()) {
218 int index = i->second;

--- 396 unchanged lines hidden ---