From a4468ea24983606b643d6ca918d4b2ccc6d697be Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Sun, 29 Oct 2017 02:39:29 +0100 Subject: [PATCH] serial ice working after rework Change-Id: I05e70ba1dfe5223040417742a18621d18b7431e8 --- src/console/serialice.c | 52 +++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/console/serialice.c b/src/console/serialice.c index f4c4763975..2408a7f743 100644 --- a/src/console/serialice.c +++ b/src/console/serialice.c @@ -24,6 +24,7 @@ #define VERSION "1.6" /* Uart wrapper functions */ +static void sio_putstring(const char *string); static void sio_flush(void) { @@ -35,12 +36,16 @@ static void sio_putc(u8 byte) debug_tx_byte(byte); } +static void sio_put8(u8 data); + static u8 sio_getc(void) { u8 val = 0; val = debug_rx_byte(); if (val) { + sio_putstring("\n c: "); + sio_put8(val); return val; } @@ -171,7 +176,7 @@ static void serialice_read_memory(char *buffer, int len) u32 *addr; if (len < 13) { - sio_putstring("Wrong size\n"); + sio_putstring("read memory short len\n"); } // Format: @@ -378,12 +383,12 @@ static int sio_get_line(char *buffer, int len) { int i; - for (i=0; i "); - len = sio_get_line(line, sizeof(line)); + len = sio_get_line(line, 32); + sio_putstring("\ngot len "); + sio_put32(len); + sio_putstring("'"); + sio_putstring(line); + sio_putstring("'"); + sio_putstring("\n"); /* only new line read */ if (len == 0) continue; @@ -439,18 +450,19 @@ void serialice_main(void) case (('v' << 8)|'i'): // Read version info *vi serialice_version(line, len); break; - case ('?'): - sio_putstring("" - "rm - read memory\n" - "wm - write memory\n" - "ri - read io\n" - "wi - write io\n" - "ci - cpu info\n" - "mb - read mainboard\n" - "vi - show version\n"); - break; - default: - sio_putstring("ERROR\n"); + default: + if (line[1] == '?') { + sio_putstring("" + "rm - read memory\n" + "wm - write memory\n" + "ri - read io\n" + "wi - write io\n" + "ci - cpu info\n" + "mb - read mainboard\n" + "vi - show version\n"); + } else { + sio_putstring("ERROR. Unknown command\n"); + } break; } }