diff options
Diffstat (limited to 'emulator.cpp')
-rw-r--r-- | emulator.cpp | 24 |
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) |