aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/Debugger/debug_comm.S
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-02-21 10:09:43 +0800
committerTat-Chee Wan (USM)2011-02-21 10:09:43 +0800
commitddaee1d4dadc5a2bdb0816d9e92862586d2c4b58 (patch)
tree2f6b9873c60de8d9f24b3c273342986c399ab0fd /AT91SAM7S256/armdebug/Debugger/debug_comm.S
parent10b6875c8eec7b2049b5c04ca54ee751e3bb0761 (diff)
parentc13f4e61d5ea38896337bde578da8b4939503be7 (diff)
Merge branch 'master' of ssh://svc.cs.usm.my/~/gitrepo-bare/armdebug
Diffstat (limited to 'AT91SAM7S256/armdebug/Debugger/debug_comm.S')
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_comm.S101
1 files changed, 57 insertions, 44 deletions
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_comm.S b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
index 5429c66..bfa3d25 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_comm.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
@@ -378,15 +378,15 @@ _exit_conv_ascii2byte:
*/
dbg__comm_init:
-#ifdef __NXOS__
stmfd sp!, {lr}
ldr r2, =debug_msgRxBufPtr
stmia r2!, {r0, r1} /* debug_msgRxBufPtr and debug_msgTxBufPtr */
stmia r2!, {r0, r1} /* debug_msgRxBuf_AppendPtr and debug_msgTxBuf_AppendPtr */
- bl _dbg__usbbuf_reset
+ bl _dbg__usb_readbuf_reset
ldmfd sp!, {pc}
-_dbg__usbbuf_reset:
+_dbg__usb_readbuf_reset:
+#ifdef __NXOS__
stmfd sp!, {lr}
ldr r0, =debug_InUSBBuf
mov r1, #USB_BUFSIZE
@@ -395,11 +395,6 @@ _dbg__usbbuf_reset:
bx r2
ldmfd sp!, {pc}
#else
- /* FIXME: NXT Firmware support */
- bl _dbg__usbbuf_reset
- bx lr
-
-_dbg__usbbuf_reset:
ldr r1, =debug_nxtMsgLength
mov r0, #0
str r0, [r1] /* Clear NXT USB Received Message Length */
@@ -443,12 +438,17 @@ _dbg_reset_msgTxBuf_AppendPtr:
* r1: message segment number
*/
_dbg__usbHasMsg:
-#ifdef __NXOS__
stmfd sp!, {lr}
+#ifdef __NXOS__
ldr r2, =nx_usb_data_read
mov lr,pc
bx r2 /* Number of bytes read in R0 */
/* Note: The return value in R0 is the USB Buffer Size, includes NXT Direct Command Header */
+#else
+ ldr r0, =debug_nxtMsgLength
+ ldr r0, [r0] /* R0 contains the USB Buffer Size, including the NXT Direct Command Header */
+#endif
+
ldr r2, =debug_InUSBBuf
ldrb r1, [r2, #USB_NXT_TELEGRAMTYPE_OFFSET]
cmp r1, #USB_NXT_TELEGRAMTYPE
@@ -467,10 +467,6 @@ invalid_USBMsg:
mov r0, #0
_exit_dbg__usbHasMsg:
ldmfd sp!, {pc}
-#else
- /* FIXME: NXT Firmware support */
- bx lr
-#endif
/* _copy_msg_from_usbbuf
* Internal USB buffer copy routine, handles segment reassembly.
@@ -547,7 +543,6 @@ _msgbuf_checksum:
* Note: If GDB Message were returned, it is ASCIIZ terminated, does not include '#' and checksum
*/
dbg__getDebugMsg:
-#ifdef __NXOS__
stmfd sp!, {r4,lr}
bl _dbg__usbHasMsg /* r0: message length, r1: segment number */
teq r0, #0
@@ -610,11 +605,51 @@ exit_dbg__getMsgError:
mov r0, #MSGBUF_MSGERROR
exit_dbg__getDebugMsg:
ldmfd sp!, {r4,pc}
+
+/* _dbg__sendUSBMsg
+ * Internal USB send routine (interfaces with drivers).
+ * On entry:
+ * R0: Total USB Message Buffer length
+ * On exit:
+ R0: Tx Status (TRUE if data sent)
+ */
+_dbg__sendUSBMsg:
+ stmfd sp!, {r4, lr}
+ mov r4, r0 /* Keep USB Buffer length in R4 */
+#ifdef __NXOS__
+ /* Check USB bus status, transmit message if possible */
+ bl nx_usb_is_connected /* R0 = True if USB is ready */
+ cmp r0, #TRUE
+ bne _exit_dbg__sendUSBMsg
+
+ /* Actual transmission (blocking) */
+ ldr r0, =debug_OutUSBBuf /* data pointer parameter */
+ mov r1, r4 /* USB buffer length */
+ bl nx_usb_write
+
+1: bl nx_usb_data_written /* R0 = True if data has been sent */
+ cmp r0, #TRUE
+ /* FIXME: implement timeout */
+ bne 1b /* Busy Wait Loop */
#else
- /* FIXME: NXT Firmware support */
- bx lr
+ /* Check USB bus status, transmit message if possible */
+ bl dUsbIsConfigured /* R0: UByte status, TRUE / FALSE */
+ teq r0, #nxt_UBYTE_TRUE
+ movne r0, #FALSE
+ bne _exit_dbg__sendUSBMsg
+
+ /* Actual transmission (blocking) */
+ ldr r0, =debug_OutUSBBuf /* data pointer parameter */
+ mov r1, r4 /* USB buffer length */
+ bl dUsbWrite /* call NXT Firmware USB driver, return 0: done, !0: remaining chars */
+ teq r0, #0 /* Tx done if returned length is 0 */
+ movne r0, #FALSE
+ moveq r0, #TRUE /* Convert NXT firmware return value to our Status (TRUE/FALSE) */
#endif
+_exit_dbg__sendUSBMsg:
+ ldmfd sp!, {r4, pc}
+
/* _copy_msg_to_usbbuf
* Internal USB buffer copy routine, handles segment fragmentation.
@@ -627,7 +662,6 @@ exit_dbg__getDebugMsg:
* r2, r3: Destroyed
*/
_copy_msg_to_usbbuf:
-#ifdef __NXOS__
stmfd sp!, {r1,r4,r5,r6,lr}
ldr r6, =debug_msgTxBufPtr /* Address of Pointers */
ldr r5, [r6, #TXAPPENDPTR_OFFSET] /* Retrieve Tx Append Pointer */
@@ -649,36 +683,20 @@ _copy_msg_to_usbbuf:
strb r0, [r3], #1 /* Message Length */
mov r2, r5 /* Copy to R2 for updating */
- _dbg_memcpy r3, r2, r4, r0 /* This copies over the message fragment, r3, r2 updated */
+ mov r1, r4 /* actual GDB message fragment length (exclude USB header) */
+ _dbg_memcpy r3, r2, r1, r0 /* This copies over the message fragment, r3, r2 updated */
mov r5, r2 /* Updated Tx Append Pointer, keep in R5 for now */
- /* Check USB bus status, transmit message if possible */
- bl nx_usb_is_connected /* R0 = True if USB is ready */
- cmp r0, #TRUE
- ldrne r5, [r6, #TXAPPENDPTR_OFFSET] /* Retrieve Original Tx Append Pointer */
- bne _exit_copy_msg_to_usbbuf
-
- /* Actual transmission (blocking) */
- ldr r0, =debug_OutUSBBuf /* data pointer parameter */
- add r1, r4, #USB_GDBMSG_START /* USB buffer length (offset = header size) */
- bl nx_usb_write
-
-1: bl nx_usb_data_written /* R0 = True if data has been sent */
+ add r0, r4, #USB_GDBMSG_START /* Total USB Buffer Size for Tx (USB_GDBMSG_START offset = header size) */
+ bl _dbg__sendUSBMsg /* Common interface routine to USB drivers */
cmp r0, #TRUE
- /* FIXME: implement timeout */
- bne 1b /* Busy Wait Loop */
-
- /* successful transmission */
- str r5, [r6, #TXAPPENDPTR_OFFSET] /* Update Tx Append Pointer to new position */
+ ldrne r5, [r6, #TXAPPENDPTR_OFFSET] /* Tx failed, Retrieve Original Tx Append Pointer */
+ streq r5, [r6, #TXAPPENDPTR_OFFSET] /* Tx succeeded, Update Tx Append Pointer to new position */
_exit_copy_msg_to_usbbuf:
ldr r6, [r6] /* Retrieve Tx Buffer Start Address */
sub r0, r5, r6 /* Return calculated cummulative message length (R0) */
ldmfd sp!, {r1,r4,r5,r6,pc} /* Return segment number in R1 */
-#else
- /* FIXME: NXT Firmware support */
- bx lr
-#endif
.global dbg__putDebugMsg
/* dbg__putDebugMsg
@@ -691,7 +709,6 @@ _exit_copy_msg_to_usbbuf:
* Response packets start with '+'/'-' followed by '$' (2 bytes prefix)
*/
dbg__putDebugMsg:
-#ifdef __NXOS__
stmfd sp!, {r4,r5,lr}
/* Perform Checksum Calculation */
ldr r5, =debug_msgTxBufPtr /* R5: data structure base pointer */
@@ -739,9 +756,5 @@ exit_dbg__putMsgError:
mov r0, #MSGBUF_MSGERROR
exit_dbg__putDebugMsg:
ldmfd sp!, {r4,r5,pc}
-#else
- /* FIXME: NXT Firmware support */
- bx lr
-#endif