summaryrefslogtreecommitdiff
path: root/emulator.cpp
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2022-09-23 10:00:55 +0300
committerOxore <oxore@protonmail.com>2022-09-25 15:06:52 +0300
commit2e363155df0380bed5210e41d395015320a9bb74 (patch)
treeda88603bdb250e40aa4c6853d6c37325a2d04aa4 /emulator.cpp
parent2233177e7ada45838dc61d1a5f98ff44f7fbc3a6 (diff)
Impl monitor reset and reset halt commands
Diffstat (limited to 'emulator.cpp')
-rw-r--r--emulator.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/emulator.cpp b/emulator.cpp
index 051c6db..5dd266a 100644
--- a/emulator.cpp
+++ b/emulator.cpp
@@ -95,11 +95,20 @@ static int setup_socket(uint16_t port)
return socket_fd;
}
+static inline bool IsReset(const std::string& command)
+{
+ if (command == "reset") return true;
+ if (command == "reset halt") return true;
+ if (command == "system_reset") return true;
+ return false;
+}
+
static std::string CreateResponse(
M68KDebuggingControl& m68k_debug,
const GDBRemote::Packet& packet)
{
using namespace GDBRemote;
+ // TODO use switch-case
if (0) {
} else if (packet.type == PacketType::kQueryHaltReason) {
return "S05"; // TODO real reason
@@ -116,6 +125,20 @@ static std::string CreateResponse(
return "OK";
} else if (packet.type == PacketType::kQueryAttached) {
return "1";
+ } else if (packet.type == PacketType::kQueryRcmd) {
+ const auto * const packet_data =
+ static_cast<const PacketDataRcmd*>(packet.data.get());
+ if (IsReset(packet_data->data)) {
+ m68k_pulse_reset();
+ // I don't want to skip reset cycles here, because GDB does not
+ // re-read registers every time, and if we skip reset cycles here,
+ // the consequent "stepi" in gdb will end up on second instruction
+ // of reset handler. If we don't skip reset cycles, the first
+ // "stepi" after "monitor reset" will land us on the first
+ // instruction in reset handler - I'd prefer this exact behavior for
+ // now.
+ return "OK";
+ }
} else if (packet.type == PacketType::kInterrupt) {
return "OK";
} else if (packet.type == PacketType::kSetBreakpoint) {
@@ -356,6 +379,7 @@ int main(int argc, char* argv[])
m68k_init();
m68k_set_cpu_type(M68K_CPU_TYPE_68000);
m68k_pulse_reset();
+ m68k_execute(1); // Skip reset cycles
emulator(g_m68k_debug);
while (0)