summaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug
diff options
context:
space:
mode:
authorTat-Chee Wan (USM)2011-03-18 12:52:40 +0800
committerTat-Chee Wan (USM)2011-03-18 12:52:40 +0800
commit52de8367e37b30bb64b86967354acf7d303e5725 (patch)
tree951e890f77bdb77a5555b04e1fae34baf8df6330 /AT91SAM7S256/armdebug
parent8945b4e00b5122619e3f5b65ae8294d7a50350d8 (diff)
parent51cf36077885f26e325739a60d45f822287a551f (diff)
Merge branch 'master' of ssh://svc.cs.usm.my/~/gitrepo-bare/armdebug
Diffstat (limited to 'AT91SAM7S256/armdebug')
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_comm.S4
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_stub.S9
-rw-r--r--AT91SAM7S256/armdebug/Debugger/debug_stub.h9
-rw-r--r--AT91SAM7S256/armdebug/Debugger/undef_handler.S7
4 files changed, 20 insertions, 9 deletions
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_comm.S b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
index 6a7aa11..efe44a9 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_comm.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_comm.S
@@ -408,7 +408,8 @@ _dbg__usb_readbuf_reset:
* R1: USB Command Bit
* R2: USB Raw Message Length
* On Exit:
- * R0-R3: Destroyed
+ * R0: CPSR
+ * R1-R3: Destroyed
*/
dbg__copyNxtDebugMsg:
@@ -416,6 +417,7 @@ dbg__copyNxtDebugMsg:
str r2, [r1]
ldr r1, =debug_InUSBBuf
_dbg_memcpy r1, r0, r2, r3 /* r3: scratch register */
+ mrs r0, cpsr
bx lr
#endif
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_stub.S b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
index 29e7814..5633db5 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_stub.S
+++ b/AT91SAM7S256/armdebug/Debugger/debug_stub.S
@@ -400,9 +400,16 @@ debug_armComplexCCTable:
*/
cCommHandleDebug:
push {r0-r3} /* store all argX registers */
- bl dbg__copyNxtDebugMsg /* setup Debugger Message Buffers, validate input */
+ bl dbg__copyNxtDebugMsg /* setup Debugger Message Buffers, validate input, CPSR returned in R0 */
+ and r0, r0, #CPSR_MODE /* Check Current Mode */
+ cmp r0, #MODE_ABT /* Debug Mode Check (Flags set) */
pop {r0-r3} /* restore all values */
+
+ /* If we're in ABT (Abort) mode, this means that we're already running the Debugger */
+ beq _in_debug
+ /* Else, we're in normal operation mode (SVC), or other mode (??!) and need to force a switch to Debug mode */
dbg__bkpt_thumb
+_in_debug:
mov r0, #0 /* FIXME: Return Status */
bx lr
#endif
diff --git a/AT91SAM7S256/armdebug/Debugger/debug_stub.h b/AT91SAM7S256/armdebug/Debugger/debug_stub.h
index d70152b..63e3c26 100644
--- a/AT91SAM7S256/armdebug/Debugger/debug_stub.h
+++ b/AT91SAM7S256/armdebug/Debugger/debug_stub.h
@@ -155,6 +155,15 @@
#define CPSR_IRQ 0x00000080
#define CPSR_MODE 0x0000001F
+/* ARM Exception Modes */
+#define MODE_USR 0x10 /* User mode */
+#define MODE_FIQ 0x11 /* FIQ mode */
+#define MODE_IRQ 0x12 /* IRQ mode */
+#define MODE_SVC 0x13 /* Supervisor mode */
+#define MODE_ABT 0x17 /* Abort mode */
+#define MODE_UND 0x1B /* Undefined mode */
+#define MODE_SYS 0x1F /* System mode */
+
/*@}*/
/** @name BKPT suppport constants
diff --git a/AT91SAM7S256/armdebug/Debugger/undef_handler.S b/AT91SAM7S256/armdebug/Debugger/undef_handler.S
index 6923d4d..f040219 100644
--- a/AT91SAM7S256/armdebug/Debugger/undef_handler.S
+++ b/AT91SAM7S256/armdebug/Debugger/undef_handler.S
@@ -11,13 +11,6 @@
#define __ASSEMBLY__
#include "debug_stub.h"
-#define MODE_USR 0x10 /* User mode */
-#define MODE_FIQ 0x11 /* FIQ mode */
-#define MODE_IRQ 0x12 /* IRQ mode */
-#define MODE_SVC 0x13 /* Supervisor mode */
-#define MODE_ABT 0x17 /* Abort mode */
-#define MODE_UND 0x1B /* Undefined mode */
-#define MODE_SYS 0x1F /* System mode */
.text
.code 32