43#include "debug/MipsPRA.hh"
44#include "debug/TLB.hh"
46#include "params/MipsTLB.hh"
52using namespace MipsISA;
59TLB::TLB(
const Params &
p) : BaseTLB(
p), size(
p.size), nlu(0)
61 table =
new PTE[size];
62 memset(table, 0,
sizeof(PTE[size]));
73TLB::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);
103TLB::getEntry(
unsigned Index)
const
107 return &table[Index];
111TLB::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);
152TLB::insertAt(
PTE &pte,
unsigned Index,
int _smallPages)
154 smallPages = _smallPages;
156 warn(
"Attempted to write at index (%d) beyond TLB size (%d)",
161 Index, pte.
Mask << 11,
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));
167 if (table[Index].V0 || table[Index].V1) {
169 PageTable::iterator
i = lookupTable.find(table[Index].VPN);
170 lookupTable.erase(i);
174 lookupTable.insert(std::make_pair(table[Index].VPN, Index));
180TLB::insert(Addr addr, PTE &pte)
182 fatal(
"TLB Insert not yet implemented\n");
189 memset(table, 0,
sizeof(PTE[size]));
200 for (
int i = 0;
i < size;
i++) {
202 table[
i].serialize(cp);
212 for (
int i = 0;
i < size;
i++) {
214 table[
i].unserialize(cp);
215 if (table[
i].V0 || table[
i].V1) {
216 lookupTable.insert(std::make_pair(table[
i].VPN,
i));
225 panic_if(FullSystem,
"translateAtomic not implemented in full system.");
234 translation->
finish(translateAtomic(req, tc, mode), req, tc, mode);
254TLB::index(
bool advance)
256 PTE *pte = &table[nlu];
virtual void finish(const Fault &fault, const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode)=0
bool translate(Addr vaddr, Addr &paddr)
Translate function.
EmulationPageTable * pTable
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual Process * getProcessPtr()=0
#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.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
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.
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
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)