read code update

This commit is contained in:
wrapper 2026-03-29 18:58:45 +07:00
parent 68a966f9bd
commit fea76d7347
5 changed files with 19 additions and 8 deletions

View file

@ -18,7 +18,7 @@ class Dynemu:
ARM7_ARM9: typing.ClassVar[Dynemu.DCCType] # value = <DCCType.ARM7_ARM9: 0>
def __init__(self, dcc_type: Dynemu.DCCType = DCCType.ARM7_ARM9, no_opts: bool = False, big_endian: bool = False) -> None:
...
def _read_code(self, vaddr: typing.SupportsInt | typing.SupportsIndex) -> int | None:
def _read_code(self, vaddr: typing.SupportsInt | typing.SupportsIndex, is_thumb: bool) -> int | None:
...
def dcc_read(self) -> int:
...

View file

@ -161,11 +161,19 @@ namespace Dynemu {
*/
bool PreCodeReadHook(bool is_thumb, u32 pc, Dynarmic::A32::IREmitter& ir) override;
/*
std::optional<u32> MemoryReadCode(u32 vaddr, bool is_thumb)
Custom function used in code read routines.
*/
std::optional<u32> MemoryReadCode(u32 vaddr, bool is_thumb);
/*
std::optional<u32> MemoryReadCode(u32 vaddr)
Custom function used in code read routines.
*/
std::optional<u32> MemoryReadCode(u32 vaddr) override;
std::optional<u32> MemoryReadCode(u32 vaddr) override {
return MemoryReadCode(vaddr, thumb_mode);
}
/*
u8 MemoryRead8(u32 vaddr)

View file

@ -6,7 +6,7 @@ set_target_properties(dynemu PROPERTIES
VERSION ${Dynemu_VERSION}
SOVERSION ${Dynemu_VERSION_MAJOR})
add_dependencies(dynemu dynarmic mcl)
target_link_libraries(dynemu PUBLIC dynarmic mcl)
target_link_libraries(dynemu PUBLIC dynarmic mcl Boost::boost)
target_include_directories(dynemu PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>")
target_compile_features(dynemu PUBLIC cxx_std_20)

View file

@ -11,6 +11,7 @@
#include "dynarmic/interface/A32/coprocessor.h"
#include "dynarmic/interface/exclusive_monitor.h"
#include "dynarmic/interface/optimization_flags.h"
#include "dynarmic/frontend/A32/a32_ir_emitter.h"
#include "mcl/assert.hpp"
@ -213,13 +214,15 @@ namespace Dynemu {
thumb_mode = is_thumb;
if (stub_mode && pc == (os_offset + ROUTE_EXIT)) {
cpu->HaltExecution(Dynarmic::HaltReason::Step);
ir.SetTerm(Dynarmic::IR::Term::CheckHalt{Dynarmic::IR::Term::ReturnToDispatch{}});
return false;
}
return true;
}
std::optional<u32> MyEmulator::MemoryReadCode(u32 vaddr) {
std::optional<u32> MyEmulator::MemoryReadCode(u32 vaddr, bool is_thumb) {
u32 temp;
if (auto ret = handle_mmio_read(vaddr, 4); ret.has_value()) {
@ -230,7 +233,7 @@ namespace Dynemu {
return std::nullopt;
}
if (big_endian && thumb_mode) {
if (big_endian && is_thumb) {
temp = MemoryRead8(vaddr + 1);
temp |= MemoryRead8(vaddr) << 8;
temp |= MemoryRead8(vaddr + 3) << 16;

View file

@ -72,8 +72,8 @@ struct Emu {
return emu.env.MemoryRead64(vaddr);
}
std::optional<u32> read_code(u32 vaddr) {
return emu.env.MemoryReadCode(vaddr);
std::optional<u32> read_code(u32 vaddr, bool is_thumb) {
return emu.env.MemoryReadCode(vaddr, is_thumb);
}
void write_u8(u32 vaddr, u8 value) {
@ -163,7 +163,7 @@ PYBIND11_MODULE(_dynemu, module, py::mod_gil_not_used()) {
.def("read_u16", &Emu::read_u16, py::arg("vaddr"))
.def("read_u32", &Emu::read_u32, py::arg("vaddr"))
.def("read_u64", &Emu::read_u64, py::arg("vaddr"))
.def("_read_code", &Emu::read_code, py::arg("vaddr"))
.def("_read_code", &Emu::read_code, py::arg("vaddr"), py::arg("is_thumb"))
.def("write_u8", &Emu::write_u8, py::arg("vaddr"), py::arg("value"))
.def("write_u16", &Emu::write_u16, py::arg("vaddr"), py::arg("value"))
.def("write_u32", &Emu::write_u32, py::arg("vaddr"), py::arg("value"))