ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MMU.h
Go to the documentation of this file.
1
58#ifndef ETISS_INCLUDE_MM_MMU_H_
59#define ETISS_INCLUDE_MM_MMU_H_
60
61#include "etiss/mm/PTE.h"
63#include "etiss/mm/TLB.h"
64
65#include "etiss/Plugin.h"
66
67namespace etiss
68{
69namespace mm
70{
71
72int32_t tlb_miss_handler(int32_t fault, MMU *mmu, uint64_t vma, MM_ACCESS access);
73// int32_t tlb_full_handler(int32_t fault, MMU * mmu);
74
75class MMU
76{
77
78#define DEFAULT_PAGE_TABLE_WALKER -15
79
80 public:
87 explicit MMU(bool hw_ptw, std::string name, bool pid_enabled);
88
89 virtual ~MMU() {}
90
98 virtual int32_t Translate(const uint64_t vma, uint64_t *const pma_buf, MM_ACCESS access, uint64_t data = 0);
99
105 void SignalMMU(uint64_t control_reg_val_);
106
111 void Dump();
112
119 void Init(ETISS_CPU *cpu, ETISS_System *system);
120
126 void AddTLBEntryMap(uint64_t phy_addr_, PTE &pte);
127
133 virtual bool CheckPrivilegedMode() = 0;
134
140 virtual int32_t CheckProtection(const PTE &, MM_ACCESS access) = 0;
141
148
153 virtual void UpdatePTEFlags(PTE &, MM_ACCESS) {}
154
155 bool IsTLBFull() const { return tlb_->IsFull(); }
156
157 PTE EvictTLBEntry(const uint64_t vfn) { return tlb_->EvictPTE(vfn); }
158
160
162
163 void UpdatePid(uint32_t new_pid)
164 {
165 if (pid_enabled_)
166 pid_ = new_pid;
167 }
168
170
171 int32_t AddTLBEntry(const uint64_t vfn, const PTE &pte);
172
173 std::string GetName() const { return name_; }
174
175 virtual int32_t GetPid(uint64_t control_reg_val_) { return 0; }
176
178
179 protected:
183
184 private:
185 // Resources in MMU
186 std::shared_ptr<etiss::mm::TLB<0>> tlb_;
187 // Map the virtual memory address (vma) of TLB entries to its own physical
188 // location for coherence
189 // NOTE: Write to TLB entries occurs rarely, so it is acceptable to evict
190 // them directly
191 std::map<uint64_t, PTE *> tlb_entry_map_;
192
195 std::string name_;
196
197 const bool pid_enabled_;
199};
200
201void DUMP_MMU(MMU *mmu);
202
203} // namespace mm
204} // namespace etiss
205
206#endif
#define DEFAULT_PAGE_TABLE_WALKER
Definition MMU.h:78
Internal fault inside MMU and.
plugins for extensions to code translation and instruction execution
Modeling Tranlation Look-up Table (TLB)
static __inline__ uint32_t
Definition arm_cde.h:25
static __inline__ uint64_t
Definition arm_cde.h:31
static __inline__ int32_t
Definition arm_mve.h:51
uint64_t GetMMUControlReg()
Definition MMU.h:169
int32_t AddTLBEntry(const uint64_t vfn, const PTE &pte)
Definition MMU.cpp:154
virtual int32_t GetPid(uint64_t control_reg_val_)
Definition MMU.h:175
virtual bool CheckPrivilegedMode()=0
MMU is enabled in certain mode.
std::string GetName() const
Definition MMU.h:173
bool mmu_enabled_
Definition MMU.h:182
virtual int32_t WalkPageTable(uint64_t, MM_ACCESS)
Page table walking is required to translate virtual address to physical address if TLB miss occurs.
Definition MMU.h:147
const bool hw_page_table_walker_
Definition MMU.h:198
void SignalMMU(uint64_t control_reg_val_)
Whenever the MMU control register changes, the MMU has to be notified with the updated control regist...
Definition MMU.cpp:166
uint32_t pid_
Definition MMU.h:194
virtual ~MMU()
Definition MMU.h:89
void UpdatePid(uint32_t new_pid)
Definition MMU.h:163
bool IsTLBFull() const
Definition MMU.h:155
bool cache_flush_pending
Definition MMU.h:177
std::shared_ptr< etiss::mm::TLB< 0 > > tlb_
Definition MMU.h:186
const bool pid_enabled_
Definition MMU.h:197
virtual int32_t CheckProtection(const PTE &, MM_ACCESS access)=0
Memory protection is architecture-dependent, which should be implemented with architecture model.
bool IsProcessIdEnabled()
Definition MMU.h:161
virtual void UpdatePTEFlags(PTE &, MM_ACCESS)
Reserved for some MMU that might update PTE when translating.
Definition MMU.h:153
ETISS_System * system_
Definition MMU.h:181
void AddTLBEntryMap(uint64_t phy_addr_, PTE &pte)
Keep a record of mapping between cached PTE with its physical address.
Definition MMU.cpp:214
uint64_t mmu_control_reg_val_
Definition MMU.h:193
bool HasPageTableWalker()
Definition MMU.h:159
virtual int32_t Translate(const uint64_t vma, uint64_t *const pma_buf, MM_ACCESS access, uint64_t data=0)
Conduct the actual translation according to the format set by PTEFormatBuilder.
Definition MMU.cpp:82
std::string name_
Definition MMU.h:195
void Init(ETISS_CPU *cpu, ETISS_System *system)
Initialize the MMU, when DMMUWrapper is wrapping the MMU.
Definition MMU.cpp:204
void Dump()
Dump the details of the MMU, when page fault cannot be handled.
Definition MMU.cpp:189
std::map< uint64_t, PTE * > tlb_entry_map_
Definition MMU.h:191
ETISS_CPU * cpu_
Definition MMU.h:180
PTE EvictTLBEntry(const uint64_t vfn)
Definition MMU.h:157
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition PTE.h:69
void DUMP_MMU(MMU *mmu)
Definition MMU.cpp:244
int32_t tlb_miss_handler(int32_t fault, MMU *mmu, uint64_t vma, MM_ACCESS access)
Definition MMU.cpp:221
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition Benchmark.h:53
basic cpu state structure needed for execution of any cpu architecture.
Definition CPU.h:89
memory access and time synchronization functions.
Definition System.h:78