aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_comm.S26
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_macros.h2
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_stub.S32
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_stub.h7
4 files changed, 65 insertions, 2 deletions
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_comm.S b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
index 77b2175..eee38a5 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_comm.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
@@ -45,6 +45,11 @@ debug_msgTxBuf_AppendPtr:
debug_segmentRxNum: /* Current Rx Segment Number */
.word 0x0
+#ifndef __NXOS__
+debug_nxtMsgLength: /* NXT Firmware Received USB Message Length */
+ .word 0x0
+#endif
+
.data
.align 4
@@ -391,7 +396,28 @@ _dbg__usbbuf_reset:
ldmfd sp!, {pc}
#else
/* FIXME: NXT Firmware support */
+ ldr r1, =debug_nxtMsgLength
+ mov r0, #0
+ str r0, [r1] /* Clear NXT USB Received Message Length */
bx lr
+
+ .global dbg__copyNxtDebugMsg
+/* dbg__copyNxtDebugMsg
+ * Copy NXT Firmware Debug Message to our own Buffers, indicate Msg Received status.
+ * On Entry:
+ * R0: NXT USB Input Buf Pointer
+ * R1: USB Command Bit
+ * R2: USB Raw Message Length
+ * On Exit:
+ * R0-R3: Destroyed
+ */
+
+dbg__copyNxtDebugMsg:
+ ldr r1, =debug_nxtMsgLength
+ str r2, [r1]
+ ldr r1, =debug_InUSBBuf
+ _dbg_memcpy r1, r0, r2, r3 /* r3: scratch register */
+ bx lr
#endif
/* _dbg_reset_msgTxBuf_AppendPtr
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_macros.h b/AT91SAM7S256/armdebug/Debugger/debug_macros.h
index 652c62b..2c6c6e7 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_macros.h
+++ b/AT91SAM7S256/armdebug/Debugger/debug_macros.h
@@ -112,7 +112,7 @@
* On exit:
* deststrptr: Pointer to next character slot in destination string
* sourcestrptr: Pointer to next character slot in source string
- * R0: destroyed
+ * sizereg, scratchreg: destroyed
*/
.macro _dbg_memcpy deststrptr, sourcestrptr, sizereg, scratchreg
1: ldrb \scratchreg, [\sourcestrptr], #1
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_stub.S b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
index 5d4cfff..d187cb6 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_stub.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
@@ -377,12 +377,42 @@ debug_armComplexCCTable:
/* FIXME: The Debugger Stack Frame is probably not 100% consistent with the order that
GDB expects in the g/G messages. CSPR is probably located above R15 */
+#ifndef __NXOS__
/****************************************************************************
*
- * GDB Debugger Init and Breakpoint Handler Routines
+ * GDB Debugger Invocation Routine for NXT Firmware
*
****************************************************************************/
+ .code 16
+ .align 2
+ .global cCommHandleDebug
+ .thumb_func
+/* cCommHandleDebug
+ * Switch Mode to Debugger.
+ * Used by NXT Firmware only
+ *
+ * UWORD cCommHandleDebug(UBYTE *pInBuf, UBYTE CmdBit, UWORD MsgLength);
+ *
+ * On Entry, we're in SVC mode. We need to setup the USB Buffers, and switch mode to
+ * ABORT mode to handle the incoming message using a Manual Breakpoint instruction.
+ * When DEBUG is exited, the execution resumes from the instruction following the Breakpoint.
+ */
+cCommHandleDebug:
+ push {r0-r3} /* store all argX registers */
+ bl dbg__copyNxtDebugMsg /* setup Debugger Message Buffers, validate input */
+ pop {r0-r3} /* restore all values */
+ dbg__bkpt_thumb
+ mov r0, #0 /* FIXME: Return Status */
+ bx lr
+#endif
+/****************************************************************************
+ *
+ * GDB Debugger Init and Breakpoint Handler Routines
+ *
+ ****************************************************************************/
+ .code 32
+ .align 4
.global dbg__bkpt_init
/* dbg__bkpt_init
* GDB set_debug_traps() routine
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_stub.h b/AT91SAM7S256/armdebug/Debugger/debug_stub.h
index 41044b2..1c47050 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_stub.h
+++ b/AT91SAM7S256/armdebug/Debugger/debug_stub.h
@@ -222,6 +222,13 @@ ENUM_END(dbg_msg_errno)
*/
FUNCDEF void dbg__bkpt_init(void);
+#ifndef __NXOS__
+/** Switch Mode to Debugger.
+ * Used by NXT Firmware only
+ */
+FUNCDEF UWORD cCommHandleDebug(UBYTE *pInBuf, UBYTE CmdBit, UWORD MsgLength);
+#endif
+
/** Debugger Handler Routine (called by Exception Handler Trap).
* Equivalent to GDB handle_exception() routine
*/