mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
Add cp15
This commit is contained in:
parent
e0204a1eff
commit
58fe2bcf18
4 changed files with 79 additions and 17 deletions
|
@ -48,6 +48,7 @@ set(SOURCE_FILES src/main.cpp src/emulator.cpp src/core/CPU/cpu_dynarmic.cpp src
|
||||||
)
|
)
|
||||||
set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp include/termcolor.hpp
|
set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp include/termcolor.hpp
|
||||||
include/cpu.hpp include/cpu_dynarmic.hpp include/memory.hpp include/kernel.hpp
|
include/cpu.hpp include/cpu_dynarmic.hpp include/memory.hpp include/kernel.hpp
|
||||||
|
include/dynarmic_cp15.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
|
|
||||||
#include "dynarmic/interface/A32/a32.h"
|
#include "dynarmic/interface/A32/a32.h"
|
||||||
#include "dynarmic/interface/A32/config.h"
|
#include "dynarmic/interface/A32/config.h"
|
||||||
|
#include "dynarmic_cp15.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "kernel.hpp"
|
#include "kernel.hpp"
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
|
|
||||||
class MyEnvironment final : public Dynarmic::A32::UserCallbacks {
|
class MyEnvironment final : public Dynarmic::A32::UserCallbacks {
|
||||||
public:
|
public:
|
||||||
u64 ticks_left = 0;
|
u64 ticksLeft = 0;
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
Kernel& kernel;
|
Kernel& kernel;
|
||||||
|
|
||||||
|
@ -59,23 +60,23 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTicks(u64 ticks) override {
|
void AddTicks(u64 ticks) override {
|
||||||
if (ticks > ticks_left) {
|
if (ticks > ticksLeft) {
|
||||||
ticks_left = 0;
|
ticksLeft = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ticks_left -= ticks;
|
ticksLeft -= ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 GetTicksRemaining() override {
|
u64 GetTicksRemaining() override {
|
||||||
return ticks_left;
|
return ticksLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyEnvironment(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
|
MyEnvironment(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CPU {
|
class CPU {
|
||||||
|
std::unique_ptr<Dynarmic::A32::Jit> jit;
|
||||||
MyEnvironment env;
|
MyEnvironment env;
|
||||||
Dynarmic::A32::Jit jit{ {.callbacks = &env} };
|
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -83,28 +84,28 @@ public:
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void setReg(int index, u32 value) {
|
void setReg(int index, u32 value) {
|
||||||
jit.Regs()[index] = value;
|
jit->Regs()[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getReg(int index) {
|
u32 getReg(int index) {
|
||||||
return jit.Regs()[index];
|
return jit->Regs()[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<u32, 16>& regs() {
|
std::array<u32, 16>& regs() {
|
||||||
return jit.Regs();
|
return jit->Regs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCPSR(u32 value) {
|
void setCPSR(u32 value) {
|
||||||
jit.SetCpsr(value);
|
jit->SetCpsr(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 getCPSR() {
|
u32 getCPSR() {
|
||||||
return jit.Cpsr();
|
return jit->Cpsr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runFrame() {
|
void runFrame() {
|
||||||
env.ticks_left = 268111856 / 60;
|
env.ticksLeft = 268111856 / 60;
|
||||||
const auto exitReason = jit.Run();
|
const auto exitReason = jit->Run();
|
||||||
Helpers::panic("Exit reason: %d", (u32)exitReason);
|
Helpers::panic("Exit reason: %d", (u32)exitReason);
|
||||||
}
|
}
|
||||||
};
|
};
|
53
include/dynarmic_cp15.hpp
Normal file
53
include/dynarmic_cp15.hpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dynarmic/interface/A32/a32.h"
|
||||||
|
#include "dynarmic/interface/A32/config.h"
|
||||||
|
#include "dynarmic/interface/A32/coprocessor.h"
|
||||||
|
#include "helpers.hpp"
|
||||||
|
|
||||||
|
class CP15 final : public Dynarmic::A32::Coprocessor {
|
||||||
|
using Callback = Dynarmic::A32::Coprocessor::Callback;
|
||||||
|
using CoprocReg = Dynarmic::A32::CoprocReg;
|
||||||
|
using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord;
|
||||||
|
using CallbackOrAccessTwoWords = Dynarmic::A32::Coprocessor::CallbackOrAccessTwoWords;
|
||||||
|
|
||||||
|
u32 threadStoragePointer = 0x696966969; // Pointer to thread-local storage
|
||||||
|
|
||||||
|
std::optional<Callback> CompileInternalOperation(bool two, unsigned opc1,
|
||||||
|
CoprocReg CRd, CoprocReg CRn,
|
||||||
|
CoprocReg CRm, unsigned opc2) override {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
CallbackOrAccessOneWord CompileSendOneWord(bool two, unsigned opc1, CoprocReg CRn,
|
||||||
|
CoprocReg CRm, unsigned opc2) override {
|
||||||
|
Helpers::panic("CP15: CompileSendOneWord\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
CallbackOrAccessTwoWords CompileSendTwoWords(bool two, unsigned opc, CoprocReg CRm) override {
|
||||||
|
return std::monostate{};
|
||||||
|
}
|
||||||
|
|
||||||
|
CallbackOrAccessOneWord CompileGetOneWord(bool two, unsigned opc1, CoprocReg CRn,
|
||||||
|
CoprocReg CRm, unsigned opc2) override {
|
||||||
|
Helpers::panic("CP15: CompileGetOneWord");
|
||||||
|
}
|
||||||
|
|
||||||
|
CallbackOrAccessTwoWords CompileGetTwoWords(bool two, unsigned opc, CoprocReg CRm) override {
|
||||||
|
return std::monostate{};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<Callback> CompileLoadWords(bool two, bool long_transfer, CoprocReg CRd,
|
||||||
|
std::optional<u8> option) override {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<Callback> CompileStoreWords(bool two, bool long_transfer, CoprocReg CRd,
|
||||||
|
std::optional<u8> option) override {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,15 +1,22 @@
|
||||||
#ifdef CPU_DYNARMIC
|
#ifdef CPU_DYNARMIC
|
||||||
#include "cpu_dynarmic.hpp"
|
#include "cpu_dynarmic.hpp"
|
||||||
|
|
||||||
CPU::CPU(Memory& mem, Kernel& kernel) : mem(mem), env(mem, kernel) {}
|
CPU::CPU(Memory& mem, Kernel& kernel) : mem(mem), env(mem, kernel) {
|
||||||
|
Dynarmic::A32::UserConfig config;
|
||||||
|
|
||||||
|
config.callbacks = &env;
|
||||||
|
config.coprocessors[15] = std::make_shared<CP15>();
|
||||||
|
jit = std::make_unique<Dynarmic::A32::Jit>(config);
|
||||||
|
}
|
||||||
|
|
||||||
void CPU::reset() {
|
void CPU::reset() {
|
||||||
// ARM mode, all flags disabled, interrupts and aborts all enabled, user mode
|
// ARM mode, all flags disabled, interrupts and aborts all enabled, user mode
|
||||||
|
|
||||||
setCPSR(0x00000010);
|
setCPSR(0x00000010);
|
||||||
|
|
||||||
jit.Reset();
|
jit->Reset();
|
||||||
jit.ClearCache();
|
jit->ClearCache();
|
||||||
jit.Regs().fill(0);
|
jit->Regs().fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CPU_DYNARMIC
|
#endif // CPU_DYNARMIC
|
Loading…
Add table
Reference in a new issue