ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
MMU.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
20#ifndef ETISS_INCLUDE_MM_MMU_H_
21#define ETISS_INCLUDE_MM_MMU_H_
22
23#include "etiss/mm/PTE.h"
25#include "etiss/mm/TLB.h"
26
27#include "etiss/Plugin.h"
28
29namespace etiss
30{
31namespace mm
32{
33
34int32_t tlb_miss_handler(int32_t fault, MMU *mmu, uint64_t vma, MM_ACCESS access);
35// int32_t tlb_full_handler(int32_t fault, MMU * mmu);
36
37class MMU
38{
39
40#define DEFAULT_PAGE_TABLE_WALKER -15
41
42 public:
49 explicit MMU(bool hw_ptw, std::string name, bool pid_enabled);
50
51 virtual ~MMU() {}
52
60 virtual int32_t Translate(const uint64_t vma, uint64_t *const pma_buf, MM_ACCESS access, uint64_t data = 0);
61
67 void SignalMMU(uint64_t control_reg_val_);
68
73 void Dump();
74
81 void Init(ETISS_CPU *cpu, ETISS_System *system);
82
88 void AddTLBEntryMap(uint64_t phy_addr_, PTE &pte);
89
95 virtual bool CheckPrivilegedMode() = 0;
96
102 virtual int32_t CheckProtection(const PTE &, MM_ACCESS access) = 0;
103
110
115 virtual void UpdatePTEFlags(PTE &, MM_ACCESS) {}
116
117 bool IsTLBFull() const { return tlb_->IsFull(); }
118
119 PTE EvictTLBEntry(const uint64_t vfn) { return tlb_->EvictPTE(vfn); }
120
122
124
125 void UpdatePid(uint32_t new_pid)
126 {
127 if (pid_enabled_)
128 pid_ = new_pid;
129 }
130
132
133 int32_t AddTLBEntry(const uint64_t vfn, const PTE &pte);
134
135 std::string GetName() const { return name_; }
136
137 virtual int32_t GetPid(uint64_t control_reg_val_) { return 0; }
138
140
141 protected:
145
146 private:
147 // Resources in MMU
148 std::shared_ptr<etiss::mm::TLB<0>> tlb_;
149 // Map the virtual memory address (vma) of TLB entries to its own physical
150 // location for coherence
151 // NOTE: Write to TLB entries occurs rarely, so it is acceptable to evict
152 // them directly
153 std::map<uint64_t, PTE *> tlb_entry_map_;
154
157 std::string name_;
158
159 const bool pid_enabled_;
161};
162
163void DUMP_MMU(MMU *mmu);
164
165} // namespace mm
166} // namespace etiss
167
168#endif
#define DEFAULT_PAGE_TABLE_WALKER
Definition MMU.h:40
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:131
int32_t AddTLBEntry(const uint64_t vfn, const PTE &pte)
Definition MMU.cpp:119
virtual int32_t GetPid(uint64_t control_reg_val_)
Definition MMU.h:137
virtual bool CheckPrivilegedMode()=0
MMU is enabled in certain mode.
std::string GetName() const
Definition MMU.h:135
bool mmu_enabled_
Definition MMU.h:144
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:109
const bool hw_page_table_walker_
Definition MMU.h:160
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:131
uint32_t pid_
Definition MMU.h:156
virtual ~MMU()
Definition MMU.h:51
void UpdatePid(uint32_t new_pid)
Definition MMU.h:125
bool IsTLBFull() const
Definition MMU.h:117
bool cache_flush_pending
Definition MMU.h:139
std::shared_ptr< etiss::mm::TLB< 0 > > tlb_
Definition MMU.h:148
const bool pid_enabled_
Definition MMU.h:159
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:123
virtual void UpdatePTEFlags(PTE &, MM_ACCESS)
Reserved for some MMU that might update PTE when translating.
Definition MMU.h:115
ETISS_System * system_
Definition MMU.h:143
void AddTLBEntryMap(uint64_t phy_addr_, PTE &pte)
Keep a record of mapping between cached PTE with its physical address.
Definition MMU.cpp:179
uint64_t mmu_control_reg_val_
Definition MMU.h:155
bool HasPageTableWalker()
Definition MMU.h:121
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:44
std::string name_
Definition MMU.h:157
void Init(ETISS_CPU *cpu, ETISS_System *system)
Initialize the MMU, when DMMUWrapper is wrapping the MMU.
Definition MMU.cpp:169
void Dump()
Dump the details of the MMU, when page fault cannot be handled.
Definition MMU.cpp:154
std::map< uint64_t, PTE * > tlb_entry_map_
Definition MMU.h:153
ETISS_CPU * cpu_
Definition MMU.h:142
PTE EvictTLBEntry(const uint64_t vfn)
Definition MMU.h:119
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition PTE.h:31
void DUMP_MMU(MMU *mmu)
Definition MMU.cpp:209
int32_t tlb_miss_handler(int32_t fault, MMU *mmu, uint64_t vma, MM_ACCESS access)
Definition MMU.cpp:186
forwards: include/jit/*
Definition Benchmark.h:17
basic cpu state structure needed for execution of any cpu architecture.
Definition CPU.h:51
memory access and time synchronization functions.
Definition System.h:40