43#include "debug/Power.hh"
44#include "debug/TLB.hh"
46#include "params/PowerTLB.hh"
53using namespace PowerISA;
60#define MODE2MASK(X) (1 << (X))
62TLB::TLB(
const Params &
p) : BaseTLB(
p), size(
p.size), nlu(0)
64 table =
new PowerISA::PTE[size];
65 memset(table, 0,
sizeof(PowerISA::PTE[size]));
77TLB::lookup(Addr vpn, uint8_t asn)
const
80 PowerISA::PTE *retval = NULL;
81 PageTable::const_iterator
i = lookupTable.find(vpn);
82 if (i != lookupTable.end()) {
83 while (
i->first == vpn) {
85 PowerISA::PTE *pte = &table[
index];
86 Addr Mask = pte->Mask;
89 if (((vpn & InvMask) == (VPN & InvMask))
90 && (pte->G || (asn == pte->asid))) {
100 DPRINTF(TLB,
"lookup %#x, asn %#x -> %s ppn %#x\n", vpn, (
int)asn,
101 retval ?
"hit" :
"miss", retval ? retval->PFN1 : 0);
106TLB::getEntry(
unsigned Index)
const
110 return &table[
Index];
114TLB::probeEntry(Addr vpn,uint8_t asn)
const
118 PageTable::const_iterator
i = lookupTable.find(vpn);
119 if (i != lookupTable.end()) {
120 while (
i->first == vpn) {
122 PowerISA::PTE *pte = &table[
index];
123 Addr Mask = pte->Mask;
124 Addr InvMask = ~Mask;
126 if (((vpn & InvMask) == (VPN & InvMask))
127 && (pte->G || (asn == pte->asid))) {
137 DPRINTF(Power,
"VPN: %x, asid: %d, Result of TLBP: %d\n", vpn, asn, Ind);
142TLB::checkCacheability(
const RequestPtr &req)
144 Addr VAddrUncacheable = 0xA0000000;
145 if ((req->getVaddr() & VAddrUncacheable) == VAddrUncacheable) {
148 req->setFlags(Request::UNCACHEABLE | Request::STRICT_ORDER);
156 smallPages=_smallPages;
158 warn(
"Attempted to write at index (%d) beyond TLB size (%d)",
163 if (table[Index].V0 || table[Index].V1) {
166 PageTable::iterator
i = lookupTable.find(table[Index].VPN);
167 lookupTable.erase(
i);
172 lookupTable.insert(std::make_pair(table[Index].VPN, Index));
180 fatal(
"TLB Insert not yet implemented\n");
193TLB::serialize(CheckpointOut &cp)
const
198 for (
int i = 0; i < size; i++) {
199 ScopedCheckpointSection sec(cp, csprintf(
"PTE%d", i));
200 table[i].serialize(cp);
205TLB::unserialize(CheckpointIn &cp)
210 for (
int i = 0;
i < size;
i++) {
211 ScopedCheckpointSection sec(cp,
csprintf(
"PTE%d", i));
212 if (table[i].V0 || table[i].V1) {
213 lookupTable.insert(std::make_pair(table[i].VPN, i));
227 return std::make_shared<AlignmentFault>(
vaddr);
244 "translateAtomic not yet implemented for full system.");
246 if (mode == BaseMMU::Execute)
247 return translateInst(req, tc);
249 return translateData(req, tc, mode == BaseMMU::Write);
257 "translateFunctional not implemented for full system.");
262TLB::translateTiming(
const RequestPtr &req, ThreadContext *tc,
263 BaseMMU::Translation *translation, BaseMMU::Mode mode)
266 translation->finish(translateAtomic(req, tc, mode), req, tc, mode);
270TLB::finalizePhysical(
const RequestPtr &req,
271 ThreadContext *tc, BaseMMU::Mode mode)
const
277TLB::index(
bool advance)
279 PowerISA::PTE *pte = &table[nlu];
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
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
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)