From e1e0d31f9aad0ed6c64f61208e94cef43e256de7 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Thu, 24 Mar 2011 10:43:07 +0800 Subject: cleaned up register get and set routines --- Debugger/debug_stub.h | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'Debugger/debug_stub.h') diff --git a/Debugger/debug_stub.h b/Debugger/debug_stub.h index 7dc9aa8..229c6d6 100644 --- a/Debugger/debug_stub.h +++ b/Debugger/debug_stub.h @@ -147,9 +147,9 @@ #define DBGSTACK_NEXTINSTR_INDEX 0 /* Next Instruction Address is at index 0 from bottom of Debug Stack */ #define DBGSTACK_USERCPSR_INDEX 1 /* User CPSR (SPSR_UNDEF) is at index 1 from bottom of Debug Stack */ #define DBGSTACK_USERREG_INDEX 2 /* R0 starts at index 2 from bottom of Debug Stack */ -#define DBGSTACK_USERSP_INDEX (DBGSTACK_USERREG_INDEX + 13) /* SP is R13 */ -#define DBGSTACK_USERPC_INDEX (DBGSTACK_USERREG_INDEX + 15) /* PC is R15 */ -#define DBGSTACK_USERCPSR_OFFSET (DBGSTACK_USERCPSR_INDEX-DBGSTACK_USERREG_INDEX) /* = -1, offset for calculating Debug Stack index */ +#define DBGSTACK_USERSP_INDEX (DBGSTACK_USERREG_INDEX + REG_SP) /* SP is R13 */ +#define DBGSTACK_USERLR_INDEX (DBGSTACK_USERREG_INDEX + REG_LR) /* LR is R14 */ +#define DBGSTACK_USERPC_INDEX (DBGSTACK_USERREG_INDEX + REG_PC) /* PC is R15 */ /*@}*/ /** @name Bitmask Definitions. @@ -252,6 +252,32 @@ ENUM_VAL(MSG_UNKNOWNPARAM) /**< Unrecognized Parameter Error. */ ENUM_VAL(MSG_UNKNOWNBRKPT) /**< Unrecognized Breakpoint Error. */ ENUM_END(dbg_msg_errno) +/** Register Enums + * + * Register Enums. + * The enums must be consecutive, starting from -1 + */ +ENUM_BEGIN +ENUM_VALASSIGN(REG_CPSR, -1) /**< Previous Mode CPSR */ +ENUM_VAL(REG_R0) /**< User Reg R0 */ +ENUM_VAL(REG_R1) /**< User Reg R1 */ +ENUM_VAL(REG_R2) /**< User Reg R2 */ +ENUM_VAL(REG_R3) /**< User Reg R3 */ +ENUM_VAL(REG_R4) /**< User Reg R4 */ +ENUM_VAL(REG_R5) /**< User Reg R5 */ +ENUM_VAL(REG_R6) /**< User Reg R6 */ +ENUM_VAL(REG_R7) /**< User Reg R7 */ +ENUM_VAL(REG_R8) /**< User Reg R8 */ +ENUM_VAL(REG_R9) /**< User Reg R9 */ +ENUM_VAL(REG_R10) /**< User Reg R10 */ +ENUM_VAL(REG_R11) /**< User Reg R11 */ +ENUM_VAL(REG_R12) /**< User Reg R12 */ +ENUM_VAL(REG_SP) /**< Previous Mode SP (R13) */ +ENUM_VAL(REG_LR) /**< Previous Mode LR (R14) */ +ENUM_VAL(REG_PC) /**< Program Counter (R15) */ + +ENUM_END(register_enum_t) + #ifndef __ASSEMBLY__ -- cgit v1.2.3 From ccc74cd2f443d57b3edc29a94935ed8f13ffef46 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Thu, 24 Mar 2011 11:01:26 +0800 Subject: cater for variable length address parameters --- Debugger/debug_stub.S | 11 ++++++++++- Debugger/debug_stub.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'Debugger/debug_stub.h') diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S index de126be..fb64b51 100644 --- a/Debugger/debug_stub.S +++ b/Debugger/debug_stub.S @@ -970,9 +970,12 @@ _dbg__nop: _dbg__cmd_ReadMem: stmfd sp!, {lr} bl __dbg__cmdParamLen +#if 0 teq r1, #CMD_MEM_READ_PARAMLEN /* Check for correct length */ bne __dbg__procCmdParamError /* Unexpected input, report error */ bl ascii2word_be /* convert ASCII address location to Hex (in R0), R1 has address of next buffer char */ +#endif + bl ascii2hex_varlen_be /* convert ASCII address to Hex (in R0), R1 has address of next buffer char */ mov r3, r0 /* Keep Address location in R3 */ _check_msgseparator r1 bne __dbg__procCmdParamError /* Can't find ',' */ @@ -1005,10 +1008,13 @@ _dbg__cmd_ReadMem: _dbg__cmd_WriteMem: stmfd sp!, {lr} bl __dbg__cmdParamLen +#if 0 cmp r1, #CMD_MEM_WRITE_MINPARAMLEN /* Check for correct (minimum) length */ blo __dbg__procCmdParamError /* Unexpected input, report error */ sub r4, r1, #CMD_MEM_WRITE_MINPARAMLEN /* R4: Number of ASCII Hex chars for byte writes */ bl ascii2word_be /* convert ASCII address location to Hex (in R0), R1 has address of next buffer char */ +#endif + bl ascii2hex_varlen_be /* convert ASCII address to Hex (in R0), R1 has address of next buffer char */ mov r3, r0 /* Keep Address location in R3 */ _check_msgseparator r1 bne __dbg__procCmdParamError /* Can't find ',' */ @@ -1044,10 +1050,13 @@ _dbg__cmd_Continue: bl __dbg__cmdParamLen cmp r1, #CMD_REG_CONTINUE_PARAMLEN /* Check for correct parameter length */ beq _dbg__cmd_processContinue /* Continue from current PC */ +#if 0 cmp r1, #CMD_REG_CONTINUEFROM_PARAMLEN /* Check for correct parameter length */ bne __dbg__procCmdParamError /* Unexpected input, report error */ - /* Continue from Specified Address */ bl ascii2word_be /* convert ASCII address location to Hex (in R0), R1 has address of next buffer char */ +#endif + bl ascii2hex_varlen_be /* convert ASCII address to Hex (in R0), R1 has address of next buffer char */ + /* Continue from Specified Address */ mov r2, #DBGSTACK_NEXTINSTR_INDEX /* The Next Instruction Pointer for Resume is in index 0 of the Debug Stack */ _setdbgregisterfromindex r2, r0, r1 /* Set Register contents in R0, using index in R2, and scratch register R1 */ diff --git a/Debugger/debug_stub.h b/Debugger/debug_stub.h index 229c6d6..9d97705 100644 --- a/Debugger/debug_stub.h +++ b/Debugger/debug_stub.h @@ -92,6 +92,8 @@ /** @name Debug Memory Command Constants. * * Debug Memory Command + * FIXME: These limits are not enforced by the GDB client, it truncates addresses and lengths to remove leading '0's + * The PARAMLEN constants would probably be removed */ /*@{*/ #define CMD_NUMITEMS_PARAMLEN 4 /* 16-bit ASCII Hex Value */ @@ -110,7 +112,6 @@ */ /*@{*/ #define CMD_REG_CONTINUE_PARAMLEN 0 -#define CMD_REG_CONTINUEFROM_PARAMLEN CMD_REG_REGPARAMLEN /* Address length is equivalent to reg param len */ /*@}*/ -- cgit v1.2.3