FreeCalypso > hg > freecalypso-sw
changeset 189:a95d253ef952
fc-tmsh: some basic tmcore commands implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 25 Nov 2013 03:10:41 +0000 |
parents | 9f4f331ac24d |
children | 405f5b46cdc4 |
files | rvinterf/etm/etmbasic.c rvinterf/etm/tmcore.c rvinterf/etm/usercmd.c |
diffstat | 3 files changed, 192 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etm/etmbasic.c Mon Nov 25 02:11:47 2013 +0000 +++ b/rvinterf/etm/etmbasic.c Mon Nov 25 03:10:41 2013 +0000 @@ -76,3 +76,17 @@ pkt[di++] = c; send_pkt_to_target(pkt, di); } + +void +send_etm_cmd(buf, len) + u_char *buf; +{ + int i, c; + + buf[0] = RVT_TM_HEADER; + c = 0; + for (i = 1; i <= len; i++) + c ^= buf[i]; + buf[i] = c; + send_pkt_to_target(buf, len + 2); +}
--- a/rvinterf/etm/tmcore.c Mon Nov 25 02:11:47 2013 +0000 +++ b/rvinterf/etm/tmcore.c Mon Nov 25 03:10:41 2013 +0000 @@ -10,6 +10,7 @@ #include <stdlib.h> #include "../pktmux.h" #include "../limits.h" +#include "localtypes.h" #include "etm.h" extern u_char rvi_msg[]; @@ -178,3 +179,166 @@ print_etm_pkt_raw("ETM_CORE resp"); } } + +void +cmd_r8(argc, argv) + char **argv; +{ + u32 addr; + int count; + u_char cmdpkt[10]; + + addr = strtoul(argv[1], 0, 16); + if (argv[2]) + count = strtoul(argv[2], 0, 0); + else + count = 1; + if (count < 1 || count > 253) { + printf("error: count argument outside valid range\n"); + return; + } + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_MEM; + cmdpkt[3] = 0x01; + cmdpkt[4] = count; + cmdpkt[5] = addr; + cmdpkt[6] = addr >> 8; + cmdpkt[7] = addr >> 16; + cmdpkt[8] = addr >> 24; + send_etm_cmd(cmdpkt, 8); +} + +void +cmd_r16(argc, argv) + char **argv; +{ + u32 addr; + int count; + u_char cmdpkt[10]; + + addr = strtoul(argv[1], 0, 16); + if (argv[2]) + count = strtoul(argv[2], 0, 0); + else + count = 1; + if (addr & 1) { + printf("error: address not aligned\n"); + return; + } + if (count < 1 || count > 126) { + printf("error: count argument outside valid range\n"); + return; + } + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_MEM; + cmdpkt[3] = 0x02; + cmdpkt[4] = count; + cmdpkt[5] = addr; + cmdpkt[6] = addr >> 8; + cmdpkt[7] = addr >> 16; + cmdpkt[8] = addr >> 24; + send_etm_cmd(cmdpkt, 8); +} + +void +cmd_r32(argc, argv) + char **argv; +{ + u32 addr; + int count; + u_char cmdpkt[10]; + + addr = strtoul(argv[1], 0, 16); + if (argv[2]) + count = strtoul(argv[2], 0, 0); + else + count = 1; + if (addr & 3) { + printf("error: address not aligned\n"); + return; + } + if (count < 1 || count > 63) { + printf("error: count argument outside valid range\n"); + return; + } + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_MEM; + cmdpkt[3] = 0x04; + cmdpkt[4] = count; + cmdpkt[5] = addr; + cmdpkt[6] = addr >> 8; + cmdpkt[7] = addr >> 16; + cmdpkt[8] = addr >> 24; + send_etm_cmd(cmdpkt, 8); +} + +void +cmd_dieid(argc, argv) + char **argv; +{ + u_char cmdpkt[4]; + + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_DIEID; + send_etm_cmd(cmdpkt, 2); +} + +void +cmd_ping(argc, argv) + char **argv; +{ + int delay, size; + u_char cmdpkt[8]; + + if (argc > 1) { + delay = strtoul(argv[1], 0, 0); + if (delay > 65535) { + printf("error: ping delay argument too big\n"); + return; + } + } else + delay = 0; + if (argc > 2) { + size = strtoul(argv[2], 0, 0); + if (size > 240) { + printf("error: ping size argument too big\n"); + return; + } + } else + size = 1; + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_ECHO; + cmdpkt[3] = delay; + cmdpkt[4] = delay >> 8; + cmdpkt[5] = size; + cmdpkt[6] = size >> 8; + send_etm_cmd(cmdpkt, 6); +} + +void +cmd_tgtreset(argc, argv) + char **argv; +{ + u_char cmdpkt[4]; + + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_RESET; + send_etm_cmd(cmdpkt, 2); +} + +void +cmd_version(argc, argv) + char **argv; +{ + u32 arg; + u_char cmdpkt[8]; + + arg = strtoul(argv[1], 0, 16); + cmdpkt[1] = ETM_CORE; + cmdpkt[2] = TMCORE_OPC_VERSION; + cmdpkt[3] = arg; + cmdpkt[4] = arg >> 8; + cmdpkt[5] = arg >> 16; + cmdpkt[6] = arg >> 24; + send_etm_cmd(cmdpkt, 6); +}
--- a/rvinterf/etm/usercmd.c Mon Nov 25 02:11:47 2013 +0000 +++ b/rvinterf/etm/usercmd.c Mon Nov 25 03:10:41 2013 +0000 @@ -11,7 +11,14 @@ extern char usercmd[]; +extern void cmd_dieid(); extern void cmd_etmpkt(); +extern void cmd_ping(); +extern void cmd_r8(); +extern void cmd_r16(); +extern void cmd_r32(); +extern void cmd_tgtreset(); +extern void cmd_version(); void cmd_exit() @@ -26,9 +33,16 @@ int maxargs; void (*func)(); } cmdtab[] = { + {"dieid", 0, 0, cmd_dieid}, {"etmpkt", 1, 253, cmd_etmpkt}, {"exit", 0, 0, cmd_exit}, + {"ping", 0, 2, cmd_ping}, {"quit", 0, 0, cmd_exit}, + {"r8", 1, 2, cmd_r8}, + {"r16", 1, 2, cmd_r16}, + {"r32", 1, 2, cmd_r32}, + {"tgtreset", 0, 0, cmd_tgtreset}, + {"version", 1, 1, cmd_version}, {0, 0, 0, 0} };