43#include "debug/Power.hh"
44#include "debug/TLB.hh"
46#include "params/PowerTLB.hh"
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);
158 warn(
"Attempted to write at index (%d) beyond TLB size (%d)",
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.");
247 return translateInst(req, tc);
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];
void flushAll() override
Reset the entire TLB.
bool translate(Addr vaddr, Addr &paddr)
Translate function.
Fault translateFunctional(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
void insertAt(PowerISA::PTE &pte, unsigned Index, int _smallPages)
void insert(Addr vaddr, PowerISA::PTE &pte)
EmulationPageTable * pTable
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, BaseMMU::Mode mode) override
Fault translateInst(const RequestPtr &req, ThreadContext *tc)
Fault translateData(const RequestPtr &req, ThreadContext *tc, bool write)
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 Arm Limited 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.
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)