43 #include "debug/MipsPRA.hh"
44 #include "debug/TLB.hh"
46 #include "params/MipsTLB.hh"
52 using namespace MipsISA;
59 TLB::TLB(
const Params &
p) : BaseTLB(
p), size(
p.size), nlu(0)
61 table =
new PTE[size];
62 memset(table, 0,
sizeof(PTE[size]));
73 TLB::lookup(
Addr vpn, uint8_t asn)
const
77 PageTable::const_iterator
i = lookupTable.find(vpn);
78 if (
i != lookupTable.end()) {
79 while (
i->first == vpn) {
87 if (((vpn & InvMask) == (VPN & InvMask)) &&
88 (pte->
G || (asn == pte->
asid))) {
97 DPRINTF(
TLB,
"lookup %#x, asn %#x -> %s ppn %#x\n", vpn, (
int)asn,
98 retval ?
"hit" :
"miss", retval ? retval->
PFN1 : 0);
103 TLB::getEntry(
unsigned Index)
const
107 return &table[
Index];
111 TLB::probeEntry(
Addr vpn, uint8_t asn)
const
115 PageTable::const_iterator
i = lookupTable.find(vpn);
116 if (
i != lookupTable.end()) {
117 while (
i->first == vpn) {
122 Addr Mask = pte->Mask;
123 Addr InvMask = ~Mask;
125 if (((vpn & InvMask) == (VPN & InvMask)) &&
126 (pte->G || (asn == pte->asid))) {
134 DPRINTF(MipsPRA,
"VPN: %x, asid: %d, Result of TLBP: %d\n",vpn,asn,Ind);
141 Addr VAddrUncacheable = 0xA0000000;
144 if ((req->getVaddr() & VAddrUncacheable) == VAddrUncacheable) {
146 req->setFlags(Request::UNCACHEABLE | Request::STRICT_ORDER);
152 TLB::insertAt(
PTE &pte,
unsigned Index,
int _smallPages)
154 smallPages = _smallPages;
156 warn(
"Attempted to write at index (%d) beyond TLB size (%d)",
163 ((pte.
PFN0 << 6) | (pte.
C0 << 3) |
164 (pte.
D0 << 2) | (pte.
V0 <<1) | pte.
G),
165 ((pte.
PFN1 <<6) | (pte.
C1 << 3) |
166 (pte.
D1 << 2) | (pte.
V1 <<1) | pte.
G));
169 PageTable::iterator
i = lookupTable.find(table[
Index].VPN);
170 lookupTable.erase(
i);
174 lookupTable.insert(std::make_pair(table[
Index].VPN,
Index));
182 fatal(
"TLB Insert not yet implemented\n");
189 memset(table, 0,
sizeof(PTE[size]));
200 for (
int i = 0;
i < size;
i++) {
201 ScopedCheckpointSection sec(cp,
csprintf(
"PTE%d",
i));
202 table[
i].serialize(cp);
212 for (
int i = 0;
i < size;
i++) {
213 ScopedCheckpointSection sec(cp,
csprintf(
"PTE%d",
i));
214 table[
i].unserialize(cp);
215 if (table[
i].
V0 || table[
i].
V1) {
216 lookupTable.insert(std::make_pair(table[
i].VPN,
i));
222 TLB::translateAtomic(
const RequestPtr &req, ThreadContext *tc,
226 return tc->getProcessPtr()->pTable->translate(req);
230 TLB::translateTiming(
const RequestPtr &req, ThreadContext *tc,
231 BaseMMU::Translation *translation, BaseMMU::Mode
mode)
234 translation->finish(translateAtomic(req, tc,
mode), req, tc,
mode);
238 TLB::translateFunctional(
const RequestPtr &req, ThreadContext *tc,
242 return tc->getProcessPtr()->pTable->translate(req);
247 ThreadContext *tc, BaseMMU::Mode
mode)
const
256 PTE *pte = &table[nlu];
#define fatal(...)
This implements a cprintf based fatal() function.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Declaration of IniFile object.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
std::shared_ptr< Request > RequestPtr
std::ostream CheckpointOut
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
void unserialize(ThreadContext &tc, CheckpointIn &cp)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
std::string csprintf(const char *format, const Args &...args)
constexpr decltype(nullptr) NoFault
Declarations of a non-full system Page Table.
#define UNSERIALIZE_SCALAR(scalar)
#define SERIALIZE_SCALAR(scalar)