Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 1 | /* |
Steve Reinhardt | ad8b963 | 2005-06-05 05:16:00 -0400 | [diff] [blame] | 2 | * Copyright (c) 2001-2005 The Regents of The University of Michigan |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 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; |
| 9 | * redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution; |
| 12 | * neither the name of the copyright holders nor the names of its |
| 13 | * contributors may be used to endorse or promote products derived from |
| 14 | * this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
Ali Saidi | cb0cf2d | 2006-05-31 19:26:56 -0400 | [diff] [blame] | 27 | * |
| 28 | * Authors: Nathan Binkert |
| 29 | * Steve Reinhardt |
| 30 | * Andrew Schultz |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 31 | */ |
| 32 | |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 33 | #include <string> |
| 34 | #include <vector> |
| 35 | |
Nathan Binkert | 39a0556 | 2011-04-15 10:44:06 -0700 | [diff] [blame] | 36 | #include "arch/alpha/faults.hh" |
Gabe Black | c9900f1 | 2006-08-15 04:46:51 -0400 | [diff] [blame] | 37 | #include "arch/alpha/pagetable.hh" |
Gabe Black | f1ef4a8 | 2006-02-27 06:05:10 -0500 | [diff] [blame] | 38 | #include "arch/alpha/tlb.hh" |
Steve Reinhardt | 25693e9 | 2003-10-10 11:09:00 -0700 | [diff] [blame] | 39 | #include "base/inifile.hh" |
| 40 | #include "base/str.hh" |
Nathan Binkert | e0b065f | 2003-10-20 20:17:01 -0400 | [diff] [blame] | 41 | #include "base/trace.hh" |
Kevin Lim | eb0e416 | 2006-06-06 17:32:21 -0400 | [diff] [blame] | 42 | #include "cpu/thread_context.hh" |
Nathan Binkert | eddac53 | 2011-04-15 10:44:32 -0700 | [diff] [blame^] | 43 | #include "debug/TLB.hh" |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 44 | |
| 45 | using namespace std; |
| 46 | |
Nathan Binkert | 06ae2d0 | 2007-02-21 16:42:16 -0800 | [diff] [blame] | 47 | namespace AlphaISA { |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 48 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 49 | /////////////////////////////////////////////////////////////////////// |
| 50 | // |
| 51 | // Alpha TLB |
| 52 | // |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 53 | |
Lisa Hsu | 1680097 | 2004-05-11 22:42:45 -0400 | [diff] [blame] | 54 | #ifdef DEBUG |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 55 | bool uncacheBit39 = false; |
| 56 | bool uncacheBit40 = false; |
Lisa Hsu | 1680097 | 2004-05-11 22:42:45 -0400 | [diff] [blame] | 57 | #endif |
| 58 | |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 59 | #define MODE2MASK(X) (1 << (X)) |
Nathan Binkert | 425dda0 | 2004-11-13 14:01:38 -0500 | [diff] [blame] | 60 | |
Miles Kaufmann | 54cc005 | 2007-08-30 15:16:59 -0400 | [diff] [blame] | 61 | TLB::TLB(const Params *p) |
Gabe Black | 8b4796a | 2008-02-26 23:38:51 -0500 | [diff] [blame] | 62 | : BaseTLB(p), size(p->size), nlu(0) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 63 | { |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 64 | table = new TlbEntry[size]; |
| 65 | memset(table, 0, sizeof(TlbEntry[size])); |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 66 | flushCache(); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 67 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 68 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 69 | TLB::~TLB() |
| 70 | { |
| 71 | if (table) |
| 72 | delete [] table; |
| 73 | } |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 74 | |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 75 | void |
| 76 | TLB::regStats() |
| 77 | { |
| 78 | fetch_hits |
| 79 | .name(name() + ".fetch_hits") |
| 80 | .desc("ITB hits"); |
| 81 | fetch_misses |
| 82 | .name(name() + ".fetch_misses") |
| 83 | .desc("ITB misses"); |
| 84 | fetch_acv |
| 85 | .name(name() + ".fetch_acv") |
| 86 | .desc("ITB acv"); |
| 87 | fetch_accesses |
| 88 | .name(name() + ".fetch_accesses") |
| 89 | .desc("ITB accesses"); |
| 90 | |
| 91 | fetch_accesses = fetch_hits + fetch_misses; |
| 92 | |
| 93 | read_hits |
| 94 | .name(name() + ".read_hits") |
| 95 | .desc("DTB read hits") |
| 96 | ; |
| 97 | |
| 98 | read_misses |
| 99 | .name(name() + ".read_misses") |
| 100 | .desc("DTB read misses") |
| 101 | ; |
| 102 | |
| 103 | read_acv |
| 104 | .name(name() + ".read_acv") |
| 105 | .desc("DTB read access violations") |
| 106 | ; |
| 107 | |
| 108 | read_accesses |
| 109 | .name(name() + ".read_accesses") |
| 110 | .desc("DTB read accesses") |
| 111 | ; |
| 112 | |
| 113 | write_hits |
| 114 | .name(name() + ".write_hits") |
| 115 | .desc("DTB write hits") |
| 116 | ; |
| 117 | |
| 118 | write_misses |
| 119 | .name(name() + ".write_misses") |
| 120 | .desc("DTB write misses") |
| 121 | ; |
| 122 | |
| 123 | write_acv |
| 124 | .name(name() + ".write_acv") |
| 125 | .desc("DTB write access violations") |
| 126 | ; |
| 127 | |
| 128 | write_accesses |
| 129 | .name(name() + ".write_accesses") |
| 130 | .desc("DTB write accesses") |
| 131 | ; |
| 132 | |
| 133 | data_hits |
| 134 | .name(name() + ".data_hits") |
| 135 | .desc("DTB hits") |
| 136 | ; |
| 137 | |
| 138 | data_misses |
| 139 | .name(name() + ".data_misses") |
| 140 | .desc("DTB misses") |
| 141 | ; |
| 142 | |
| 143 | data_acv |
| 144 | .name(name() + ".data_acv") |
| 145 | .desc("DTB access violations") |
| 146 | ; |
| 147 | |
| 148 | data_accesses |
| 149 | .name(name() + ".data_accesses") |
| 150 | .desc("DTB accesses") |
| 151 | ; |
| 152 | |
| 153 | data_hits = read_hits + write_hits; |
| 154 | data_misses = read_misses + write_misses; |
| 155 | data_acv = read_acv + write_acv; |
| 156 | data_accesses = read_accesses + write_accesses; |
| 157 | } |
| 158 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 159 | // look up an entry in the TLB |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 160 | TlbEntry * |
Vincentius Robby | 1caed14 | 2007-08-08 18:38:19 -0400 | [diff] [blame] | 161 | TLB::lookup(Addr vpn, uint8_t asn) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 162 | { |
| 163 | // assume not found... |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 164 | TlbEntry *retval = NULL; |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 165 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 166 | if (EntryCache[0]) { |
| 167 | if (vpn == EntryCache[0]->tag && |
| 168 | (EntryCache[0]->asma || EntryCache[0]->asn == asn)) |
| 169 | retval = EntryCache[0]; |
| 170 | else if (EntryCache[1]) { |
| 171 | if (vpn == EntryCache[1]->tag && |
| 172 | (EntryCache[1]->asma || EntryCache[1]->asn == asn)) |
| 173 | retval = EntryCache[1]; |
| 174 | else if (EntryCache[2] && vpn == EntryCache[2]->tag && |
| 175 | (EntryCache[2]->asma || EntryCache[2]->asn == asn)) |
| 176 | retval = EntryCache[2]; |
Vincentius Robby | 13d10e8 | 2007-08-08 14:18:09 -0400 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | |
Vincentius Robby | 1caed14 | 2007-08-08 18:38:19 -0400 | [diff] [blame] | 180 | if (retval == NULL) { |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 181 | PageTable::const_iterator i = lookupTable.find(vpn); |
| 182 | if (i != lookupTable.end()) { |
| 183 | while (i->first == vpn) { |
| 184 | int index = i->second; |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 185 | TlbEntry *entry = &table[index]; |
| 186 | assert(entry->valid); |
| 187 | if (vpn == entry->tag && (entry->asma || entry->asn == asn)) { |
| 188 | retval = updateCache(entry); |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 189 | break; |
| 190 | } |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 191 | |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 192 | ++i; |
| 193 | } |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 194 | } |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 195 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 196 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 197 | DPRINTF(TLB, "lookup %#x, asn %#x -> %s ppn %#x\n", vpn, (int)asn, |
| 198 | retval ? "hit" : "miss", retval ? retval->ppn : 0); |
| 199 | return retval; |
| 200 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 201 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 202 | Fault |
Ali Saidi | 91d9687 | 2008-08-13 16:29:59 -0400 | [diff] [blame] | 203 | TLB::checkCacheability(RequestPtr &req, bool itb) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 204 | { |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 205 | // in Alpha, cacheability is controlled by upper-level bits of the |
| 206 | // physical address |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 207 | |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 208 | /* |
| 209 | * We support having the uncacheable bit in either bit 39 or bit |
| 210 | * 40. The Turbolaser platform (and EV5) support having the bit |
| 211 | * in 39, but Tsunami (which Linux assumes uses an EV6) generates |
| 212 | * accesses with the bit in 40. So we must check for both, but we |
| 213 | * have debug flags to catch a weird case where both are used, |
| 214 | * which shouldn't happen. |
| 215 | */ |
Andrew Schultz | e3fb3d1 | 2004-02-19 16:30:06 -0500 | [diff] [blame] | 216 | |
Ali Saidi | f37eb6f | 2004-06-22 17:20:19 -0400 | [diff] [blame] | 217 | |
Nathan Binkert | 18a3052 | 2009-04-08 22:22:49 -0700 | [diff] [blame] | 218 | if (req->getPaddr() & PAddrUncachedBit43) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 219 | // IPR memory space not implemented |
| 220 | if (PAddrIprSpace(req->getPaddr())) { |
| 221 | return new UnimpFault("IPR memory space not implemented!"); |
| 222 | } else { |
| 223 | // mark request as uncacheable |
Nathan Binkert | 9c49bc7 | 2008-11-10 11:51:17 -0800 | [diff] [blame] | 224 | req->setFlags(Request::UNCACHEABLE); |
Andrew Schultz | f5c7b13 | 2004-05-19 15:58:24 -0400 | [diff] [blame] | 225 | |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 226 | // Clear bits 42:35 of the physical address (10-2 in |
| 227 | // Tsunami manual) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 228 | req->setPaddr(req->getPaddr() & PAddrUncachedMask); |
Ali Saidi | f37eb6f | 2004-06-22 17:20:19 -0400 | [diff] [blame] | 229 | } |
Ali Saidi | 91d9687 | 2008-08-13 16:29:59 -0400 | [diff] [blame] | 230 | // We shouldn't be able to read from an uncachable address in Alpha as |
| 231 | // we don't have a ROM and we don't want to try to fetch from a device |
| 232 | // register as we destroy any data that is clear-on-read. |
| 233 | if (req->isUncacheable() && itb) |
| 234 | return new UnimpFault("CPU trying to fetch from uncached I/O"); |
| 235 | |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 236 | } |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 237 | return NoFault; |
| 238 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 239 | |
| 240 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 241 | // insert a new TLB entry |
| 242 | void |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 243 | TLB::insert(Addr addr, TlbEntry &entry) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 244 | { |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 245 | flushCache(); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 246 | VAddr vaddr = addr; |
| 247 | if (table[nlu].valid) { |
| 248 | Addr oldvpn = table[nlu].tag; |
| 249 | PageTable::iterator i = lookupTable.find(oldvpn); |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 250 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 251 | if (i == lookupTable.end()) |
| 252 | panic("TLB entry not found in lookupTable"); |
| 253 | |
| 254 | int index; |
| 255 | while ((index = i->second) != nlu) { |
| 256 | if (table[index].tag != oldvpn) |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 257 | panic("TLB entry not found in lookupTable"); |
| 258 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 259 | ++i; |
| 260 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 261 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 262 | DPRINTF(TLB, "remove @%d: %#x -> %#x\n", nlu, oldvpn, table[nlu].ppn); |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 263 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 264 | lookupTable.erase(i); |
| 265 | } |
| 266 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 267 | DPRINTF(TLB, "insert @%d: %#x -> %#x\n", nlu, vaddr.vpn(), entry.ppn); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 268 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 269 | table[nlu] = entry; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 270 | table[nlu].tag = vaddr.vpn(); |
| 271 | table[nlu].valid = true; |
| 272 | |
| 273 | lookupTable.insert(make_pair(vaddr.vpn(), nlu)); |
| 274 | nextnlu(); |
| 275 | } |
| 276 | |
| 277 | void |
| 278 | TLB::flushAll() |
| 279 | { |
| 280 | DPRINTF(TLB, "flushAll\n"); |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 281 | memset(table, 0, sizeof(TlbEntry[size])); |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 282 | flushCache(); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 283 | lookupTable.clear(); |
| 284 | nlu = 0; |
| 285 | } |
| 286 | |
| 287 | void |
| 288 | TLB::flushProcesses() |
| 289 | { |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 290 | flushCache(); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 291 | PageTable::iterator i = lookupTable.begin(); |
| 292 | PageTable::iterator end = lookupTable.end(); |
| 293 | while (i != end) { |
| 294 | int index = i->second; |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 295 | TlbEntry *entry = &table[index]; |
| 296 | assert(entry->valid); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 297 | |
| 298 | // we can't increment i after we erase it, so save a copy and |
| 299 | // increment it to get the next entry now |
| 300 | PageTable::iterator cur = i; |
| 301 | ++i; |
| 302 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 303 | if (!entry->asma) { |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 304 | DPRINTF(TLB, "flush @%d: %#x -> %#x\n", index, |
| 305 | entry->tag, entry->ppn); |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 306 | entry->valid = false; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 307 | lookupTable.erase(cur); |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | void |
| 313 | TLB::flushAddr(Addr addr, uint8_t asn) |
| 314 | { |
Vincentius Robby | 2898d76 | 2007-08-04 14:25:35 -0400 | [diff] [blame] | 315 | flushCache(); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 316 | VAddr vaddr = addr; |
| 317 | |
| 318 | PageTable::iterator i = lookupTable.find(vaddr.vpn()); |
| 319 | if (i == lookupTable.end()) |
| 320 | return; |
| 321 | |
Ali Saidi | 39743d3 | 2007-05-01 18:12:58 -0400 | [diff] [blame] | 322 | while (i != lookupTable.end() && i->first == vaddr.vpn()) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 323 | int index = i->second; |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 324 | TlbEntry *entry = &table[index]; |
| 325 | assert(entry->valid); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 326 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 327 | if (vaddr.vpn() == entry->tag && (entry->asma || entry->asn == asn)) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 328 | DPRINTF(TLB, "flushaddr @%d: %#x -> %#x\n", index, vaddr.vpn(), |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 329 | entry->ppn); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 330 | |
| 331 | // invalidate this entry |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 332 | entry->valid = false; |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 333 | |
Ali Saidi | 39743d3 | 2007-05-01 18:12:58 -0400 | [diff] [blame] | 334 | lookupTable.erase(i++); |
| 335 | } else { |
| 336 | ++i; |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 337 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 338 | } |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 339 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 340 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 341 | |
| 342 | void |
| 343 | TLB::serialize(ostream &os) |
| 344 | { |
| 345 | SERIALIZE_SCALAR(size); |
| 346 | SERIALIZE_SCALAR(nlu); |
| 347 | |
| 348 | for (int i = 0; i < size; i++) { |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 349 | nameOut(os, csprintf("%s.Entry%d", name(), i)); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 350 | table[i].serialize(os); |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 351 | } |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 352 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 353 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 354 | void |
| 355 | TLB::unserialize(Checkpoint *cp, const string §ion) |
| 356 | { |
| 357 | UNSERIALIZE_SCALAR(size); |
| 358 | UNSERIALIZE_SCALAR(nlu); |
Steve Reinhardt | b90f810 | 2003-10-28 12:55:12 -0800 | [diff] [blame] | 359 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 360 | for (int i = 0; i < size; i++) { |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 361 | table[i].unserialize(cp, csprintf("%s.Entry%d", section, i)); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 362 | if (table[i].valid) { |
| 363 | lookupTable.insert(make_pair(table[i].tag, i)); |
Steve Reinhardt | af5277a | 2003-10-29 13:35:07 -0800 | [diff] [blame] | 364 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 365 | } |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 366 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 367 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 368 | Fault |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 369 | TLB::translateInst(RequestPtr req, ThreadContext *tc) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 370 | { |
Gabe Black | 54abc8b | 2007-04-11 14:02:03 +0000 | [diff] [blame] | 371 | //If this is a pal pc, then set PHYSICAL |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 372 | if (FULL_SYSTEM && PcPAL(req->getPC())) |
Nathan Binkert | 9c49bc7 | 2008-11-10 11:51:17 -0800 | [diff] [blame] | 373 | req->setFlags(Request::PHYSICAL); |
Gabe Black | 54abc8b | 2007-04-11 14:02:03 +0000 | [diff] [blame] | 374 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 375 | if (PcPAL(req->getPC())) { |
| 376 | // strip off PAL PC marker (lsb is 1) |
| 377 | req->setPaddr((req->getVaddr() & ~3) & PAddrImplMask); |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 378 | fetch_hits++; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 379 | return NoFault; |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 380 | } |
| 381 | |
Nathan Binkert | 9c49bc7 | 2008-11-10 11:51:17 -0800 | [diff] [blame] | 382 | if (req->getFlags() & Request::PHYSICAL) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 383 | req->setPaddr(req->getVaddr()); |
| 384 | } else { |
| 385 | // verify that this is a good virtual address |
| 386 | if (!validVirtualAddress(req->getVaddr())) { |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 387 | fetch_acv++; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 388 | return new ItbAcvFault(req->getVaddr()); |
Andrew Schultz | a73e263 | 2004-02-16 21:56:38 -0500 | [diff] [blame] | 389 | } |
| 390 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 391 | |
| 392 | // VA<42:41> == 2, VA<39:13> maps directly to PA<39:13> for EV5 |
| 393 | // VA<47:41> == 0x7e, VA<40:13> maps directly to PA<40:13> for EV6 |
Nathan Binkert | 18a3052 | 2009-04-08 22:22:49 -0700 | [diff] [blame] | 394 | if (VAddrSpaceEV6(req->getVaddr()) == 0x7e) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 395 | // only valid in kernel mode |
Ali Saidi | 689cab3 | 2007-03-07 15:04:31 -0500 | [diff] [blame] | 396 | if (ICM_CM(tc->readMiscRegNoEffect(IPR_ICM)) != |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 397 | mode_kernel) { |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 398 | fetch_acv++; |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 399 | return new ItbAcvFault(req->getVaddr()); |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 400 | } |
Andrew Schultz | e3fb3d1 | 2004-02-19 16:30:06 -0500 | [diff] [blame] | 401 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 402 | req->setPaddr(req->getVaddr() & PAddrImplMask); |
Andrew Schultz | e3fb3d1 | 2004-02-19 16:30:06 -0500 | [diff] [blame] | 403 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 404 | // sign extend the physical address properly |
| 405 | if (req->getPaddr() & PAddrUncachedBit40) |
| 406 | req->setPaddr(req->getPaddr() | ULL(0xf0000000000)); |
| 407 | else |
| 408 | req->setPaddr(req->getPaddr() & ULL(0xffffffffff)); |
Andrew Schultz | e3fb3d1 | 2004-02-19 16:30:06 -0500 | [diff] [blame] | 409 | } else { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 410 | // not a physical address: need to look up pte |
Ali Saidi | 689cab3 | 2007-03-07 15:04:31 -0500 | [diff] [blame] | 411 | int asn = DTB_ASN_ASN(tc->readMiscRegNoEffect(IPR_DTB_ASN)); |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 412 | TlbEntry *entry = lookup(VAddr(req->getVaddr()).vpn(), |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 413 | asn); |
| 414 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 415 | if (!entry) { |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 416 | fetch_misses++; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 417 | return new ItbPageFault(req->getVaddr()); |
Andrew Schultz | e3fb3d1 | 2004-02-19 16:30:06 -0500 | [diff] [blame] | 418 | } |
| 419 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 420 | req->setPaddr((entry->ppn << PageShift) + |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 421 | (VAddr(req->getVaddr()).offset() |
| 422 | & ~3)); |
| 423 | |
| 424 | // check permissions for this access |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 425 | if (!(entry->xre & |
Ali Saidi | 689cab3 | 2007-03-07 15:04:31 -0500 | [diff] [blame] | 426 | (1 << ICM_CM(tc->readMiscRegNoEffect(IPR_ICM))))) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 427 | // instruction access fault |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 428 | fetch_acv++; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 429 | return new ItbAcvFault(req->getVaddr()); |
| 430 | } |
| 431 | |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 432 | fetch_hits++; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 433 | } |
| 434 | } |
| 435 | |
| 436 | // check that the physical address is ok (catch bad physical addresses) |
| 437 | if (req->getPaddr() & ~PAddrImplMask) |
| 438 | return genMachineCheckFault(); |
| 439 | |
Ali Saidi | 91d9687 | 2008-08-13 16:29:59 -0400 | [diff] [blame] | 440 | return checkCacheability(req, true); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 441 | |
| 442 | } |
| 443 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 444 | Fault |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 445 | TLB::translateData(RequestPtr req, ThreadContext *tc, bool write) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 446 | { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 447 | mode_type mode = |
Ali Saidi | 689cab3 | 2007-03-07 15:04:31 -0500 | [diff] [blame] | 448 | (mode_type)DTB_CM_CM(tc->readMiscRegNoEffect(IPR_DTB_CM)); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 449 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 450 | /** |
| 451 | * Check for alignment faults |
| 452 | */ |
| 453 | if (req->getVaddr() & (req->getSize() - 1)) { |
Korey Sewell | 1c7e988 | 2009-05-12 15:01:15 -0400 | [diff] [blame] | 454 | DPRINTF(TLB, "Alignment Fault on %#x, size = %d\n", req->getVaddr(), |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 455 | req->getSize()); |
| 456 | uint64_t flags = write ? MM_STAT_WR_MASK : 0; |
| 457 | return new DtbAlignmentFault(req->getVaddr(), req->getFlags(), flags); |
| 458 | } |
| 459 | |
Gabe Black | 6f4bd2c | 2010-10-31 00:07:20 -0700 | [diff] [blame] | 460 | if (PcPAL(tc->pcState().pc())) { |
Nathan Binkert | 9c49bc7 | 2008-11-10 11:51:17 -0800 | [diff] [blame] | 461 | mode = (req->getFlags() & Request::ALTMODE) ? |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 462 | (mode_type)ALT_MODE_AM( |
Ali Saidi | 689cab3 | 2007-03-07 15:04:31 -0500 | [diff] [blame] | 463 | tc->readMiscRegNoEffect(IPR_ALT_MODE)) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 464 | : mode_kernel; |
| 465 | } |
| 466 | |
Nathan Binkert | 9c49bc7 | 2008-11-10 11:51:17 -0800 | [diff] [blame] | 467 | if (req->getFlags() & Request::PHYSICAL) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 468 | req->setPaddr(req->getVaddr()); |
| 469 | } else { |
| 470 | // verify that this is a good virtual address |
| 471 | if (!validVirtualAddress(req->getVaddr())) { |
| 472 | if (write) { write_acv++; } else { read_acv++; } |
| 473 | uint64_t flags = (write ? MM_STAT_WR_MASK : 0) | |
| 474 | MM_STAT_BAD_VA_MASK | |
| 475 | MM_STAT_ACV_MASK; |
| 476 | return new DtbPageFault(req->getVaddr(), req->getFlags(), flags); |
| 477 | } |
| 478 | |
| 479 | // Check for "superpage" mapping |
Nathan Binkert | 18a3052 | 2009-04-08 22:22:49 -0700 | [diff] [blame] | 480 | if (VAddrSpaceEV6(req->getVaddr()) == 0x7e) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 481 | // only valid in kernel mode |
Ali Saidi | 689cab3 | 2007-03-07 15:04:31 -0500 | [diff] [blame] | 482 | if (DTB_CM_CM(tc->readMiscRegNoEffect(IPR_DTB_CM)) != |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 483 | mode_kernel) { |
| 484 | if (write) { write_acv++; } else { read_acv++; } |
| 485 | uint64_t flags = ((write ? MM_STAT_WR_MASK : 0) | |
| 486 | MM_STAT_ACV_MASK); |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 487 | |
| 488 | return new DtbAcvFault(req->getVaddr(), req->getFlags(), |
| 489 | flags); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | req->setPaddr(req->getVaddr() & PAddrImplMask); |
| 493 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 494 | // sign extend the physical address properly |
| 495 | if (req->getPaddr() & PAddrUncachedBit40) |
| 496 | req->setPaddr(req->getPaddr() | ULL(0xf0000000000)); |
| 497 | else |
| 498 | req->setPaddr(req->getPaddr() & ULL(0xffffffffff)); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 499 | } else { |
| 500 | if (write) |
| 501 | write_accesses++; |
| 502 | else |
| 503 | read_accesses++; |
| 504 | |
Ali Saidi | 689cab3 | 2007-03-07 15:04:31 -0500 | [diff] [blame] | 505 | int asn = DTB_ASN_ASN(tc->readMiscRegNoEffect(IPR_DTB_ASN)); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 506 | |
| 507 | // not a physical address: need to look up pte |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 508 | TlbEntry *entry = lookup(VAddr(req->getVaddr()).vpn(), asn); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 509 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 510 | if (!entry) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 511 | // page fault |
| 512 | if (write) { write_misses++; } else { read_misses++; } |
| 513 | uint64_t flags = (write ? MM_STAT_WR_MASK : 0) | |
| 514 | MM_STAT_DTB_MISS_MASK; |
Nathan Binkert | 9c49bc7 | 2008-11-10 11:51:17 -0800 | [diff] [blame] | 515 | return (req->getFlags() & Request::VPTE) ? |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 516 | (Fault)(new PDtbMissFault(req->getVaddr(), req->getFlags(), |
| 517 | flags)) : |
| 518 | (Fault)(new NDtbMissFault(req->getVaddr(), req->getFlags(), |
| 519 | flags)); |
| 520 | } |
| 521 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 522 | req->setPaddr((entry->ppn << PageShift) + |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 523 | VAddr(req->getVaddr()).offset()); |
| 524 | |
| 525 | if (write) { |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 526 | if (!(entry->xwe & MODE2MASK(mode))) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 527 | // declare the instruction access fault |
| 528 | write_acv++; |
| 529 | uint64_t flags = MM_STAT_WR_MASK | |
| 530 | MM_STAT_ACV_MASK | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 531 | (entry->fonw ? MM_STAT_FONW_MASK : 0); |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 532 | return new DtbPageFault(req->getVaddr(), req->getFlags(), |
| 533 | flags); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 534 | } |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 535 | if (entry->fonw) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 536 | write_acv++; |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 537 | uint64_t flags = MM_STAT_WR_MASK | MM_STAT_FONW_MASK; |
| 538 | return new DtbPageFault(req->getVaddr(), req->getFlags(), |
| 539 | flags); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 540 | } |
| 541 | } else { |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 542 | if (!(entry->xre & MODE2MASK(mode))) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 543 | read_acv++; |
| 544 | uint64_t flags = MM_STAT_ACV_MASK | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 545 | (entry->fonr ? MM_STAT_FONR_MASK : 0); |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 546 | return new DtbAcvFault(req->getVaddr(), req->getFlags(), |
| 547 | flags); |
Andrew Schultz | e3fb3d1 | 2004-02-19 16:30:06 -0500 | [diff] [blame] | 548 | } |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 549 | if (entry->fonr) { |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 550 | read_acv++; |
| 551 | uint64_t flags = MM_STAT_FONR_MASK; |
Nathan Binkert | cf7ddd8 | 2008-09-27 21:03:48 -0700 | [diff] [blame] | 552 | return new DtbPageFault(req->getVaddr(), req->getFlags(), |
| 553 | flags); |
Andrew Schultz | e3fb3d1 | 2004-02-19 16:30:06 -0500 | [diff] [blame] | 554 | } |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 555 | } |
| 556 | } |
Andrew Schultz | a73e263 | 2004-02-16 21:56:38 -0500 | [diff] [blame] | 557 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 558 | if (write) |
| 559 | write_hits++; |
| 560 | else |
| 561 | read_hits++; |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 562 | } |
| 563 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 564 | // check that the physical address is ok (catch bad physical addresses) |
| 565 | if (req->getPaddr() & ~PAddrImplMask) |
| 566 | return genMachineCheckFault(); |
Steve Raasch | 92638f9 | 2003-10-07 10:41:54 -0400 | [diff] [blame] | 567 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 568 | return checkCacheability(req); |
| 569 | } |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 570 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 571 | TlbEntry & |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 572 | TLB::index(bool advance) |
| 573 | { |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 574 | TlbEntry *entry = &table[nlu]; |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 575 | |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 576 | if (advance) |
| 577 | nextnlu(); |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 578 | |
Gabe Black | 9b49a78 | 2007-08-26 20:33:57 -0700 | [diff] [blame] | 579 | return *entry; |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 580 | } |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 581 | |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 582 | Fault |
Nathan Binkert | e0de2c3 | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 583 | TLB::translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 584 | { |
Nathan Binkert | e0de2c3 | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 585 | if (mode == Execute) |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 586 | return translateInst(req, tc); |
| 587 | else |
Nathan Binkert | e0de2c3 | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 588 | return translateData(req, tc, mode == Write); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 589 | } |
Gabe Black | 4862879 | 2006-10-31 02:08:44 -0500 | [diff] [blame] | 590 | |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 591 | void |
| 592 | TLB::translateTiming(RequestPtr req, ThreadContext *tc, |
Nathan Binkert | e0de2c3 | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 593 | Translation *translation, Mode mode) |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 594 | { |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 595 | assert(translation); |
Nathan Binkert | e0de2c3 | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 596 | translation->finish(translateAtomic(req, tc, mode), req, tc, mode); |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 597 | } |
| 598 | |
Steve Reinhardt | c69d48f | 2011-01-03 14:35:43 -0800 | [diff] [blame] | 599 | } // namespace AlphaISA |
Gabe Black | 7b5a96f | 2009-04-08 22:21:27 -0700 | [diff] [blame] | 600 | |
| 601 | AlphaISA::TLB * |
| 602 | AlphaTLBParams::create() |
| 603 | { |
| 604 | return new AlphaISA::TLB(this); |
Lisa Hsu | 9a4370e | 2006-12-15 12:58:02 -0500 | [diff] [blame] | 605 | } |