read code and halt
This commit is contained in:
parent
ae0e084251
commit
68a966f9bd
3 changed files with 17 additions and 0 deletions
|
|
@ -18,6 +18,8 @@ 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 dcc_read(self) -> int:
|
||||
...
|
||||
def dcc_write(self, value: typing.SupportsInt | typing.SupportsIndex) -> None:
|
||||
|
|
@ -26,6 +28,8 @@ class Dynemu:
|
|||
...
|
||||
def get_reg(self, reg_num: typing.SupportsInt | typing.SupportsIndex) -> int:
|
||||
...
|
||||
def halt(self) -> None:
|
||||
...
|
||||
def memory_map(self, vaddr: typing.SupportsInt | typing.SupportsIndex, size: typing.SupportsInt | typing.SupportsIndex) -> None:
|
||||
...
|
||||
@typing.overload
|
||||
|
|
|
|||
|
|
@ -419,6 +419,9 @@ namespace Dynemu {
|
|||
Dynarmic::HaltReason returnCode = cpu->Run();
|
||||
cpu->ClearCache();
|
||||
|
||||
if (returnCode == Dynarmic::HaltReason::MemoryAbort)
|
||||
throw std::runtime_error("attempted to access outside memory bounds");
|
||||
|
||||
return cpu->Regs()[0];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ struct Emu {
|
|||
return emu.env.MemoryRead64(vaddr);
|
||||
}
|
||||
|
||||
std::optional<u32> read_code(u32 vaddr) {
|
||||
return emu.env.MemoryReadCode(vaddr);
|
||||
}
|
||||
|
||||
void write_u8(u32 vaddr, u8 value) {
|
||||
emu.env.MemoryWrite8(vaddr, value);
|
||||
}
|
||||
|
|
@ -109,6 +113,10 @@ struct Emu {
|
|||
return emu.env.Execute(pc, stub_mode);
|
||||
}
|
||||
|
||||
void halt() {
|
||||
emu.env.cpu->HaltExecution(Dynarmic::HaltReason::Step);
|
||||
}
|
||||
|
||||
u32 get_reg(u8 reg_num) {
|
||||
return emu.env.cpu->Regs()[reg_num];
|
||||
}
|
||||
|
|
@ -155,6 +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("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"))
|
||||
|
|
@ -163,6 +172,7 @@ PYBIND11_MODULE(_dynemu, module, py::mod_gil_not_used()) {
|
|||
.def("write_bytes", static_cast<void (Emu::*)(u32, py::bytes)>(&Emu::write_bytes), py::arg("vaddr"), py::arg("data"))
|
||||
.def("write_bytes", static_cast<void (Emu::*)(u32, py::bytearray)>(&Emu::write_bytes), py::arg("vaddr"), py::arg("data"))
|
||||
.def("execute", &Emu::execute, py::arg("pc"), py::arg("stub_mode") = true)
|
||||
.def("halt", &Emu::halt)
|
||||
.def("get_reg", &Emu::get_reg, py::arg("reg_num"))
|
||||
.def("set_reg", &Emu::set_reg, py::arg("reg_num"), py::arg("value"))
|
||||
.def("dcc_read", &Emu::dcc_read)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue