aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/Debugger
diff options
context:
space:
mode:
Diffstat (limited to 'AT91SAM7S256/armdebug/Debugger')
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_comm.S11
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_stub.S48
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_stub.h19
3 files changed, 72 insertions, 6 deletions
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_comm.S b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
index b743f72..821d0c8 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_comm.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
@@ -46,7 +46,7 @@ debug_msgTxBuf_AppendPtr:
debug_segmentRxNum: /* Current Rx Segment Number */
.word 0x0
-#ifndef __NXOS__
+/* Incoming Message Length and Comm Channel is now common to both NxOS and NXT Firmware */
debug_nxtMsgLength: /* NXT Firmware Received Message Length */
.word 0x0
@@ -55,8 +55,6 @@ debug_nxtCommChannel:
.equ NXTCOMMCHANNEL_OFFSET, (debug_nxtCommChannel - debug_nxtMsgLength)
-#endif
-
.data
.align 4
@@ -574,11 +572,9 @@ dbg__comm_init:
stmia r2!, {r0, r1} /* debug_msgRxBufPtr and debug_msgTxBufPtr */
stmia r2!, {r0, r1} /* debug_msgRxBuf_AppendPtr and debug_msgTxBuf_AppendPtr */
bl _dbg__comm_readbuf_reset
-#ifndef __NXOS__
ldr r1, =debug_nxtMsgLength
mov r0, #0
str r0, [r1, #NXTCOMMCHANNEL_OFFSET] /* Clear NXT Channel on INIT */
-#endif
ldmfd sp!, {pc}
_dbg__comm_readbuf_reset:
@@ -589,12 +585,16 @@ _dbg__comm_readbuf_reset:
ldr r2, =nx_usb_read
mov lr, pc
bx r2
+ ldr r1, =debug_nxtMsgLength
+ mov r0, #0
+ str r0, [r1] /* Clear NxOS Received Message Length */
ldmfd sp!, {pc}
#else
ldr r1, =debug_nxtMsgLength
mov r0, #0
str r0, [r1] /* Clear NXT Received Message Length */
bx lr
+#endif
.global dbg__copyNxtDebugMsg
/* dbg__copyNxtDebugMsg
@@ -616,7 +616,6 @@ dbg__copyNxtDebugMsg:
*/
_dbg_memcpy r1, r0, r2, r3 /* r3: scratch register */
bx lr
-#endif
/* _dbg_reset_msgTxBuf_AppendPtr
* Internal variable to reset pointers.
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_stub.S b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
index a58fa8f..4e26da3 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_stub.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
@@ -469,6 +469,54 @@ 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 */
+#ifdef __NXOS__
+/****************************************************************************
+ *
+ * GDB Debugger Invocation Routine for NxOS
+ *
+ ****************************************************************************/
+ .code 32
+ .align 4
+ .global nxos__handleDebug
+/* nxos__handleDebug
+ * Prepare to switch to Debug Mode
+ * int nxos__handleDebug(unsigned char *msg, comm_chan_t channel, long len, void *isrRetAddr);
+ *
+ * This routine is called from NxOS Fantom library to setup
+ * Single Step Breakpoint and copy Incoming Message to
+ * Debugger Message Buffers in preparation for Debugger invocation.
+ *
+ * If we're operating in normal NxOS mode, return True (!0)
+ * If we're already in Debugger Mode, return False (0)
+ */
+nxos__handleDebug:
+ push {r4, lr}
+ /* When called, NxOS is in ISR servicing mode (MODE_IRQ) */
+ /* R0-R3 has received message related parameters */
+ mov r4, r3 /* Keep isrRetAddr in R4 */
+ mrs r3, spsr /* Copy SPSR to r3 */
+ and r3, r3, #CPSR_MODE /* Get previous mode */
+ teq r3, #MODE_ABT /* Are we in Abort (Debug) mode? */
+ moveq r0, #FALSE
+ beq exit_nxos__handleDebug /* Yes, return False */
+
+_nxos_switch2debug:
+ bl dbg__copyNxtDebugMsg /* setup Debugger Message Buffers, validate input, CPSR returned in R0 */
+
+ /* Retrieve ISR Return Address */
+ mrs r3, spsr /* Copy SPSR to r3 */
+ tst r3, #CPSR_THUMB /* Check for Thumb Mode */
+ sub r1, r4, #4 /* R3 (isrRetAddr) has PC + 4, need to setup Single Step Breakpoint at PC */
+ orrne r1, r1, #1 /* Configure for Thumb Single Step Breakpoint */
+ bl _dbg__install_singlestep /* Setup Single Step, next instruction address returned in r1 */
+ bl _dbg__activate_singlestep
+ mov r0, #TRUE /* We're going to switch to Debug Mode */
+exit_nxos__handleDebug:
+ pop {r4, lr}
+ mov r1, lr /* Safe code: Thumb mode can't access lr */
+ bx r1 /* In case we have Interworking from different caller mode */
+#endif
+
#ifndef __NXOS__
/****************************************************************************
*
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_stub.h b/AT91SAM7S256/armdebug/Debugger/debug_stub.h
index 931aa68..c5cbeee 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_stub.h
+++ b/AT91SAM7S256/armdebug/Debugger/debug_stub.h
@@ -55,6 +55,25 @@
*/
FUNCDEF void dbg__bkpt_init(void);
+#ifdef __NXOS__
+
+/** Communication Channel Enums
+ *
+ * Communication Channel Enums.
+ */
+ENUM_BEGIN
+ENUM_VALASSIGN(COMM_USB, 1) /**< USB Communications */
+ENUM_VAL(COMM_BT) /**< Bluetooth Communications */
+ENUM_END(comm_chan_t)
+
+/** Enable switch to Debugger Mode from NxOS operational mode
+ * Returns 0 if no mode switch needed (already in Debug mode)
+ * !0 if mode switch will happen
+ * Used by NxOS only
+ */
+FUNCDEF int nxos__handleDebug(unsigned char *msg, comm_chan_t channel, long len, void *isrRetAddr);
+#endif
+
#ifndef __NXOS__
/** Switch Mode to Debugger.
* Used by NXT Firmware only