mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 16:52:14 +02:00
console: remove #ifdef CONFIG_CONSOLE_RECORD
Add helper functions to access to gd->console_out and gd->console_in with membuff API and replace the #ifdef CONFIG_CONSOLE_RECORD test by if (IS_ENABLED(CONFIG_CONSOLE_RECORD)) to respect the U-Boot coding rule. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Tom Rini
parent
45375adc97
commit
1e993710e8
@@ -88,6 +88,64 @@ static int on_silent(const char *name, const char *value, enum env_op op,
|
|||||||
U_BOOT_ENV_CALLBACK(silent, on_silent);
|
U_BOOT_ENV_CALLBACK(silent, on_silent);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_CONSOLE_RECORD
|
||||||
|
/* helper function: access to gd->console_out and gd->console_in */
|
||||||
|
static void console_record_putc(const char c)
|
||||||
|
{
|
||||||
|
if (!(gd->flags & GD_FLG_RECORD))
|
||||||
|
return;
|
||||||
|
if (gd->console_out.start)
|
||||||
|
membuff_putbyte((struct membuff *)&gd->console_out, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void console_record_puts(const char *s)
|
||||||
|
{
|
||||||
|
if (!(gd->flags & GD_FLG_RECORD))
|
||||||
|
return;
|
||||||
|
if (gd->console_out.start)
|
||||||
|
membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int console_record_getc(void)
|
||||||
|
{
|
||||||
|
if (!(gd->flags & GD_FLG_RECORD))
|
||||||
|
return -1;
|
||||||
|
if (!gd->console_in.start)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return membuff_getbyte((struct membuff *)&gd->console_in);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int console_record_tstc(void)
|
||||||
|
{
|
||||||
|
if (!(gd->flags & GD_FLG_RECORD))
|
||||||
|
return 0;
|
||||||
|
if (gd->console_in.start) {
|
||||||
|
if (membuff_peekbyte((struct membuff *)&gd->console_in) != -1)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void console_record_putc(char c)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void console_record_puts(const char *s)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static int console_record_getc(void)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int console_record_tstc(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
|
#if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
|
||||||
/*
|
/*
|
||||||
* if overwrite_console returns 1, the stdin, stderr and stdout
|
* if overwrite_console returns 1, the stdin, stderr and stdout
|
||||||
@@ -414,21 +472,18 @@ int fprintf(int file, const char *fmt, ...)
|
|||||||
|
|
||||||
int getchar(void)
|
int getchar(void)
|
||||||
{
|
{
|
||||||
|
int ch;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE))
|
if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!gd->have_console)
|
if (!gd->have_console)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef CONFIG_CONSOLE_RECORD
|
ch = console_record_getc();
|
||||||
if (gd->console_in.start) {
|
if (ch != -1)
|
||||||
int ch;
|
return ch;
|
||||||
|
|
||||||
ch = membuff_getbyte((struct membuff *)&gd->console_in);
|
|
||||||
if (ch != -1)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (gd->flags & GD_FLG_DEVINIT) {
|
if (gd->flags & GD_FLG_DEVINIT) {
|
||||||
/* Get from the standard input */
|
/* Get from the standard input */
|
||||||
return fgetc(stdin);
|
return fgetc(stdin);
|
||||||
@@ -445,12 +500,10 @@ int tstc(void)
|
|||||||
|
|
||||||
if (!gd->have_console)
|
if (!gd->have_console)
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef CONFIG_CONSOLE_RECORD
|
|
||||||
if (gd->console_in.start) {
|
if (console_record_tstc())
|
||||||
if (membuff_peekbyte((struct membuff *)&gd->console_in) != -1)
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (gd->flags & GD_FLG_DEVINIT) {
|
if (gd->flags & GD_FLG_DEVINIT) {
|
||||||
/* Test the standard input */
|
/* Test the standard input */
|
||||||
return ftstc(stdin);
|
return ftstc(stdin);
|
||||||
@@ -521,10 +574,9 @@ void putc(const char c)
|
|||||||
{
|
{
|
||||||
if (!gd)
|
if (!gd)
|
||||||
return;
|
return;
|
||||||
#ifdef CONFIG_CONSOLE_RECORD
|
|
||||||
if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
|
console_record_putc(c);
|
||||||
membuff_putbyte((struct membuff *)&gd->console_out, c);
|
|
||||||
#endif
|
|
||||||
/* sandbox can send characters to stdout before it has a console */
|
/* sandbox can send characters to stdout before it has a console */
|
||||||
if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) {
|
if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) {
|
||||||
os_putc(c);
|
os_putc(c);
|
||||||
@@ -563,10 +615,9 @@ void puts(const char *s)
|
|||||||
{
|
{
|
||||||
if (!gd)
|
if (!gd)
|
||||||
return;
|
return;
|
||||||
#ifdef CONFIG_CONSOLE_RECORD
|
|
||||||
if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
|
console_record_puts(s);
|
||||||
membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
|
|
||||||
#endif
|
|
||||||
/* sandbox can send characters to stdout before it has a console */
|
/* sandbox can send characters to stdout before it has a console */
|
||||||
if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) {
|
if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) {
|
||||||
os_puts(s);
|
os_puts(s);
|
||||||
|
Reference in New Issue
Block a user