From 3bd42c4969f92d991605c89d4cb3112cc7c5e917 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Sat, 18 Jun 2011 16:13:35 +0800 Subject: preliminary kill command support When GDB Kill command received, reboot the brick. Conditionalize Step command support based on compiler flags. --- Debugger/debug_internals.h | 2 ++ Debugger/debug_runlooptasks.S | 22 +++++++++++++++++++++- Debugger/debug_stub.S | 29 +++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/Debugger/debug_internals.h b/Debugger/debug_internals.h index 82c0e38..9dc2bad 100644 --- a/Debugger/debug_internals.h +++ b/Debugger/debug_internals.h @@ -88,6 +88,8 @@ #define CMD_REG_SETONE_MINPARAMLEN (2 + CMD_REG_REGPARAMLEN) #define CMD_REG_SETONE_MAXPARAMLEN (3 + CMD_REG_REGPARAMLEN) #define CMD_REG_SETALL_PARAMLEN (CMD_REG_NUMREGS*CMD_REG_REGPARAMLEN) +#define CMD_KILL_PARAMLEN 0 + /*@}*/ /** @name Debug Memory Command Constants. diff --git a/Debugger/debug_runlooptasks.S b/Debugger/debug_runlooptasks.S index a9e0fcd..a80c46a 100644 --- a/Debugger/debug_runlooptasks.S +++ b/Debugger/debug_runlooptasks.S @@ -75,7 +75,7 @@ .code 32 .align 4 .global dbg__runloopTasks - + .global dbg__reboot #ifdef __NXOS__ /**************************************************************************** @@ -103,6 +103,26 @@ dbg__runloopTasks: pop {pc} #endif +#ifdef __NXOS__ + .extern nx_core_reset +/**************************************************************************** + * + * NxOS Reboot Routine + * + ****************************************************************************/ + dbg__reboot: + b nx_core_reset /* Reboot Brick, won't return */ + +#else +/**************************************************************************** + * + * NXT Firmware Reboot Routine + * + ****************************************************************************/ +dbg__reboot: + bx lr +#endif + #ifdef __NXOS__ /**************************************************************************** diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S index eb064fc..fc4f368 100644 --- a/Debugger/debug_stub.S +++ b/Debugger/debug_stub.S @@ -242,8 +242,13 @@ debug_cmdJumpTable: .word _dbg__cmd_ReadMem /* 'm' */ .word _dbg__cmd_WriteMem /* 'M' */ .word _dbg__cmd_Continue /* 'c' */ +#ifdef __NXOS__ + .word _dbg__cmd_Step /* 's' */ +#else + /* NXT Firmware does not support Stepping */ .word _dbg__nop /* 's' */ - .word _dbg__nop /* 'k' */ +#endif + .word _dbg__cmd_Kill /* 'k' */ .word _dbg__cmd_RemoveBreakpoint /* 'z' */ .word _dbg__cmd_InsertBreakpoint /* 'Z' */ .word _dbg__cmd_Status /* '?' */ @@ -1203,7 +1208,7 @@ _dbg__cont_is_manual_bkpt_or_address_specified: * Step User Program Execution Command Handler * Setup breakpoints before resuming execution of program. * - * If Address is specified, update the next instruction address to specified address + * If Address is specified, update the next instruction address to specified address * * If this is a Normal Breakpoint, then we need to install a Step Breakpoint at next instruction address * and resume from current (Breakpoint) exception address @@ -1260,6 +1265,26 @@ _dbg__step_is_manual_bkpt_or_address_specified: bl dbg__activate_singlestep b _dbg__switch2undefmode_withAck +/* _dbg__cmd_Kill + * Kill User Program Execution Command Handler + * Kill Program, this is accomplished by rebooting the Brick + * + * On entry: + * r0: parameter buffer pointer (contents after '$' and '') + * (No Parameters) + * On exit: + * r0-r7: destroyed + * Note: This routine does not return to caller. Instead it calls + * the relevant system routine to reboot the Brick + */ +_dbg__cmd_Kill: + stmfd sp!, {lr} /* In case unexpected parameters were received */ + bl __dbg__cmdParamLen + teq r1, #CMD_KILL_PARAMLEN /* Check for correct length */ + bne __dbg__procCmdParamError /* Unexpected input, report error */ + + bl __dbg__procAckOnly /* send Ack to keep GDB server happy */ + b dbg__reboot /* _dbg__proc_brkpt_params * Process Breakpoint Parameters -- cgit v1.2.3