From c581a52793e2c7abb21a6d2cf3c35d717f60e0d2 Mon Sep 17 00:00:00 2001 From: Tat-Chee Wan (USM) Date: Tue, 18 Jan 2011 09:58:34 +0800 Subject: fixing command decoder after changes made to comm routines --- Debugger/debug_comm.S | 9 ------- Debugger/debug_macros.h | 66 ++++++++++++++++++++++++++++++++++--------------- Debugger/debug_stub.S | 8 +++--- Debugger/debug_stub.h | 1 - 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/Debugger/debug_comm.S b/Debugger/debug_comm.S index 15b9706..09c983f 100644 --- a/Debugger/debug_comm.S +++ b/Debugger/debug_comm.S @@ -57,15 +57,6 @@ hex2char_lut: /* Macros */ -/* _asciiz - * Terminate string given string buffer pointer in \addrptr - * reg is used as a scratch register (destroyed) - * - */ - .macro _asciiz reg, strptr - mov \reg, #0 /* NULL character */ - strb \reg, [\strptr] /* Terminate ASCIIZ string */ - .endm /* _hex2char_lut * Internal routine to intialize the LUT address pointer diff --git a/Debugger/debug_macros.h b/Debugger/debug_macros.h index 324bcbf..0d14951 100644 --- a/Debugger/debug_macros.h +++ b/Debugger/debug_macros.h @@ -72,6 +72,15 @@ ldm \instrmask, {\instrreg, \instrmask, \codehandler} .endm +/* _asciiz + * Terminate string given string buffer pointer in \addrptr + * reg is used as a scratch register (destroyed) + * + */ + .macro _asciiz reg, strptr + mov \reg, #0 /* NULL character */ + strb \reg, [\strptr] /* Terminate ASCIIZ string */ + .endm /* _dbg_stpcpy @@ -114,7 +123,7 @@ * Return Message with valid response ('+$') * On exit: * R0: destroyed - * R1: points to NULL character after the prefix + * R1: Pointer to Output Buffer next character slot location * R2: destroyed */ .macro _dbg_outputMsgValidResponse @@ -125,54 +134,71 @@ /* _dbg_outputMsgStatusOk - * Return Message with Ok ('+OK') status + * Return Message with Ok ('+$OK') status * On exit: * R0: destroyed - * R1: destroyed + * R1: Pointer to Output Buffer ASCIIZ location * R2: destroyed */ .macro _dbg_outputMsgStatusOk ldr r1, =debug_OutMsgBuf - ldr r2, =debug_OkResponse - _dbg_stpcpy r1, r2 + ldr r2, =debug_OkResponse /* ASCIIZ terminated */ + _dbg_stpcpy r1, r2 .endm /* _dbg_outputMsgStatusErr - * Return Message with Error ('-ENN') status + * Return Message with Error ('-$ENN') status * On entry: - * R0: register containing error value (byte) + * R0: error code * On exit: * R0: destroyed - * R1: destroyed + * R1: Pointer to Output Buffer ASCIIZ location * R2: destroyed * R3: destroyed */ .macro _dbg_outputMsgStatusErr - mov r3, r0 + mov r3, r0 + ldr r1, =debug_OutMsgBuf + ldr r2, =debug_ErrorResponsePrefix + _dbg_stpcpy r1, r2 + mov r0, r1 + mov r1, r3 + bl byte2ascii /* R0 points to buffer position after byte value */ + _asciiz r1, r0 + .endm + +/* _dbg_outputMsgStatusErrCode + * Return Message with Error ('-$ENN') status + * On exit: + * R0: destroyed + * R1: Pointer to Output Buffer ASCIIZ location + * R2: destroyed + */ + .macro _dbg_outputMsgStatusErrCode errcode ldr r1, =debug_OutMsgBuf ldr r2, =debug_ErrorResponsePrefix _dbg_stpcpy r1, r2 - mov r0, r3 - bl byte2ascii /* R1 points to NULL character after the prefix */ + mov r0, r1 + mov r1, #errcode + bl byte2ascii /* R0 points to buffer position after byte value */ + _asciiz r1, r0 .endm /* _dbg_outputMsgStatusSig - * Return Message with Signal ('+SNN') status - * On entry: - * R0: register containing error value (byte) + * Return Message with Signal ('+$SNN') status * On exit: * R0: destroyed - * R1: destroyed + * R1: Pointer to Output Buffer ASCIIZ location * R2: destroyed - * R3: destroyed */ - .macro _dbg_outputMsgStatusSig - mov r3, r0 + .macro _dbg_outputMsgStatusSig statuscode ldr r1, =debug_OutMsgBuf ldr r2, =debug_SignalResponsePrefix _dbg_stpcpy r1, r2 - mov r0, r3 - bl byte2ascii /* R1 points to NULL character after the prefix */ + mov r0, r1 + mov r1, #statuscode + bl byte2ascii /* R0 points to buffer position after byte value */ + _asciiz r1, r0 .endm /* _getdbgregisterfromindex diff --git a/Debugger/debug_stub.S b/Debugger/debug_stub.S index 508b619..f7a098d 100644 --- a/Debugger/debug_stub.S +++ b/Debugger/debug_stub.S @@ -530,8 +530,7 @@ _exit_cmdIndexTable: */ __dbg__procCmdParamError: - mov r0, #MSG_UNKNOWNPARAM - _dbg_outputMsgStatusErr + _dbg_outputMsgStatusErrCode MSG_UNKNOWNPARAM bl dbg__putDebugMsg /* Send error response to the GDB server */ ldmfd sp!, {pc} @@ -619,9 +618,8 @@ _dbg__procSetRegs: */ _dbg__nop: stmfd sp!, {lr} - mov r0, #MSG_ERRIMPL /* Stub, not implemented yet */ - _dbg_outputMsgStatusErr - bl dbg__putDebugMsg /* Send error response to the GDB server */ + _dbg_outputMsgStatusErrCode MSG_ERRIMPL /* Stub, not implemented yet */ + bl dbg__putDebugMsg /* Send error response to the GDB server */ ldmfd sp!, {pc} diff --git a/Debugger/debug_stub.h b/Debugger/debug_stub.h index 9cf4d0a..e7a9ce4 100644 --- a/Debugger/debug_stub.h +++ b/Debugger/debug_stub.h @@ -61,7 +61,6 @@ #define MSGBUF_SETCHAR '=' #define MSGBUF_CHKSUMCHAR '#' #define MSGBUF_MSGERROR -1 -#define MSGBUF_CMDINDEX_OUTOFRANGE_VAL -1 /*@}*/ /** @name Debug Stack Constants. -- cgit v1.2.3