1 // SPDX-License-Identifier: GPL-2.0+
4 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
9 #include <debug_uart.h>
10 #include <display_options.h>
19 #include <stdio_dev.h>
21 #include <env_internal.h>
23 #include <asm/global_data.h>
24 #include <linux/delay.h>
26 DECLARE_GLOBAL_DATA_PTR;
28 static int on_console(const char *name, const char *value, enum env_op op,
33 /* Check for console redirection */
34 if (strcmp(name, "stdin") == 0)
36 else if (strcmp(name, "stdout") == 0)
38 else if (strcmp(name, "stderr") == 0)
41 /* if not actually setting a console variable, we don't care */
42 if (console == -1 || (gd->flags & GD_FLG_DEVINIT) == 0)
47 case env_op_overwrite:
49 if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
50 if (iomux_doenv(console, value))
53 /* Try assigning specified device */
54 if (console_assign(console, value) < 0)
61 if ((flags & H_FORCE) == 0)
62 printf("Can't delete \"%s\"\n", name);
69 U_BOOT_ENV_CALLBACK(console, on_console);
71 #ifdef CONFIG_SILENT_CONSOLE
72 static int on_silent(const char *name, const char *value, enum env_op op,
75 if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_SET))
76 if (flags & H_INTERACTIVE)
79 if (!CONFIG_IS_ENABLED(SILENT_CONSOLE_UPDATE_ON_RELOC))
80 if ((flags & H_INTERACTIVE) == 0)
84 gd->flags |= GD_FLG_SILENT;
86 gd->flags &= ~GD_FLG_SILENT;
90 U_BOOT_ENV_CALLBACK(silent, on_silent);
93 #ifdef CONFIG_CONSOLE_RECORD
94 /* helper function: access to gd->console_out and gd->console_in */
95 static void console_record_putc(const char c)
97 if (!(gd->flags & GD_FLG_RECORD))
99 if (gd->console_out.start &&
100 !membuff_putbyte((struct membuff *)&gd->console_out, c))
101 gd->flags |= GD_FLG_RECORD_OVF;
104 static void console_record_puts(const char *s)
106 if (!(gd->flags & GD_FLG_RECORD))
108 if (gd->console_out.start) {
111 if (membuff_put((struct membuff *)&gd->console_out, s, len) !=
113 gd->flags |= GD_FLG_RECORD_OVF;
117 static int console_record_getc(void)
119 if (!(gd->flags & GD_FLG_RECORD))
121 if (!gd->console_in.start)
124 return membuff_getbyte((struct membuff *)&gd->console_in);
127 static int console_record_tstc(void)
129 if (!(gd->flags & GD_FLG_RECORD))
131 if (gd->console_in.start) {
132 if (membuff_peekbyte((struct membuff *)&gd->console_in) != -1)
138 static void console_record_putc(char c)
142 static void console_record_puts(const char *s)
146 static int console_record_getc(void)
151 static int console_record_tstc(void)
157 #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
159 * if overwrite_console returns 1, the stdin, stderr and stdout
160 * are switched to the serial port, else the settings in the
161 * environment are used
163 #ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
164 extern int overwrite_console(void);
165 #define OVERWRITE_CONSOLE overwrite_console()
167 #define OVERWRITE_CONSOLE 0
168 #endif /* CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE */
170 #endif /* CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) */
172 static int console_setfile(int file, struct stdio_dev * dev)
183 error = console_start(file, dev);
187 /* Assign the new device (leaving the existing one started) */
188 stdio_devices[file] = dev;
191 * Update monitor functions
192 * (to use the console stuff by other applications)
196 gd->jt->getc = getchar;
202 gd->jt->printf = printf;
207 default: /* Invalid file ID */
214 * console_dev_is_serial() - Check if a stdio device is a serial device
216 * @sdev: Device to check
217 * Return: true if this device is in the serial uclass (or for pre-driver-model,
218 * whether it is called "serial".
220 static bool console_dev_is_serial(struct stdio_dev *sdev)
224 if (IS_ENABLED(CONFIG_DM_SERIAL) && (sdev->flags & DEV_FLAGS_DM)) {
225 struct udevice *dev = sdev->priv;
227 is_serial = device_get_uclass_id(dev) == UCLASS_SERIAL;
229 is_serial = !strcmp(sdev->name, "serial");
235 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
236 /** Console I/O multiplexing *******************************************/
238 /* tstcdev: save the last stdio device with pending characters, with tstc != 0 */
239 static struct stdio_dev *tstcdev;
240 struct stdio_dev **console_devices[MAX_FILES];
241 int cd_count[MAX_FILES];
243 static void console_devices_set(int file, struct stdio_dev *dev)
245 console_devices[file][0] = dev;
250 * console_needs_start_stop() - check if we need to start or stop the STDIO device
252 * @sdev: STDIO device in question
254 * This function checks if we need to start or stop the stdio device used for
255 * a console. For IOMUX case it simply enforces one time start and one time
256 * stop of the device independently of how many STDIO files are using it. In
257 * other words, we start console once before first STDIO device wants it and
258 * stop after the last is gone.
260 static bool console_needs_start_stop(int file, struct stdio_dev *sdev)
264 for (i = 0; i < ARRAY_SIZE(cd_count); i++) {
268 if (iomux_match_device(console_devices[i], cd_count[i], sdev) >= 0)
275 * This depends on tstc() always being called before getchar().
276 * This is guaranteed to be true because this routine is called
277 * only from fgetc() which assures it.
278 * No attempt is made to demultiplex multiple input sources.
280 static int console_getc(int file)
284 /* This is never called with testcdev == NULL */
285 ret = tstcdev->getc(tstcdev);
290 /* Upper layer may have already called tstc(): check the saved result */
291 static bool console_has_tstc(void)
296 static int console_tstc(int file)
299 struct stdio_dev *dev;
302 prev = disable_ctrlc(1);
303 for_each_console_dev(i, file, dev) {
304 if (dev->tstc != NULL) {
305 ret = dev->tstc(dev);
318 static void console_putc(int file, const char c)
321 struct stdio_dev *dev;
323 for_each_console_dev(i, file, dev) {
324 if (dev->putc != NULL)
330 * console_puts_select() - Output a string to all console devices
332 * @file: File number to output to (e,g, stdout, see stdio.h)
333 * @serial_only: true to output only to serial, false to output to everything
335 * @s: String to output
337 static void console_puts_select(int file, bool serial_only, const char *s)
340 struct stdio_dev *dev;
342 for_each_console_dev(i, file, dev) {
343 bool is_serial = console_dev_is_serial(dev);
345 if (dev->puts && serial_only == is_serial)
350 void console_puts_select_stderr(bool serial_only, const char *s)
352 if (gd->flags & GD_FLG_DEVINIT)
353 console_puts_select(stderr, serial_only, s);
356 static void console_puts(int file, const char *s)
359 struct stdio_dev *dev;
361 for_each_console_dev(i, file, dev) {
362 if (dev->puts != NULL)
367 #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
368 static inline void console_doenv(int file, struct stdio_dev *dev)
370 iomux_doenv(file, dev->name);
375 static void console_devices_set(int file, struct stdio_dev *dev)
379 static inline bool console_needs_start_stop(int file, struct stdio_dev *sdev)
384 static inline int console_getc(int file)
386 return stdio_devices[file]->getc(stdio_devices[file]);
389 static bool console_has_tstc(void)
394 static inline int console_tstc(int file)
396 return stdio_devices[file]->tstc(stdio_devices[file]);
399 static inline void console_putc(int file, const char c)
401 stdio_devices[file]->putc(stdio_devices[file], c);
404 void console_puts_select(int file, bool serial_only, const char *s)
406 if ((gd->flags & GD_FLG_DEVINIT) &&
407 serial_only == console_dev_is_serial(stdio_devices[file]))
408 stdio_devices[file]->puts(stdio_devices[file], s);
411 static inline void console_puts(int file, const char *s)
413 stdio_devices[file]->puts(stdio_devices[file], s);
416 #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
417 static inline void console_doenv(int file, struct stdio_dev *dev)
419 console_setfile(file, dev);
422 #endif /* CONIFIG_IS_ENABLED(CONSOLE_MUX) */
424 static void __maybe_unused console_setfile_and_devices(int file, struct stdio_dev *dev)
426 console_setfile(file, dev);
427 console_devices_set(file, dev);
430 int console_start(int file, struct stdio_dev *sdev)
434 if (!console_needs_start_stop(file, sdev))
437 /* Start new device */
439 error = sdev->start(sdev);
440 /* If it's not started don't use it */
447 void console_stop(int file, struct stdio_dev *sdev)
449 if (!console_needs_start_stop(file, sdev))
456 /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/
458 int serial_printf(const char *fmt, ...)
462 char printbuffer[CONFIG_SYS_PBSIZE];
466 /* For this to work, printbuffer must be larger than
467 * anything we ever want to print.
469 i = vscnprintf(printbuffer, sizeof(printbuffer), fmt, args);
472 serial_puts(printbuffer);
478 if (file < MAX_FILES) {
480 * Effectively poll for input wherever it may be available.
484 if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
486 * Upper layer may have already called tstc() so
487 * check for that first.
489 if (console_has_tstc())
490 return console_getc(file);
493 if (console_tstc(file))
494 return console_getc(file);
498 * If the watchdog must be rate-limited then it should
499 * already be handled in board-specific code.
501 if (IS_ENABLED(CONFIG_WATCHDOG))
511 if (file < MAX_FILES)
512 return console_tstc(file);
517 void fputc(int file, const char c)
519 if (file < MAX_FILES)
520 console_putc(file, c);
523 void fputs(int file, const char *s)
525 if (file < MAX_FILES)
526 console_puts(file, s);
529 int fprintf(int file, const char *fmt, ...)
533 char printbuffer[CONFIG_SYS_PBSIZE];
537 /* For this to work, printbuffer must be larger than
538 * anything we ever want to print.
540 i = vscnprintf(printbuffer, sizeof(printbuffer), fmt, args);
543 /* Send to desired file */
544 fputs(file, printbuffer);
548 /** U-Boot INITIAL CONSOLE-COMPATIBLE FUNCTION *****************************/
554 if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE))
557 if (!gd->have_console)
560 ch = console_record_getc();
564 if (gd->flags & GD_FLG_DEVINIT) {
565 /* Get from the standard input */
569 /* Send directly to the handler */
570 return serial_getc();
575 if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE))
578 if (!gd->have_console)
581 if (console_record_tstc())
584 if (gd->flags & GD_FLG_DEVINIT) {
585 /* Test the standard input */
589 /* Send directly to the handler */
590 return serial_tstc();
593 #define PRE_CONSOLE_FLUSHPOINT1_SERIAL 0
594 #define PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL 1
596 #if CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
597 #define CIRC_BUF_IDX(idx) ((idx) % (unsigned long)CONFIG_VAL(PRE_CON_BUF_SZ))
599 static void pre_console_putc(const char c)
603 if (gd->precon_buf_idx < 0)
606 buffer = map_sysmem(CONFIG_VAL(PRE_CON_BUF_ADDR), CONFIG_VAL(PRE_CON_BUF_SZ));
608 buffer[CIRC_BUF_IDX(gd->precon_buf_idx++)] = c;
610 unmap_sysmem(buffer);
613 static void pre_console_puts(const char *s)
615 if (gd->precon_buf_idx < 0)
619 pre_console_putc(*s++);
622 static void print_pre_console_buffer(int flushpoint)
624 long in = 0, out = 0;
625 char buf_out[CONFIG_VAL(PRE_CON_BUF_SZ) + 1];
628 if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT))
631 buf_in = map_sysmem(CONFIG_VAL(PRE_CON_BUF_ADDR), CONFIG_VAL(PRE_CON_BUF_SZ));
632 if (gd->precon_buf_idx > CONFIG_VAL(PRE_CON_BUF_SZ))
633 in = gd->precon_buf_idx - CONFIG_VAL(PRE_CON_BUF_SZ);
635 while (in < gd->precon_buf_idx)
636 buf_out[out++] = buf_in[CIRC_BUF_IDX(in++)];
637 unmap_sysmem(buf_in);
641 gd->precon_buf_idx = -1;
642 switch (flushpoint) {
643 case PRE_CONSOLE_FLUSHPOINT1_SERIAL:
646 case PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL:
647 console_puts_select(stdout, false, buf_out);
650 gd->precon_buf_idx = in;
653 static inline void pre_console_putc(const char c) {}
654 static inline void pre_console_puts(const char *s) {}
655 static inline void print_pre_console_buffer(int flushpoint) {}
658 void putc(const char c)
663 console_record_putc(c);
665 /* sandbox can send characters to stdout before it has a console */
666 if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) {
671 /* if we don't have a console yet, use the debug UART */
672 if (IS_ENABLED(CONFIG_DEBUG_UART) && !(gd->flags & GD_FLG_SERIAL_READY)) {
677 if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT)) {
678 if (!(gd->flags & GD_FLG_DEVINIT))
683 if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE))
686 if (!gd->have_console)
687 return pre_console_putc(c);
689 if (gd->flags & GD_FLG_DEVINIT) {
690 /* Send to the standard output */
693 /* Send directly to the handler */
699 void puts(const char *s)
704 console_record_puts(s);
706 /* sandbox can send characters to stdout before it has a console */
707 if (IS_ENABLED(CONFIG_SANDBOX) && !(gd->flags & GD_FLG_SERIAL_READY)) {
712 if (IS_ENABLED(CONFIG_DEBUG_UART) && !(gd->flags & GD_FLG_SERIAL_READY)) {
721 if (IS_ENABLED(CONFIG_SILENT_CONSOLE) && (gd->flags & GD_FLG_SILENT)) {
722 if (!(gd->flags & GD_FLG_DEVINIT))
727 if (IS_ENABLED(CONFIG_DISABLE_CONSOLE) && (gd->flags & GD_FLG_DISABLE_CONSOLE))
730 if (!gd->have_console)
731 return pre_console_puts(s);
733 if (gd->flags & GD_FLG_DEVINIT) {
734 /* Send to the standard output */
737 /* Send directly to the handler */
743 #ifdef CONFIG_CONSOLE_RECORD
744 int console_record_init(void)
748 ret = membuff_new((struct membuff *)&gd->console_out,
749 gd->flags & GD_FLG_RELOC ?
750 CONFIG_CONSOLE_RECORD_OUT_SIZE :
751 CONFIG_CONSOLE_RECORD_OUT_SIZE_F);
754 ret = membuff_new((struct membuff *)&gd->console_in,
755 CONFIG_CONSOLE_RECORD_IN_SIZE);
760 void console_record_reset(void)
762 membuff_purge((struct membuff *)&gd->console_out);
763 membuff_purge((struct membuff *)&gd->console_in);
764 gd->flags &= ~GD_FLG_RECORD_OVF;
767 int console_record_reset_enable(void)
769 console_record_reset();
770 gd->flags |= GD_FLG_RECORD;
775 int console_record_readline(char *str, int maxlen)
777 if (gd->flags & GD_FLG_RECORD_OVF)
780 return membuff_readline((struct membuff *)&gd->console_out, str,
784 int console_record_avail(void)
786 return membuff_avail((struct membuff *)&gd->console_out);
789 int console_in_puts(const char *str)
791 return membuff_put((struct membuff *)&gd->console_in, str, strlen(str));
796 /* test if ctrl-c was pressed */
797 static int ctrlc_disabled = 0; /* see disable_ctrl() */
798 static int ctrlc_was_pressed = 0;
801 if (!ctrlc_disabled && gd->have_console) {
804 case 0x03: /* ^C - Control C */
805 ctrlc_was_pressed = 1;
815 /* Reads user's confirmation.
816 Returns 1 if user's input is "y", "Y", "yes" or "YES"
818 int confirm_yesno(void)
827 while (i < sizeof(str_input)) {
828 str_input[i] = getchar();
830 if (str_input[i] == '\r')
835 if (strncmp(str_input, "y\r", 2) == 0 ||
836 strncmp(str_input, "Y\r", 2) == 0 ||
837 strncmp(str_input, "yes\r", 4) == 0 ||
838 strncmp(str_input, "YES\r", 4) == 0)
842 /* pass 1 to disable ctrlc() checking, 0 to enable.
843 * returns previous state
845 int disable_ctrlc(int disable)
847 int prev = ctrlc_disabled; /* save previous state */
849 ctrlc_disabled = disable;
855 return ctrlc_was_pressed;
858 void clear_ctrlc(void)
860 ctrlc_was_pressed = 0;
863 /** U-Boot INIT FUNCTIONS *************************************************/
865 struct stdio_dev *console_search_dev(int flags, const char *name)
867 struct stdio_dev *dev;
869 dev = stdio_get_by_name(name);
870 #ifdef CONFIG_VIDCONSOLE_AS_LCD
871 if (!dev && !strcmp(name, CONFIG_VIDCONSOLE_AS_NAME))
872 dev = stdio_get_by_name("vidconsole");
875 if (dev && (dev->flags & flags))
881 int console_assign(int file, const char *devname)
884 struct stdio_dev *dev;
886 /* Check for valid file */
887 flag = stdio_file_to_flags(file);
891 /* Check for valid device name */
893 dev = console_search_dev(flag, devname);
896 return console_setfile(file, dev);
901 /* return true if the 'silent' flag is removed */
902 static bool console_update_silent(void)
904 unsigned long flags = gd->flags;
906 if (!IS_ENABLED(CONFIG_SILENT_CONSOLE))
909 if (env_get("silent")) {
910 gd->flags |= GD_FLG_SILENT;
914 gd->flags &= ~GD_FLG_SILENT;
916 return !!(flags & GD_FLG_SILENT);
919 int console_announce_r(void)
921 #if !CONFIG_IS_ENABLED(PRE_CONSOLE_BUFFER)
922 char buf[DISPLAY_OPTIONS_BANNER_LENGTH];
924 display_options_get_banner(false, buf, sizeof(buf));
926 console_puts_select(stdout, false, buf);
932 /* Called before relocation - use serial functions */
933 int console_init_f(void)
935 gd->have_console = 1;
937 console_update_silent();
939 print_pre_console_buffer(PRE_CONSOLE_FLUSHPOINT1_SERIAL);
944 void stdio_print_current_devices(void)
946 /* Print information */
948 if (stdio_devices[stdin] == NULL) {
949 puts("No input devices available!\n");
951 printf ("%s\n", stdio_devices[stdin]->name);
955 if (stdio_devices[stdout] == NULL) {
956 puts("No output devices available!\n");
958 printf ("%s\n", stdio_devices[stdout]->name);
962 if (stdio_devices[stderr] == NULL) {
963 puts("No error devices available!\n");
965 printf ("%s\n", stdio_devices[stderr]->name);
969 #if CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV)
970 /* Called after the relocation - use desired console functions */
971 int console_init_r(void)
973 char *stdinname, *stdoutname, *stderrname;
974 struct stdio_dev *inputdev = NULL, *outputdev = NULL, *errdev = NULL;
979 /* update silent for env loaded from flash (initr_env) */
980 if (console_update_silent())
981 flushpoint = PRE_CONSOLE_FLUSHPOINT1_SERIAL;
983 flushpoint = PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL;
985 /* set default handlers at first */
986 gd->jt->getc = serial_getc;
987 gd->jt->tstc = serial_tstc;
988 gd->jt->putc = serial_putc;
989 gd->jt->puts = serial_puts;
990 gd->jt->printf = serial_printf;
992 /* stdin stdout and stderr are in environment */
994 stdinname = env_get("stdin");
995 stdoutname = env_get("stdout");
996 stderrname = env_get("stderr");
998 if (OVERWRITE_CONSOLE == 0) { /* if not overwritten by config switch */
999 inputdev = console_search_dev(DEV_FLAGS_INPUT, stdinname);
1000 outputdev = console_search_dev(DEV_FLAGS_OUTPUT, stdoutname);
1001 errdev = console_search_dev(DEV_FLAGS_OUTPUT, stderrname);
1002 if (CONFIG_IS_ENABLED(CONSOLE_MUX)) {
1003 iomux_err = iomux_doenv(stdin, stdinname);
1004 iomux_err += iomux_doenv(stdout, stdoutname);
1005 iomux_err += iomux_doenv(stderr, stderrname);
1007 /* Successful, so skip all the code below. */
1011 /* if the devices are overwritten or not found, use default device */
1012 if (inputdev == NULL) {
1013 inputdev = console_search_dev(DEV_FLAGS_INPUT, "serial");
1015 if (outputdev == NULL) {
1016 outputdev = console_search_dev(DEV_FLAGS_OUTPUT, "serial");
1018 if (errdev == NULL) {
1019 errdev = console_search_dev(DEV_FLAGS_OUTPUT, "serial");
1021 /* Initializes output console first */
1022 if (outputdev != NULL) {
1023 /* need to set a console if not done above. */
1024 console_doenv(stdout, outputdev);
1026 if (errdev != NULL) {
1027 /* need to set a console if not done above. */
1028 console_doenv(stderr, errdev);
1030 if (inputdev != NULL) {
1031 /* need to set a console if not done above. */
1032 console_doenv(stdin, inputdev);
1037 if (!IS_ENABLED(CONFIG_SYS_CONSOLE_INFO_QUIET))
1038 stdio_print_current_devices();
1040 #ifdef CONFIG_VIDCONSOLE_AS_LCD
1041 if (strstr(stdoutname, CONFIG_VIDCONSOLE_AS_NAME))
1042 printf("Warning: Please change '%s' to 'vidconsole' in stdout/stderr environment vars\n",
1043 CONFIG_VIDCONSOLE_AS_NAME);
1046 if (IS_ENABLED(CONFIG_SYS_CONSOLE_ENV_OVERWRITE)) {
1047 /* set the environment variables (will overwrite previous env settings) */
1048 for (i = 0; i < MAX_FILES; i++)
1049 env_set(stdio_names[i], stdio_devices[i]->name);
1052 gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
1054 print_pre_console_buffer(flushpoint);
1058 #else /* !CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) */
1060 /* Called after the relocation - use desired console functions */
1061 int console_init_r(void)
1063 struct stdio_dev *inputdev = NULL, *outputdev = NULL;
1065 struct list_head *list = stdio_get_list();
1066 struct list_head *pos;
1067 struct stdio_dev *dev;
1070 /* update silent for env loaded from flash (initr_env) */
1071 if (console_update_silent())
1072 flushpoint = PRE_CONSOLE_FLUSHPOINT1_SERIAL;
1074 flushpoint = PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL;
1077 * suppress all output if splash screen is enabled and we have
1078 * a bmp to display. We redirect the output from frame buffer
1079 * console to serial console in this case or suppress it if
1080 * "silent" mode was requested.
1082 if (IS_ENABLED(CONFIG_SPLASH_SCREEN) && env_get("splashimage")) {
1083 if (!(gd->flags & GD_FLG_SILENT))
1084 outputdev = console_search_dev (DEV_FLAGS_OUTPUT, "serial");
1087 /* Scan devices looking for input and output devices */
1088 list_for_each(pos, list) {
1089 dev = list_entry(pos, struct stdio_dev, list);
1091 if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) {
1094 if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev == NULL)) {
1097 if(inputdev && outputdev)
1101 /* Initializes output console first */
1102 if (outputdev != NULL) {
1103 console_setfile_and_devices(stdout, outputdev);
1104 console_setfile_and_devices(stderr, outputdev);
1107 /* Initializes input console */
1108 if (inputdev != NULL)
1109 console_setfile_and_devices(stdin, inputdev);
1111 if (!IS_ENABLED(CONFIG_SYS_CONSOLE_INFO_QUIET))
1112 stdio_print_current_devices();
1114 /* Setting environment variables */
1115 for (i = 0; i < MAX_FILES; i++) {
1116 env_set(stdio_names[i], stdio_devices[i]->name);
1119 gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
1121 print_pre_console_buffer(flushpoint);
1125 #endif /* CONFIG_IS_ENABLED(SYS_CONSOLE_IS_IN_ENV) */