summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-10-24 06:36:06 -0700
committerZachary T Welch <zw@superlucidity.net>2009-11-05 18:03:19 -0800
commit3541ed3aa3beb93c80bb2a01be429dacdec33919 (patch)
tree6159617bd292bef918a6b1a4131f31ab94827fa1 /src
parent3dd5c59d7d4d4dc13ebd3fc870bd4bc695c9fda8 (diff)
downloadopenocd_libswd-3541ed3aa3beb93c80bb2a01be429dacdec33919.tar.gz
openocd_libswd-3541ed3aa3beb93c80bb2a01be429dacdec33919.tar.bz2
openocd_libswd-3541ed3aa3beb93c80bb2a01be429dacdec33919.tar.xz
openocd_libswd-3541ed3aa3beb93c80bb2a01be429dacdec33919.zip
Improve armv7m command argument parsing.
Diffstat (limited to 'src')
-rw-r--r--src/target/armv7m.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/target/armv7m.c b/src/target/armv7m.c
index 64bdfd52..49e50f4d 100644
--- a/src/target/armv7m.c
+++ b/src/target/armv7m.c
@@ -756,25 +756,27 @@ static int handle_dap_baseaddr_command(struct command_context_s *cmd_ctx,
uint32_t apsel, apselsave, baseaddr;
int retval;
- apsel = swjdp->apsel;
apselsave = swjdp->apsel;
- if (argc > 0)
- {
- apsel = strtoul(args[0], NULL, 0);
+ switch (argc) {
+ case 0:
+ apsel = swjdp->apsel;
+ break;
+ case 1:
+ COMMAND_PARSE_NUMBER(u32, args[0], apsel);
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
+
if (apselsave != apsel)
- {
dap_ap_select(swjdp, apsel);
- }
dap_ap_read_reg_u32(swjdp, 0xF8, &baseaddr);
retval = swjdp_transaction_endcheck(swjdp);
command_print(cmd_ctx, "0x%8.8" PRIx32 "", baseaddr);
if (apselsave != apsel)
- {
dap_ap_select(swjdp, apselsave);
- }
return retval;
}
@@ -822,9 +824,16 @@ static int handle_dap_info_command(struct command_context_s *cmd_ctx,
swjdp_common_t *swjdp = &armv7m->swjdp_info;
uint32_t apsel;
- apsel = swjdp->apsel;
- if (argc > 0)
- apsel = strtoul(args[0], NULL, 0);
+ switch (argc) {
+ case 0:
+ apsel = swjdp->apsel;
+ break;
+ case 1:
+ COMMAND_PARSE_NUMBER(u32, args[0], apsel);
+ break;
+ default:
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ }
return dap_info_command(cmd_ctx, swjdp, apsel);
}