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; |
85 int x; 86 87 cacheValid = false; |
88 /* tr.va = va; |
89 tr.size = PTE.size() - 1; 90 tr.contextId = context_id; 91 tr.partitionId = partition_id; 92 tr.real = real; |
93*/ |
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 |
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/* |
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*/ |
135 |
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]; |
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]; |
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 |
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(); |
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; |
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 --- |