FreeCalypso > hg > freecalypso-sw
changeset 192:707aa640b2dc
fc-tmsh: w8/w16/w32 implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 25 Nov 2013 05:37:46 +0000 |
parents | cf8583923dc4 |
children | f9ac53d8e999 |
files | rvinterf/etm/tmcore.c rvinterf/etm/usercmd.c |
diffstat | 2 files changed, 119 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etm/tmcore.c Mon Nov 25 04:41:36 2013 +0000 +++ b/rvinterf/etm/tmcore.c Mon Nov 25 05:37:46 2013 +0000 @@ -17,16 +17,20 @@ extern int rvi_msg_len; static void -r8_response() +rw8_response() { char buf[MAX_PKT_FROM_TARGET*3+80], *dp; int num, i; if (rvi_msg[3]) { - print_etm_pkt_raw("r8 error"); + print_etm_pkt_raw("rw8 error"); return; } num = rvi_msg_len - 7; + if (!num) { + async_msg_output("w8 OK"); + return; + } strcpy(buf, "r8:"); dp = buf + 3; for (i = 0; i < num; i++) { @@ -37,18 +41,22 @@ } static void -r16_response() +rw16_response() { char buf[MAX_PKT_FROM_TARGET*3+80], *dp; int num, i, d, off; if (rvi_msg[3]) { - print_etm_pkt_raw("r16 error"); + print_etm_pkt_raw("rw16 error"); return; } num = rvi_msg_len - 7; + if (!num) { + async_msg_output("w16 OK"); + return; + } if (num & 1) { - print_etm_pkt_raw("r16 malformed resp"); + print_etm_pkt_raw("rw16 malformed resp"); return; } num >>= 1; @@ -65,18 +73,22 @@ } static void -r32_response() +rw32_response() { char buf[MAX_PKT_FROM_TARGET*3+80], *dp; int num, i, d, off; if (rvi_msg[3]) { - print_etm_pkt_raw("r32 error"); + print_etm_pkt_raw("rw32 error"); return; } num = rvi_msg_len - 7; + if (!num) { + async_msg_output("w32 OK"); + return; + } if (num & 3) { - print_etm_pkt_raw("r32 malformed resp"); + print_etm_pkt_raw("rw32 malformed resp"); return; } num >>= 2; @@ -150,13 +162,13 @@ switch (rvi_msg[5]) { case 0x00: case 0x04: - r32_response(); + rw32_response(); return; case 0x01: - r8_response(); + rw8_response(); return; case 0x02: - r16_response(); + rw16_response(); return; default: goto unknown; @@ -273,6 +285,96 @@ } void +cmd_w8(argc, argv) + char **argv; +{ + u32 addr, v; + u_char cmdpkt[MAX_PKT_TO_TARGET]; + int di; + char **ap; + + addr = strtoul(argv[1], 0, 16); + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_MEM; + cmdpkt[3] = 0x11; + cmdpkt[4] = argc - 2; + cmdpkt[5] = addr; + cmdpkt[6] = addr >> 8; + cmdpkt[7] = addr >> 16; + cmdpkt[8] = addr >> 24; + di = 9; + for (ap = argv + 2; *ap; ap++) { + v = strtoul(*ap, 0, 16); + cmdpkt[di++] = v; + } + send_etm_cmd(cmdpkt, di - 1); +} + +void +cmd_w16(argc, argv) + char **argv; +{ + u32 addr, v; + u_char cmdpkt[MAX_PKT_TO_TARGET]; + int di; + char **ap; + + addr = strtoul(argv[1], 0, 16); + if (addr & 1) { + printf("error: address not aligned\n"); + return; + } + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_MEM; + cmdpkt[3] = 0x12; + cmdpkt[4] = argc - 2; + cmdpkt[5] = addr; + cmdpkt[6] = addr >> 8; + cmdpkt[7] = addr >> 16; + cmdpkt[8] = addr >> 24; + di = 9; + for (ap = argv + 2; *ap; ap++) { + v = strtoul(*ap, 0, 16); + cmdpkt[di++] = v; + cmdpkt[di++] = v >> 8; + } + send_etm_cmd(cmdpkt, di - 1); +} + +void +cmd_w32(argc, argv) + char **argv; +{ + u32 addr, v; + u_char cmdpkt[MAX_PKT_TO_TARGET]; + int di; + char **ap; + + addr = strtoul(argv[1], 0, 16); + if (addr & 3) { + printf("error: address not aligned\n"); + return; + } + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_MEM; + cmdpkt[3] = 0x14; + cmdpkt[4] = argc - 2; + cmdpkt[5] = addr; + cmdpkt[6] = addr >> 8; + cmdpkt[7] = addr >> 16; + cmdpkt[8] = addr >> 24; + di = 9; + for (ap = argv + 2; *ap; ap++) { + v = strtoul(*ap, 0, 16); + cmdpkt[di++] = v; + cmdpkt[di++] = v >> 8; + cmdpkt[di++] = v >> 16; + cmdpkt[di++] = v >> 24; + } + send_etm_cmd(cmdpkt, di - 1); +} + +void cmd_dieid(argc, argv) char **argv; {
--- a/rvinterf/etm/usercmd.c Mon Nov 25 04:41:36 2013 +0000 +++ b/rvinterf/etm/usercmd.c Mon Nov 25 05:37:46 2013 +0000 @@ -19,6 +19,9 @@ extern void cmd_r32(); extern void cmd_tgtreset(); extern void cmd_version(); +extern void cmd_w8(); +extern void cmd_w16(); +extern void cmd_w32(); void cmd_exit() @@ -43,6 +46,9 @@ {"r32", 1, 2, cmd_r32}, {"tgtreset", 0, 0, cmd_tgtreset}, {"version", 1, 1, cmd_version}, + {"w8", 2, 246, cmd_w8}, + {"w16", 2, 123, cmd_w16}, + {"w32", 2, 62, cmd_w32}, {0, 0, 0, 0} };