diff --git a/src/ds/core.c b/src/ds/core.c index b2ae25798..ec2019c7c 100644 --- a/src/ds/core.c +++ b/src/ds/core.c @@ -38,7 +38,7 @@ static bool _DSCoreInit(struct mCore* core) { free(ds); return false; } - core->cpu = arm7; + core->cpu = arm9; core->board = ds; core->debugger = NULL; dscore->arm7 = arm7; @@ -343,9 +343,6 @@ static void _DSCoreAttachDebugger(struct mCore* core, struct mDebugger* debugger DSDetachDebugger(core->board); } DSAttachDebugger(core->board, debugger); - struct ARMCore* cpu = core->cpu; - cpu->components[CPU_COMPONENT_DEBUGGER] = &debugger->d; - ARMHotplugAttach(cpu, CPU_COMPONENT_DEBUGGER); core->debugger = debugger; } diff --git a/src/ds/ds.c b/src/ds/ds.c index 90043ce26..30262d511 100644 --- a/src/ds/ds.c +++ b/src/ds/ds.c @@ -216,6 +216,10 @@ static void DSProcessEvents(struct ARMCore* cpu) { void DSAttachDebugger(struct DS* ds, struct mDebugger* debugger) { ds->debugger = (struct ARMDebugger*) debugger->platform; + ds->arm7->components[CPU_COMPONENT_DEBUGGER] = &debugger->d; + ds->arm9->components[CPU_COMPONENT_DEBUGGER] = &debugger->d; + ARMHotplugAttach(ds->arm7, CPU_COMPONENT_DEBUGGER); + ARMHotplugAttach(ds->arm9, CPU_COMPONENT_DEBUGGER); } void DSDetachDebugger(struct DS* ds) { diff --git a/src/ds/extra/cli.c b/src/ds/extra/cli.c index 43927e855..841b9027d 100644 --- a/src/ds/extra/cli.c +++ b/src/ds/extra/cli.c @@ -6,6 +6,9 @@ #include "cli.h" #include "arm/debugger/cli-debugger.h" +#include "core/core.h" +#include "ds/core.h" +#include "ds/ds.h" #ifdef USE_CLI_DEBUGGER @@ -14,9 +17,11 @@ static bool _DSCLIDebuggerCustom(struct CLIDebuggerSystem*); static uint32_t _DSCLIDebuggerLookupIdentifier(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv); static void _frame(struct CLIDebugger*, struct CLIDebugVector*); +static void _switchCpu(struct CLIDebugger*, struct CLIDebugVector*); struct CLIDebuggerCommandSummary _DSCLIDebuggerCommands[] = { { "frame", _frame, 0, "Frame advance" }, + { "cpu", _switchCpu, 0 , "Switch active CPU" }, { 0, 0, 0, 0 } }; @@ -59,4 +64,20 @@ static void _frame(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { struct DSCLIDebugger* dsDebugger = (struct DSCLIDebugger*) debugger->system; dsDebugger->frameAdvance = true; } + +static void _switchCpu(struct CLIDebugger* debugger, struct CLIDebugVector* dv) { + UNUSED(dv); + struct DSCLIDebugger* dsDebugger = (struct DSCLIDebugger*) debugger->system; + struct mCore* core = dsDebugger->core; + struct DS* ds = core->board; + debugger->d.platform->deinit(debugger->d.platform); + if (core->cpu == ds->arm9) { + core->cpu = ds->arm7; + } else { + core->cpu = ds->arm9; + } + debugger->d.platform->init(core->cpu, debugger->d.platform); + debugger->system->printStatus(debugger->system); +} + #endif