tlb.cc (3906:4cf7d8d42349) | tlb.cc (3907:00f18b4eedb5) |
---|---|
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; --- 67 unchanged lines hidden (view full) --- 76void 77TLB::insert(Addr va, int partition_id, int context_id, bool real, 78 const PageTableEntry& PTE, int entry) 79{ 80 81 82 MapIter i; 83 TlbEntry *new_entry = NULL; | 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; --- 67 unchanged lines hidden (view full) --- 76void 77TLB::insert(Addr va, int partition_id, int context_id, bool real, 78 const PageTableEntry& PTE, int entry) 79{ 80 81 82 MapIter i; 83 TlbEntry *new_entry = NULL; |
84 TlbRange tr; | 84// TlbRange tr; |
85 int x; 86 87 cacheValid = false; | 85 int x; 86 87 cacheValid = false; |
88 tr.va = va; | 88 /* tr.va = va; |
89 tr.size = PTE.size() - 1; 90 tr.contextId = context_id; 91 tr.partitionId = partition_id; 92 tr.real = real; | 89 tr.size = PTE.size() - 1; 90 tr.contextId = context_id; 91 tr.partitionId = partition_id; 92 tr.real = real; |
93*/ |
|
93 | 94 |
94 | |
95 DPRINTF(TLB, "TLB: Inserting TLB Entry; va=%#x pa=%#x pid=%d cid=%d r=%d entryid=%d\n", 96 va, PTE.paddr(), partition_id, context_id, (int)real, entry); 97 98 // Demap any entry that conflicts | 95 DPRINTF(TLB, "TLB: Inserting TLB Entry; va=%#x pa=%#x pid=%d cid=%d r=%d entryid=%d\n", 96 va, PTE.paddr(), partition_id, context_id, (int)real, entry); 97 98 // Demap any entry that conflicts |
99 for (x = 0; x < size; x++) { 100 if (tlb[x].range.real == real && 101 tlb[x].range.partitionId == partition_id && 102 tlb[x].range.va < va + PTE.size() - 1 && 103 tlb[x].range.va + tlb[x].range.size >= va && 104 (real || tlb[x].range.contextId == context_id )) 105 { 106 if (tlb[x].valid) { 107 freeList.push_front(&tlb[x]); 108 DPRINTF(TLB, "TLB: Conflicting entry %#X , deleting it\n", x); 109 110 tlb[x].valid = false; 111 if (tlb[x].used) { 112 tlb[x].used = false; 113 usedEntries--; 114 } 115 lookupTable.erase(tlb[x].range); 116 } 117 } 118 } 119 120 121/* |
|
99 i = lookupTable.find(tr); 100 if (i != lookupTable.end()) { 101 i->second->valid = false; 102 if (i->second->used) { 103 i->second->used = false; 104 usedEntries--; 105 } 106 freeList.push_front(i->second); 107 DPRINTF(TLB, "TLB: Found conflicting entry %#X , deleting it\n", 108 i->second); 109 lookupTable.erase(i); 110 } | 122 i = lookupTable.find(tr); 123 if (i != lookupTable.end()) { 124 i->second->valid = false; 125 if (i->second->used) { 126 i->second->used = false; 127 usedEntries--; 128 } 129 freeList.push_front(i->second); 130 DPRINTF(TLB, "TLB: Found conflicting entry %#X , deleting it\n", 131 i->second); 132 lookupTable.erase(i); 133 } |
134*/ |
|
111 | 135 |
112 | |
113 if (entry != -1) { 114 assert(entry < size && entry >= 0); 115 new_entry = &tlb[entry]; 116 } else { 117 if (!freeList.empty()) { 118 new_entry = freeList.front(); 119 } else { 120 x = lastReplaced; 121 do { 122 ++x; 123 if (x == size) 124 x = 0; 125 if (x == lastReplaced) 126 goto insertAllLocked; 127 } while (tlb[x].pte.locked()); 128 lastReplaced = x; 129 new_entry = &tlb[x]; | 136 if (entry != -1) { 137 assert(entry < size && entry >= 0); 138 new_entry = &tlb[entry]; 139 } else { 140 if (!freeList.empty()) { 141 new_entry = freeList.front(); 142 } else { 143 x = lastReplaced; 144 do { 145 ++x; 146 if (x == size) 147 x = 0; 148 if (x == lastReplaced) 149 goto insertAllLocked; 150 } while (tlb[x].pte.locked()); 151 lastReplaced = x; 152 new_entry = &tlb[x]; |
130 lookupTable.erase(new_entry->range); | |
131 } 132 /* 133 for (x = 0; x < size; x++) { 134 if (!tlb[x].valid || !tlb[x].used) { 135 new_entry = &tlb[x]; 136 break; 137 } 138 }*/ 139 } 140 141insertAllLocked: 142 // Update the last ently if their all locked 143 if (!new_entry) { 144 new_entry = &tlb[size-1]; | 153 } 154 /* 155 for (x = 0; x < size; x++) { 156 if (!tlb[x].valid || !tlb[x].used) { 157 new_entry = &tlb[x]; 158 break; 159 } 160 }*/ 161 } 162 163insertAllLocked: 164 // Update the last ently if their all locked 165 if (!new_entry) { 166 new_entry = &tlb[size-1]; |
145 lookupTable.erase(new_entry->range); | |
146 } 147 148 freeList.remove(new_entry); | 167 } 168 169 freeList.remove(new_entry); |
170 if (new_entry->valid && new_entry->used) 171 usedEntries--; 172 173 lookupTable.erase(new_entry->range); 174 175 |
|
149 DPRINTF(TLB, "Using entry: %#X\n", new_entry); 150 151 assert(PTE.valid()); 152 new_entry->range.va = va; 153 new_entry->range.size = PTE.size() - 1; 154 new_entry->range.partitionId = partition_id; 155 new_entry->range.contextId = context_id; 156 new_entry->range.real = real; --- 153 unchanged lines hidden (view full) --- 310 311void 312TLB::invalidateAll() 313{ 314 int x; 315 cacheValid = false; 316 317 freeList.clear(); | 176 DPRINTF(TLB, "Using entry: %#X\n", new_entry); 177 178 assert(PTE.valid()); 179 new_entry->range.va = va; 180 new_entry->range.size = PTE.size() - 1; 181 new_entry->range.partitionId = partition_id; 182 new_entry->range.contextId = context_id; 183 new_entry->range.real = real; --- 153 unchanged lines hidden (view full) --- 337 338void 339TLB::invalidateAll() 340{ 341 int x; 342 cacheValid = false; 343 344 freeList.clear(); |
345 lookupTable.clear(); |
|
318 for (x = 0; x < size; x++) { 319 if (tlb[x].valid == true) 320 freeList.push_back(&tlb[x]); 321 tlb[x].valid = false; | 346 for (x = 0; x < size; x++) { 347 if (tlb[x].valid == true) 348 freeList.push_back(&tlb[x]); 349 tlb[x].valid = false; |
350 tlb[x].used = false; |
|
322 } 323 usedEntries = 0; 324} 325 326uint64_t 327TLB::TteRead(int entry) { 328 if (entry >= size) 329 panic("entry: %d\n", entry); --- 937 unchanged lines hidden --- | 351 } 352 usedEntries = 0; 353} 354 355uint64_t 356TLB::TteRead(int entry) { 357 if (entry >= size) 358 panic("entry: %d\n", entry); --- 937 unchanged lines hidden --- |