aboutsummaryrefslogtreecommitdiff
path: root/app/mdebug/rswd.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/mdebug/rswd.c')
-rw-r--r--app/mdebug/rswd.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/app/mdebug/rswd.c b/app/mdebug/rswd.c
index 336b6e5e..94c75cef 100644
--- a/app/mdebug/rswd.c
+++ b/app/mdebug/rswd.c
@@ -21,6 +21,8 @@
#include <stdlib.h>
#include <printf.h>
+#include <platform.h>
+
#include "swd.h"
#include "rswdp.h"
@@ -56,6 +58,10 @@ static u8 optable[16] = {
static const char *board_str = TARGET;
static const char *build_str = "fw v0.9 (" __DATE__ ", " __TIME__ ")";
+static void _reboot(void) {
+ platform_halt(HALT_ACTION_REBOOT, HALT_REASON_SW_RESET);
+}
+
/* TODO bounds checking -- we trust the host far too much */
void process_txn(u32 txnid, u32 *rx, int rxc, u32 *tx) {
unsigned msg, op, n;
@@ -80,8 +86,8 @@ void process_txn(u32 txnid, u32 *rx, int rxc, u32 *tx) {
case CMD_SWD_WRITE:
while (n-- > 0) {
rxc--;
- if (swd_write(optable[op], *rx++)) {
- status = 3;
+ status = swd_write(optable[op], *rx++);
+ if (status) {
goto done;
}
}
@@ -89,11 +95,11 @@ void process_txn(u32 txnid, u32 *rx, int rxc, u32 *tx) {
case CMD_SWD_READ:
tx[txc++] = RSWD_MSG(CMD_SWD_DATA, 0, n);
while (n-- > 0) {
- if (swd_read(optable[op], tx + txc)) {
+ status = swd_read(optable[op], tx + txc);
+ if (status) {
txc++;
while (n-- > 0)
tx[txc++] = 0xfefefefe;
- status = 3;
goto done;
}
txc++;
@@ -102,8 +108,8 @@ void process_txn(u32 txnid, u32 *rx, int rxc, u32 *tx) {
case CMD_SWD_DISCARD:
while (n-- > 0) {
u32 tmp;
- if (swd_read(optable[op], &tmp)) {
- status = 3;
+ status = swd_read(optable[op], &tmp);
+ if (status) {
goto done;
}
}
@@ -132,7 +138,7 @@ void process_txn(u32 txnid, u32 *rx, int rxc, u32 *tx) {
swdp_trace = op;
continue;
case CMD_BOOTLOADER:
- //func = reboot_bootloader;
+ func = _reboot;
continue;
case CMD_SET_CLOCK:
n = swd_set_clock(n);