changeset 811:4c7f3778dc24

fc-tmsh: add simple commands carried via ETM debug opcode
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 10 May 2021 00:59:15 +0000
parents c535e7438c25
children d1fce6d9bfa4
files rvinterf/tmsh/tmcore.c rvinterf/tmsh/usercmd.c
diffstat 2 files changed, 70 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rvinterf/tmsh/tmcore.c	Mon May 10 00:56:23 2021 +0000
+++ b/rvinterf/tmsh/tmcore.c	Mon May 10 00:59:15 2021 +0000
@@ -153,6 +153,29 @@
 	async_msg_output(buf);
 }
 
+static void
+etm_debug_response()
+{
+	char buf[80];
+
+	if (rvi_msg[3]) {
+		print_etm_pkt_raw("ETM debug command error");
+		return;
+	}
+	switch (rvi_msg_len) {
+	case 6:
+		async_msg_output("ETM debug command successful");
+		return;
+	case 10:
+		sprintf(buf, "ETM debug command response: %02X%02X%02X%02X",
+			rvi_msg[8], rvi_msg[7], rvi_msg[6], rvi_msg[5]);
+		async_msg_output(buf);
+		return;
+	default:
+		print_etm_pkt_raw("ETM debug response wrong length");
+	}
+}
+
 void
 tmcore_msg_rx()
 {
@@ -189,6 +212,9 @@
 	case TMCORE_OPC_DIEID:
 		dieid_response();
 		return;
+	case TMCORE_OPC_DEBUG:
+		etm_debug_response();
+		return;
 	default:
 	unknown:
 		print_etm_pkt_raw("ETM_CORE resp");
@@ -447,3 +473,41 @@
 	send_etm_cmd(cmdpkt, 6);
 	return(0);
 }
+
+cmd_rvf_dump(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = ETM_CORE;
+	cmdpkt[2] = TMCORE_OPC_DEBUG;
+	cmdpkt[3] = TMDBG_OPC_RVF_DUMP;
+	send_etm_cmd(cmdpkt, 3);
+	return(0);
+}
+
+/* the following commands are FreeCalypso additions */
+
+cmd_pwr_key(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = ETM_CORE;
+	cmdpkt[2] = TMCORE_OPC_DEBUG;
+	cmdpkt[3] = TMDBG_OPC_PWR_CYCLE;
+	send_etm_cmd(cmdpkt, 3);
+	return(0);
+}
+
+cmd_phone_on(argc, argv)
+	char **argv;
+{
+	u_char cmdpkt[5];
+
+	cmdpkt[1] = ETM_CORE;
+	cmdpkt[2] = TMCORE_OPC_DEBUG;
+	cmdpkt[3] = TMDBG_OPC_PHONE_ON;
+	send_etm_cmd(cmdpkt, 3);
+	return(0);
+}
--- a/rvinterf/tmsh/usercmd.c	Mon May 10 00:56:23 2021 +0000
+++ b/rvinterf/tmsh/usercmd.c	Mon May 10 00:59:15 2021 +0000
@@ -29,7 +29,9 @@
 extern int cmd_oabbw();
 extern int cmd_omr();
 extern int cmd_omw();
+extern int cmd_phone_on();
 extern int cmd_ping();
+extern int cmd_pwr_key();
 extern int cmd_r8();
 extern int cmd_r16();
 extern int cmd_r32();
@@ -38,6 +40,7 @@
 extern int cmd_rfpw();
 extern int cmd_rftr();
 extern int cmd_rftw();
+extern int cmd_rvf_dump();
 extern int cmd_rxpr();
 extern int cmd_rxpw();
 extern int cmd_save_rf_table();
@@ -91,7 +94,9 @@
 	{"oabbw", 3, 3, cmd_oabbw},
 	{"omr", 2, 2, cmd_omr},
 	{"omw", 2, 129, cmd_omw},
+	{"phone-on", 0, 0, cmd_phone_on},
 	{"ping", 0, 2, cmd_ping},
+	{"pwr-key", 0, 0, cmd_pwr_key},
 	{"quit", 0, 0, cmd_exit},
 	{"r8", 1, 2, cmd_r8},
 	{"r16", 1, 2, cmd_r16},
@@ -101,6 +106,7 @@
 	{"rfpw", 2, 3, cmd_rfpw},
 	{"rftr", 1, 1, cmd_rftr},
 	{"rftw", 2, 3, cmd_rftw},
+	{"rvf-dump", 0, 0, cmd_rvf_dump},
 	{"rxpr", 1, 1, cmd_rxpr},
 	{"rxpw", 2, 2, cmd_rxpw},
 	{"save-rf-table", 1, 1, cmd_save_rf_table},