From 5bb5aa82d31d1125edce22ec0a80ce0240c9a111 Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Tue, 30 Apr 2019 14:12:25 +0800 Subject: [PATCH] common: console: optimize console record MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix: passing argument 1 of ‘membuff_new’ discards ‘volatile’ qualifier from pointer target type; - add console_record_print_purge(); - set default CONSOLE_RECORD_OUT_SIZE value for rockchip; Change-Id: Id247d590b677cd2cff95bc5e66963b0ff07b0658 Signed-off-by: Joseph Chen --- common/Kconfig | 3 ++- common/console.c | 38 +++++++++++++++++++++++++++++++------- include/console.h | 5 +++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/common/Kconfig b/common/Kconfig index f7a7dd952f..d6efe6590a 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -233,7 +233,8 @@ config CONSOLE_RECORD config CONSOLE_RECORD_OUT_SIZE hex "Output buffer size" depends on CONSOLE_RECORD - default 0x400 if CONSOLE_RECORD + default 0x400 if CONSOLE_RECORD && !ARCH_ROCKCHIP + default 0x2000 if CONSOLE_RECORD && ARCH_ROCKCHIP help Set the size of the console output buffer. When this fills up, no more data will be recorded until some is removed. The buffer is diff --git a/common/console.c b/common/console.c index a6fd9c4322..169c47c039 100644 --- a/common/console.c +++ b/common/console.c @@ -420,7 +420,7 @@ int getc(void) if (gd->console_in.start) { int ch; - ch = membuff_getbyte(&gd->console_in); + ch = membuff_getbyte((struct membuff *)&gd->console_in); if (ch != -1) return 1; } @@ -445,7 +445,7 @@ int tstc(void) return 0; #ifdef CONFIG_CONSOLE_RECORD if (gd->console_in.start) { - if (membuff_peekbyte(&gd->console_in) != -1) + if (membuff_peekbyte((struct membuff *)&gd->console_in) != -1) return 1; } #endif @@ -529,7 +529,7 @@ void putc(const char c) #endif #ifdef CONFIG_CONSOLE_RECORD if (gd && (gd->flags & GD_FLG_RECORD) && gd->console_out.start) - membuff_putbyte(&gd->console_out, c); + membuff_putbyte((struct membuff *)&gd->console_out, c); #endif #ifdef CONFIG_SILENT_CONSOLE if (gd->flags & GD_FLG_SILENT) @@ -605,18 +605,20 @@ int console_record_init(void) { int ret; - ret = membuff_new(&gd->console_out, CONFIG_CONSOLE_RECORD_OUT_SIZE); + ret = membuff_new((struct membuff *)&gd->console_out, + CONFIG_CONSOLE_RECORD_OUT_SIZE); if (ret) return ret; - ret = membuff_new(&gd->console_in, CONFIG_CONSOLE_RECORD_IN_SIZE); + ret = membuff_new((struct membuff *)&gd->console_in, + CONFIG_CONSOLE_RECORD_IN_SIZE); return ret; } void console_record_reset(void) { - membuff_purge(&gd->console_out); - membuff_purge(&gd->console_in); + membuff_purge((struct membuff *)&gd->console_out); + membuff_purge((struct membuff *)&gd->console_in); } void console_record_reset_enable(void) @@ -624,6 +626,28 @@ void console_record_reset_enable(void) console_record_reset(); gd->flags |= GD_FLG_RECORD; } + +/* Print and remove data from buffer */ +void console_record_print_purge(void) +{ + unsigned long flags; + char c; + + if (!gd || !(gd->flags & GD_FLG_RECORD)) + return; + + /* Remove some bits to avoid running unexpected branch in putc() */ + flags = gd->flags; + gd->flags &= ~(GD_FLG_RECORD | GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE); + + printf("\n\n## Console Record: \n"); + while (!membuff_isempty((struct membuff *)&gd->console_out)) { + c = membuff_getbyte((struct membuff *)&gd->console_out); + putc(c); + } + + gd->flags = flags; +} #endif /* test if ctrl-c was pressed */ diff --git a/include/console.h b/include/console.h index cea29ed6dc..61cba6bcfd 100644 --- a/include/console.h +++ b/include/console.h @@ -42,6 +42,11 @@ void console_record_reset(void); */ void console_record_reset_enable(void); +/** + * console_record_print_purge() - print record data and remove data from buffers + */ +void console_record_print_purge(void); + /** * console_announce_r() - print a U-Boot console on non-serial consoles *