summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar MerryMage2018-02-12 21:53:32 +0000
committerGravatar MerryMage2018-02-12 21:53:32 +0000
commit6085d32cf5d5ca4f9a5c0dc2f261505ed86c6539 (patch)
treec4422ff9c0fff43c035551f72ae3e84952d068f6 /src
parentMerge pull request #179 from gdkchan/audren_stubs (diff)
downloadyuzu-6085d32cf5d5ca4f9a5c0dc2f261505ed86c6539.tar.gz
yuzu-6085d32cf5d5ca4f9a5c0dc2f261505ed86c6539.tar.xz
yuzu-6085d32cf5d5ca4f9a5c0dc2f261505ed86c6539.zip
arm_dynarmic: Support direct page table access
Diffstat (limited to 'src')
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic.cpp20
-rw-r--r--src/core/memory.h9
2 files changed, 19 insertions, 10 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp
index 302bae569..283d20831 100644
--- a/src/core/arm/dynarmic/arm_dynarmic.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic.cpp
@@ -85,11 +85,19 @@ public:
85 ARM_Dynarmic& parent; 85 ARM_Dynarmic& parent;
86 size_t ticks_remaining = 0; 86 size_t ticks_remaining = 0;
87 size_t num_interpreted_instructions = 0; 87 size_t num_interpreted_instructions = 0;
88 u64 tpidrr0_el0 = 0; 88 u64 tpidrro_el0 = 0;
89}; 89};
90 90
91std::unique_ptr<Dynarmic::A64::Jit> MakeJit(const std::unique_ptr<ARM_Dynarmic_Callbacks>& cb) { 91std::unique_ptr<Dynarmic::A64::Jit> MakeJit(const std::unique_ptr<ARM_Dynarmic_Callbacks>& cb) {
92 Dynarmic::A64::UserConfig config{cb.get()}; 92 const auto page_table = Kernel::g_current_process->vm_manager.page_table.pointers.data();
93
94 Dynarmic::A64::UserConfig config;
95 config.callbacks = cb.get();
96 config.tpidrro_el0 = &cb->tpidrro_el0;
97 config.dczid_el0 = 4;
98 config.page_table = reinterpret_cast<void**>(page_table);
99 config.page_table_address_space_bits = Memory::ADDRESS_SPACE_BITS;
100 config.silently_mirror_page_table = false;
93 return std::make_unique<Dynarmic::A64::Jit>(config); 101 return std::make_unique<Dynarmic::A64::Jit>(config);
94} 102}
95 103
@@ -149,11 +157,11 @@ void ARM_Dynarmic::SetCPSR(u32 cpsr) {
149} 157}
150 158
151u64 ARM_Dynarmic::GetTlsAddress() const { 159u64 ARM_Dynarmic::GetTlsAddress() const {
152 return cb->tpidrr0_el0; 160 return cb->tpidrro_el0;
153} 161}
154 162
155void ARM_Dynarmic::SetTlsAddress(u64 address) { 163void ARM_Dynarmic::SetTlsAddress(u64 address) {
156 cb->tpidrr0_el0 = address; 164 cb->tpidrro_el0 = address;
157} 165}
158 166
159void ARM_Dynarmic::ExecuteInstructions(int num_instructions) { 167void ARM_Dynarmic::ExecuteInstructions(int num_instructions) {
@@ -170,7 +178,7 @@ void ARM_Dynarmic::SaveContext(ARM_Interface::ThreadContext& ctx) {
170 ctx.cpsr = jit->GetPstate(); 178 ctx.cpsr = jit->GetPstate();
171 ctx.fpu_registers = jit->GetVectors(); 179 ctx.fpu_registers = jit->GetVectors();
172 ctx.fpscr = jit->GetFpcr(); 180 ctx.fpscr = jit->GetFpcr();
173 ctx.tls_address = cb->tpidrr0_el0; 181 ctx.tls_address = cb->tpidrro_el0;
174} 182}
175 183
176void ARM_Dynarmic::LoadContext(const ARM_Interface::ThreadContext& ctx) { 184void ARM_Dynarmic::LoadContext(const ARM_Interface::ThreadContext& ctx) {
@@ -180,7 +188,7 @@ void ARM_Dynarmic::LoadContext(const ARM_Interface::ThreadContext& ctx) {
180 jit->SetPstate(static_cast<u32>(ctx.cpsr)); 188 jit->SetPstate(static_cast<u32>(ctx.cpsr));
181 jit->SetVectors(ctx.fpu_registers); 189 jit->SetVectors(ctx.fpu_registers);
182 jit->SetFpcr(static_cast<u32>(ctx.fpscr)); 190 jit->SetFpcr(static_cast<u32>(ctx.fpscr));
183 cb->tpidrr0_el0 = ctx.tls_address; 191 cb->tpidrro_el0 = ctx.tls_address;
184} 192}
185 193
186void ARM_Dynarmic::PrepareReschedule() { 194void ARM_Dynarmic::PrepareReschedule() {
diff --git a/src/core/memory.h b/src/core/memory.h
index b2158ca46..f3ace7a98 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -25,10 +25,11 @@ namespace Memory {
25 * Page size used by the ARM architecture. This is the smallest granularity with which memory can 25 * Page size used by the ARM architecture. This is the smallest granularity with which memory can
26 * be mapped. 26 * be mapped.
27 */ 27 */
28const int PAGE_BITS = 12; 28constexpr size_t PAGE_BITS = 12;
29const u64 PAGE_SIZE = 1 << PAGE_BITS; 29constexpr u64 PAGE_SIZE = 1 << PAGE_BITS;
30const u64 PAGE_MASK = PAGE_SIZE - 1; 30constexpr u64 PAGE_MASK = PAGE_SIZE - 1;
31const size_t PAGE_TABLE_NUM_ENTRIES = 1ULL << (36 - PAGE_BITS); 31constexpr size_t ADDRESS_SPACE_BITS = 36;
32constexpr size_t PAGE_TABLE_NUM_ENTRIES = 1ULL << (ADDRESS_SPACE_BITS - PAGE_BITS);
32 33
33enum class PageType : u8 { 34enum class PageType : u8 {
34 /// Page is unmapped and should cause an access error. 35 /// Page is unmapped and should cause an access error.