#include <exports.h>
#include <env_internal.h>
#include <watchdog.h>
+#include <linux/delay.h>
DECLARE_GLOBAL_DATA_PTR;
*/
switch (file) {
case stdin:
- gd->jt->getc = getc;
+ gd->jt->getc = getchar;
gd->jt->tstc = tstc;
break;
case stdout:
int cd_count[MAX_FILES];
/*
- * This depends on tstc() always being called before getc().
+ * This depends on tstc() always being called before getchar().
* This is guaranteed to be true because this routine is called
* only from fgetc() which assures it.
* No attempt is made to demultiplex multiple input sources.
}
}
-static void console_puts_noserial(int file, const char *s)
+/**
+ * console_puts_select() - Output a string to all console devices
+ *
+ * @file: File number to output to (e,g, stdout, see stdio.h)
+ * @serial_only: true to output only to serial, false to output to everything
+ * else
+ * @s: String to output
+ */
+static void console_puts_select(int file, bool serial_only, const char *s)
{
int i;
struct stdio_dev *dev;
for (i = 0; i < cd_count[file]; i++) {
+ bool is_serial;
+
dev = console_devices[file][i];
- if (dev->puts != NULL && !console_dev_is_serial(dev))
+ is_serial = console_dev_is_serial(dev);
+ if (dev->puts && serial_only == is_serial)
dev->puts(dev, s);
}
}
+void console_puts_select_stderr(bool serial_only, const char *s)
+{
+ console_puts_select(stderr, serial_only, s);
+}
+
static void console_puts(int file, const char *s)
{
int i;
stdio_devices[file]->putc(stdio_devices[file], c);
}
-static inline void console_puts_noserial(int file, const char *s)
+void console_puts_select(int file, bool serial_only, const char *s)
{
- if (!console_dev_is_serial(stdio_devices[file]))
+ if (serial_only == console_dev_is_serial(stdio_devices[file]))
stdio_devices[file]->puts(stdio_devices[file], s);
}
/** U-Boot INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************/
-int getc(void)
+int getchar(void)
{
#ifdef CONFIG_DISABLE_CONSOLE
if (gd->flags & GD_FLG_DISABLE_CONSOLE)
puts(buf_out);
break;
case PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL:
- console_puts_noserial(stdout, buf_out);
+ console_puts_select(stdout, false, buf_out);
break;
}
}
void putc(const char c)
{
+ if (!gd)
+ return;
+#ifdef CONFIG_CONSOLE_RECORD
+ if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
+ membuff_putbyte((struct membuff *)&gd->console_out, c);
+#endif
#ifdef CONFIG_SANDBOX
/* sandbox can send characters to stdout before it has a console */
- if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+ if (!(gd->flags & GD_FLG_SERIAL_READY)) {
os_putc(c);
return;
}
#endif
#ifdef CONFIG_DEBUG_UART
/* if we don't have a console yet, use the debug UART */
- if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+ if (!(gd->flags & GD_FLG_SERIAL_READY)) {
printch(c);
return;
}
#endif
- if (!gd)
- return;
-#ifdef CONFIG_CONSOLE_RECORD
- if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
- membuff_putbyte((struct membuff *)&gd->console_out, c);
-#endif
#ifdef CONFIG_SILENT_CONSOLE
if (gd->flags & GD_FLG_SILENT) {
if (!(gd->flags & GD_FLG_DEVINIT))
void puts(const char *s)
{
+ if (!gd)
+ return;
+#ifdef CONFIG_CONSOLE_RECORD
+ if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
+ membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
+#endif
#ifdef CONFIG_SANDBOX
/* sandbox can send characters to stdout before it has a console */
- if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+ if (!(gd->flags & GD_FLG_SERIAL_READY)) {
os_puts(s);
return;
}
#endif
#ifdef CONFIG_DEBUG_UART
- if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+ if (!(gd->flags & GD_FLG_SERIAL_READY)) {
while (*s) {
int ch = *s++;
return;
}
#endif
- if (!gd)
- return;
-#ifdef CONFIG_CONSOLE_RECORD
- if ((gd->flags & GD_FLG_RECORD) && gd->console_out.start)
- membuff_put((struct membuff *)&gd->console_out, s, strlen(s));
-#endif
#ifdef CONFIG_SILENT_CONSOLE
if (gd->flags & GD_FLG_SILENT) {
if (!(gd->flags & GD_FLG_DEVINIT))
membuff_purge((struct membuff *)&gd->console_in);
}
-void console_record_reset_enable(void)
+int console_record_reset_enable(void)
{
console_record_reset();
gd->flags |= GD_FLG_RECORD;
+
+ return 0;
}
int console_record_readline(char *str, int maxlen)
{
if (!ctrlc_disabled && gd->have_console) {
if (tstc()) {
- switch (getc()) {
+ switch (getchar()) {
case 0x03: /* ^C - Control C */
ctrlc_was_pressed = 1;
return 1;
/* Flush input */
while (tstc())
- getc();
+ getchar();
i = 0;
while (i < sizeof(str_input)) {
- str_input[i] = getc();
+ str_input[i] = getchar();
putc(str_input[i]);
if (str_input[i] == '\r')
break;
dev = stdio_get_by_name(name);
#ifdef CONFIG_VIDCONSOLE_AS_LCD
- if (!dev && !strcmp(name, "lcd"))
+ if (!dev && !strcmp(name, CONFIG_VIDCONSOLE_AS_NAME))
dev = stdio_get_by_name("vidconsole");
#endif
display_options_get_banner(false, buf, sizeof(buf));
- console_puts_noserial(stdout, buf);
+ console_puts_select(stdout, false, buf);
#endif
return 0;
stdio_print_current_devices();
#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
#ifdef CONFIG_VIDCONSOLE_AS_LCD
- if (strstr(stdoutname, "lcd"))
- printf("Warning: Please change 'lcd' to 'vidconsole' in stdout/stderr environment vars\n");
+ if (strstr(stdoutname, CONFIG_VIDCONSOLE_AS_NAME))
+ printf("Warning: Please change '%s' to 'vidconsole' in stdout/stderr environment vars\n",
+ CONFIG_VIDCONSOLE_AS_NAME);
#endif
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE