static inline void console_printdevs(int file) { iomux_printdevs(file); }
/* Called after the relocation - use desired console functions */ int console_init_r (void) { char *stdinname, *stdoutname, *stderrname; device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL; #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE int i; #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ #ifdef CONFIG_CONSOLE_MUX int iomux_err = 0; #endif /* set default handlers at first */ gd->jt[XF_getc] = serial_getc; gd->jt[XF_tstc] = serial_tstc; gd->jt[XF_putc] = serial_putc; gd->jt[XF_puts] = serial_puts; gd->jt[XF_printf] = serial_printf; /* stdin stdout and stderr are in environment */ /* scan for it */ stdinname = getenv ("stdin"); stdoutname = getenv ("stdout"); stderrname = getenv ("stderr"); if (OVERWRITE_CONSOLE == 0) { /* if not overwritten by config switch */ inputdev = search_device (DEV_FLAGS_INPUT, stdinname); outputdev = search_device (DEV_FLAGS_OUTPUT, stdoutname); errdev = search_device (DEV_FLAGS_OUTPUT, stderrname); #ifdef CONFIG_CONSOLE_MUX iomux_err = iomux_doenv(stdin, stdinname); iomux_err += iomux_doenv(stdout, stdoutname); iomux_err += iomux_doenv(stderr, stderrname); if (!iomux_err) /* Successful, so skip all the code below. */ goto done; #endif } /* if the devices are overwritten or not found, use default device */ if (inputdev == NULL) { inputdev = search_device (DEV_FLAGS_INPUT, "serial"); } if (outputdev == NULL) { outputdev = search_device (DEV_FLAGS_OUTPUT, "serial"); } if (errdev == NULL) { errdev = search_device (DEV_FLAGS_OUTPUT, "serial"); } /* Initializes output console first */ if (outputdev != NULL) { #ifdef CONFIG_CONSOLE_MUX /* need to set a console if not done above. */ iomux_doenv(stdout, outputdev->name); #else console_setfile (stdout, outputdev); #endif } if (errdev != NULL) { #ifdef CONFIG_CONSOLE_MUX /* need to set a console if not done above. */ iomux_doenv(stderr, errdev->name); #else console_setfile (stderr, errdev); #endif } if (inputdev != NULL) { #ifdef CONFIG_CONSOLE_MUX /* need to set a console if not done above. */ iomux_doenv(stdin, inputdev->name); #else console_setfile (stdin, inputdev); #endif } #ifdef CONFIG_CONSOLE_MUX done: #endif gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ #ifndef CONFIG_SYS_CONSOLE_INFO_QUIET /* Print information */ puts ("In: "); if (stdio_devices[stdin] == NULL) { puts ("No input devices available!\n"); } else { #ifdef CONFIG_CONSOLE_MUX iomux_printdevs(stdin); #else printf ("%s\n", stdio_devices[stdin]->name); #endif } puts ("Out: "); if (stdio_devices[stdout] == NULL) { puts ("No output devices available!\n"); } else { #ifdef CONFIG_CONSOLE_MUX iomux_printdevs(stdout); #else printf ("%s\n", stdio_devices[stdout]->name); #endif } puts ("Err: "); if (stdio_devices[stderr] == NULL) { puts ("No error devices available!\n"); } else { #ifdef CONFIG_CONSOLE_MUX iomux_printdevs(stderr); #else printf ("%s\n", stdio_devices[stderr]->name); #endif } #endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE /* set the environment variables (will overwrite previous env settings) */ for (i = 0; i < 3; i++) { setenv (stdio_names[i], stdio_devices[i]->name); } #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ #if 0 /* If nothing usable installed, use only the initial console */ if ((stdio_devices[stdin] == NULL) && (stdio_devices[stdout] == NULL)) return (0); #endif return (0); }