common: console: optimize console record
- 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 <chenjh@rock-chips.com>
This commit is contained in:
parent
a69fab4a34
commit
5bb5aa82d3
|
|
@ -233,7 +233,8 @@ config CONSOLE_RECORD
|
||||||
config CONSOLE_RECORD_OUT_SIZE
|
config CONSOLE_RECORD_OUT_SIZE
|
||||||
hex "Output buffer size"
|
hex "Output buffer size"
|
||||||
depends on CONSOLE_RECORD
|
depends on CONSOLE_RECORD
|
||||||
default 0x400 if CONSOLE_RECORD
|
default 0x400 if CONSOLE_RECORD && !ARCH_ROCKCHIP
|
||||||
|
default 0x2000 if CONSOLE_RECORD && ARCH_ROCKCHIP
|
||||||
help
|
help
|
||||||
Set the size of the console output buffer. When this fills up, no
|
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
|
more data will be recorded until some is removed. The buffer is
|
||||||
|
|
|
||||||
|
|
@ -420,7 +420,7 @@ int getc(void)
|
||||||
if (gd->console_in.start) {
|
if (gd->console_in.start) {
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
ch = membuff_getbyte(&gd->console_in);
|
ch = membuff_getbyte((struct membuff *)&gd->console_in);
|
||||||
if (ch != -1)
|
if (ch != -1)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -445,7 +445,7 @@ int tstc(void)
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef CONFIG_CONSOLE_RECORD
|
#ifdef CONFIG_CONSOLE_RECORD
|
||||||
if (gd->console_in.start) {
|
if (gd->console_in.start) {
|
||||||
if (membuff_peekbyte(&gd->console_in) != -1)
|
if (membuff_peekbyte((struct membuff *)&gd->console_in) != -1)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -529,7 +529,7 @@ void putc(const char c)
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_CONSOLE_RECORD
|
#ifdef CONFIG_CONSOLE_RECORD
|
||||||
if (gd && (gd->flags & GD_FLG_RECORD) && gd->console_out.start)
|
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
|
#endif
|
||||||
#ifdef CONFIG_SILENT_CONSOLE
|
#ifdef CONFIG_SILENT_CONSOLE
|
||||||
if (gd->flags & GD_FLG_SILENT)
|
if (gd->flags & GD_FLG_SILENT)
|
||||||
|
|
@ -605,18 +605,20 @@ int console_record_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
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)
|
if (ret)
|
||||||
return 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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_record_reset(void)
|
void console_record_reset(void)
|
||||||
{
|
{
|
||||||
membuff_purge(&gd->console_out);
|
membuff_purge((struct membuff *)&gd->console_out);
|
||||||
membuff_purge(&gd->console_in);
|
membuff_purge((struct membuff *)&gd->console_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_record_reset_enable(void)
|
void console_record_reset_enable(void)
|
||||||
|
|
@ -624,6 +626,28 @@ void console_record_reset_enable(void)
|
||||||
console_record_reset();
|
console_record_reset();
|
||||||
gd->flags |= GD_FLG_RECORD;
|
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
|
#endif
|
||||||
|
|
||||||
/* test if ctrl-c was pressed */
|
/* test if ctrl-c was pressed */
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,11 @@ void console_record_reset(void);
|
||||||
*/
|
*/
|
||||||
void console_record_reset_enable(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
|
* console_announce_r() - print a U-Boot console on non-serial consoles
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue