aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/Debugger/debug_macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'AT91SAM7S256/armdebug/Debugger/debug_macros.h')
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_macros.h195
1 files changed, 136 insertions, 59 deletions
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_macros.h b/AT91SAM7S256/armdebug/Debugger/debug_macros.h
index 75d6299..8d63e46 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_macros.h
+++ b/AT91SAM7S256/armdebug/Debugger/debug_macros.h
@@ -67,7 +67,7 @@
*/
.macro _dbg_armDecodeEntry instrreg, instrmask, codehandler, indexreg
- ldr \instrmask, =debug_thumbDecodeTable /* Temporary register */
+ ldr \instrmask, =debug_armDecodeTable /* Temporary register */
add \instrmask, \instrmask, \indexreg, lsl #3
add \instrmask, \instrmask, \indexreg, lsl #2 /* 12 byte entries */
ldm \instrmask, {\instrreg, \instrmask, \codehandler}
@@ -122,17 +122,44 @@
bne 1b
.endm
+/* _dbg_CopyMsg2OutputBuf
+ * Copies source message to output buffer
+ * On entry:
+ * R2: source message buffer (ASCIIZ terminated)
+ * On exit:
+ * R0: Pointer to Output Buffer ASCIIZ location
+ * R2-R3: destroyed
+ */
+ .macro _dbg_CopyMsg2OutputBuf
+ ldr r0, =debug_OutMsgBuf
+ _dbg_stpcpy r0, r2, r3
+ .endm
+
+/* _dbg_CopyMsg2OutputBuf_withParam
+ * Internal Routine called to output message with parameters
+ * Return Message with byte-sized parameter
+ * On entry:
+ * R1: byte-sized param
+ * R2: source message buffer (ASCIIZ terminated)
+ * On exit:
+ * R0: Pointer to Output Buffer ASCIIZ location
+ * R1-R3: destroyed
+ */
+ .macro _dbg_CopyMsg2OutputBuf_withParam
+ _dbg_CopyMsg2OutputBuf /* R1 unchanged */
+ bl byte2ascii /* R0 points to buffer position after byte value */
+ _asciiz r0, r1
+ .endm
+
/* _dbg_outputAckOnlyFlag
* Return Flag ('+') for Continue or Step
* On exit:
* R0: Pointer to Output Buffer ASCIIZ location
- * R1: destroyed
- * R2: destroyed
+ * R2-R3: destroyed
*/
.macro _dbg_outputAckOnlyFlag
- ldr r0, =debug_OutMsgBuf
- ldr r1, =debug_AckOnlyFlag /* ASCIIZ terminated */
- _dbg_stpcpy r0, r1, r2
+ ldr r2, =debug_AckOnlyFlag /* ASCIIZ terminated */
+ _dbg_CopyMsg2OutputBuf
.endm
@@ -140,104 +167,117 @@
* Return Flag ('-') for Checksum Error (retransmission needed)
* On exit:
* R0: Pointer to Output Buffer ASCIIZ location
- * R1: destroyed
- * R2: destroyed
+ * R2-R3: destroyed
*/
.macro _dbg_outputRetransmitFlag
- ldr r0, =debug_OutMsgBuf
- ldr r1, =debug_RetransmitFlag /* ASCIIZ terminated */
- _dbg_stpcpy r0, r1, r2
+ ldr r2, =debug_RetransmitFlag /* ASCIIZ terminated */
+ _dbg_CopyMsg2OutputBuf
.endm
/* _dbg_outputMsgValidResponse
* Return Message with valid response ('+$')
* On exit:
* R0: Pointer to Output Buffer next character slot location
- * R1: destroyed
- * R2: destroyed
+ * R2-R3: destroyed
*/
.macro _dbg_outputMsgValidResponse
- ldr r0, =debug_OutMsgBuf
- ldr r1, =debug_ValidResponsePrefix
- _dbg_stpcpy r0, r1, r2
+ ldr r2, =debug_ValidResponsePrefix
+ _dbg_CopyMsg2OutputBuf
.endm
-
/* _dbg_outputMsgStatusOk
* Return Message with Ok ('+$OK') status
* On exit:
* R0: Pointer to Output Buffer ASCIIZ location
- * R1: destroyed
- * R2: destroyed
+ * R2-R3: destroyed
*/
.macro _dbg_outputMsgStatusOk
- ldr r0, =debug_OutMsgBuf
- ldr r1, =debug_OkResponse /* ASCIIZ terminated */
- _dbg_stpcpy r0, r1, r2
+ ldr r2, =debug_OkResponse /* ASCIIZ terminated */
+ _dbg_CopyMsg2OutputBuf
.endm
-/* __dbg_outputErrMsg
- * Internal Routine called to generate error messages
- * Return Message with Error ('+$ENN') status
- * On entry:
- * R1: error code
- * On exit:
+/* _dbg_outputMsgCurrTID
+ * Return Message with Default Thread ID ('+$QC0')
+ * On exit:
* R0: Pointer to Output Buffer ASCIIZ location
- * R1: destroyed
- * R2: destroyed
- * R3: destroyed
- */
- .macro __dbg_outputErrMsg
- ldr r0, =debug_OutMsgBuf
- ldr r2, =debug_ErrorResponsePrefix
- _dbg_stpcpy r0, r2, r3
- bl byte2ascii /* R0 points to buffer position after byte value */
- _asciiz r0, r1
- .endm
+ * R2-R3: destroyed
+ */
+ .macro _dbg_outputMsgCurrTID
+ ldr r2, =debug_ThreadIDResponse /* ASCIIZ terminated */
+ _dbg_CopyMsg2OutputBuf
+ .endm
+
+/* _dbg_outputMsgFirstThreadInfo
+ * Return Message with Default Current Thread ID ('+$m0')
+ * On exit:
+ * R0: Pointer to Output Buffer ASCIIZ location
+ * R2-R3: destroyed
+ */
+ .macro _dbg_outputMsgFirstThreadInfo
+ ldr r2, =debug_FirstThreadInfoResponse /* ASCIIZ terminated */
+ _dbg_CopyMsg2OutputBuf
+ .endm
+
+/* _dbg_outputMsgSubsequentThreadInfo
+ * Return Message with Default Current Thread ID ('+$m0')
+ * On exit:
+ * R0: Pointer to Output Buffer ASCIIZ location
+ * R2-R3: destroyed
+ */
+ .macro _dbg_outputMsgSubsequentThreadInfo
+ ldr r2, =debug_SubsequentThreadInfoResponse /* ASCIIZ terminated */
+ _dbg_CopyMsg2OutputBuf
+ .endm
/* _dbg_outputMsgStatusErr
* Return Message with Error ('+$ENN') status
* On entry:
- * R0: error code
+ * R1: error code
* On exit:
* R0: Pointer to Output Buffer ASCIIZ location
- * R1: destroyed
- * R2: destroyed
- * R3: destroyed
+ * R1-R3: destroyed
*/
.macro _dbg_outputMsgStatusErr
- mov r1, r0
- __dbg_outputErrMsg
+ ldr r2, =debug_ErrorResponsePrefix
+ _dbg_CopyMsg2OutputBuf_withParam
.endm
/* _dbg_outputMsgStatusErrCode
* Return Message with Error ('+$ENN') status
* On exit:
* R0: Pointer to Output Buffer ASCIIZ location
- * R1: destroyed
- * R2: destroyed
+ * R1-R3: destroyed
*/
.macro _dbg_outputMsgStatusErrCode errcode
mov r1, #\errcode
- __dbg_outputErrMsg
+ _dbg_outputMsgStatusErr
.endm
/* _dbg_outputMsgStatusSig
* Return Message with Signal ('+$SNN') status
+ * On entry:
+ * R1: signal code
* On exit:
* R0: Pointer to Output Buffer ASCIIZ location
- * R1: destroyed
- * R2: destroyed
+ * R1-R3: destroyed
*/
- .macro _dbg_outputMsgStatusSig statuscode
- ldr r0, =debug_OutMsgBuf
- ldr r1, =debug_SignalResponsePrefix
- _dbg_stpcpy r0, r1, r2
+ .macro _dbg_outputMsgStatusSig
+ ldr r2, =debug_SignalResponsePrefix
+ _dbg_CopyMsg2OutputBuf_withParam
+ .endm
+
+/* _dbg_outputMsgStatusSigCode
+ * Return Message with Signal ('+$SNN') status
+ * On exit:
+ * R0: Pointer to Output Buffer ASCIIZ location
+ * R1-R3: destroyed
+ */
+ .macro _dbg_outputMsgStatusSigCode statuscode
mov r1, #\statuscode
- bl byte2ascii /* R0 points to buffer position after byte value */
- _asciiz r0, r1
+ _dbg_outputMsgStatusSig
.endm
+
/* _regenum2index
* Convert register enum to debugger stack index
*
@@ -281,6 +321,34 @@
str \contentsreg, [\addressreg, \indexreg, lsl #2]
.endm
+/* _getdbgregister
+ * Retrieve register contents from debugger stack given immediate index value
+ *
+ * On entry:
+ * indexval contains debugger stack index value (0-max index)
+ * On exit:
+ * contentsreg: Register Contents for given index
+ */
+ .macro _getdbgregister indexval, contentsreg
+ ldr \contentsreg, =__debugger_stack_bottom__
+ ldr \contentsreg, [\contentsreg, #(\indexval << 2)]
+ .endm
+
+/* _setdbgregister
+ * Store register contents to debugger stack given immediate index value
+ *
+ * On entry:
+ * indexval contains debugger stack index value (0-max index)
+ * contentsreg: Register Contents for given index
+ * addressreg: Scratch register for address pointer
+ * On exit:
+ * contentsreg: Register Contents for given index
+ * addressreg: Destroyed
+ */
+ .macro _setdbgregister indexval, contentsreg, addressreg
+ ldr \addressreg, =__debugger_stack_bottom__
+ str \contentsreg, [\addressreg, #(\indexval << 2)]
+ .endm
/* _index2bkptindex_addr
* Convert Breakpoint index to breakpoing entry address
@@ -349,18 +417,27 @@
.endm
/* _dbg_set_bkpt_type
+ * Set Breakpoint Type using value in reg
+ * On exit:
+ * reg: destroyed
+ * r1: destroyed
+ */
+ .macro _dbg_set_bkpt_type reg
+ ldr r1, =debug_bkpt_type
+ strb \reg, [r1]
+ .endm
+
+/* _dbg_set_bkpt_type_val
* Set Breakpoint Type to given value
* On exit:
* r0, r1: destroyed
*/
- .macro _dbg_set_bkpt_type bkpt_type
+ .macro _dbg_set_bkpt_type_val bkpt_type
mov r0, #\bkpt_type
ldr r1, =debug_bkpt_type
strb r0, [r1]
.endm
-
-
/* _dbg_getcurrbkpt_index
* Get current breakpoint index
* On exit: