#include <common.h>
#include <stdarg.h>
#include <malloc.h>
-#include <console.h>
+#include <stdio_dev.h>
#include <exports.h>
DECLARE_GLOBAL_DATA_PTR;
#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
-static int console_setfile(int file, device_t * dev)
+static int console_setfile(int file, struct stdio_dev * dev)
{
int error = 0;
#if defined(CONFIG_CONSOLE_MUX)
/** Console I/O multiplexing *******************************************/
-static device_t *tstcdev;
-device_t **console_devices[MAX_FILES];
+static struct stdio_dev *tstcdev;
+struct stdio_dev **console_devices[MAX_FILES];
int cd_count[MAX_FILES];
/*
* only from fgetc() which assures it.
* No attempt is made to demultiplex multiple input sources.
*/
-static int iomux_getc(void)
+static int console_getc(int file)
{
unsigned char ret;
return ret;
}
-static int iomux_tstc(int file)
+static int console_tstc(int file)
{
int i, ret;
- device_t *dev;
+ struct stdio_dev *dev;
disable_ctrlc(1);
for (i = 0; i < cd_count[file]; i++) {
return 0;
}
-static void iomux_putc(int file, const char c)
+static void console_putc(int file, const char c)
{
int i;
- device_t *dev;
+ struct stdio_dev *dev;
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
}
}
-static void iomux_puts(int file, const char *s)
+static void console_puts(int file, const char *s)
{
int i;
- device_t *dev;
+ struct stdio_dev *dev;
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
dev->puts(s);
}
}
+
+static inline void console_printdevs(int file)
+{
+ iomux_printdevs(file);
+}
+
+static inline void console_doenv(int file, struct stdio_dev *dev)
+{
+ iomux_doenv(file, dev->name);
+}
+#else
+static inline int console_getc(int file)
+{
+ return stdio_devices[file]->getc();
+}
+
+static inline int console_tstc(int file)
+{
+ return stdio_devices[file]->tstc();
+}
+
+static inline void console_putc(int file, const char c)
+{
+ stdio_devices[file]->putc(c);
+}
+
+static inline void console_puts(int file, const char *s)
+{
+ stdio_devices[file]->puts(s);
+}
+
+static inline void console_printdevs(int file)
+{
+ printf("%s\n", stdio_devices[file]->name);
+}
+
+static inline void console_doenv(int file, struct stdio_dev *dev)
+{
+ console_setfile(file, dev);
+}
#endif /* defined(CONFIG_CONSOLE_MUX) */
/** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS *************************/
* check for that first.
*/
if (tstcdev != NULL)
- return iomux_getc();
- iomux_tstc(file);
+ return console_getc(file);
+ console_tstc(file);
#ifdef CONFIG_WATCHDOG
/*
* If the watchdog must be rate-limited then it should
#endif
}
#else
- return stdio_devices[file]->getc();
+ return console_getc(file);
#endif
}
int ftstc(int file)
{
if (file < MAX_FILES)
-#if defined(CONFIG_CONSOLE_MUX)
- return iomux_tstc(file);
-#else
- return stdio_devices[file]->tstc();
-#endif
+ return console_tstc(file);
return -1;
}
void fputc(int file, const char c)
{
if (file < MAX_FILES)
-#if defined(CONFIG_CONSOLE_MUX)
- iomux_putc(file, c);
-#else
- stdio_devices[file]->putc(c);
-#endif
+ console_putc(file, c);
}
void fputs(int file, const char *s)
{
if (file < MAX_FILES)
-#if defined(CONFIG_CONSOLE_MUX)
- iomux_puts(file, s);
-#else
- stdio_devices[file]->puts(s);
-#endif
+ console_puts(file, s);
}
void fprintf(int file, const char *fmt, ...)
/** U-Boot INIT FUNCTIONS *************************************************/
-device_t *search_device(int flags, char *name)
+struct stdio_dev *search_device(int flags, char *name)
{
- device_t *dev;
+ struct stdio_dev *dev;
- dev = device_get_by_name(name);
+ dev = stdio_get_by_name(name);
if (dev && (dev->flags & flags))
return dev;
int console_assign(int file, char *devname)
{
int flag;
- device_t *dev;
+ struct stdio_dev *dev;
/* Check for valid file */
switch (file) {
return 0;
}
+void stdio_print_current_devices(void)
+{
+#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
+ /* Print information */
+ puts("In: ");
+ if (stdio_devices[stdin] == NULL) {
+ puts("No input devices available!\n");
+ } else {
+ printf ("%s\n", stdio_devices[stdin]->name);
+ }
+
+ puts("Out: ");
+ if (stdio_devices[stdout] == NULL) {
+ puts("No output devices available!\n");
+ } else {
+ printf ("%s\n", stdio_devices[stdout]->name);
+ }
+
+ puts("Err: ");
+ if (stdio_devices[stderr] == NULL) {
+ puts("No error devices available!\n");
+ } else {
+ printf ("%s\n", stdio_devices[stderr]->name);
+ }
+#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
+}
+
#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV
/* 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;
+ struct stdio_dev *inputdev = NULL, *outputdev = NULL, *errdev = NULL;
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
int i;
#endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
}
/* 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
+ console_doenv(stdout, outputdev);
}
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
+ console_doenv(stderr, errdev);
}
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
+ console_doenv(stdin, inputdev);
}
#ifdef CONFIG_CONSOLE_MUX
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 */
+ stdio_print_current_devices();
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
/* set the environment variables (will overwrite previous env settings) */
/* Called after the relocation - use desired console functions */
int console_init_r(void)
{
- device_t *inputdev = NULL, *outputdev = NULL;
+ struct stdio_dev *inputdev = NULL, *outputdev = NULL;
int i;
- struct list_head *list = device_get_list();
+ struct list_head *list = stdio_get_list();
struct list_head *pos;
- device_t *dev;
+ struct stdio_dev *dev;
#ifdef CONFIG_SPLASH_SCREEN
/*
/* Scan devices looking for input and output devices */
list_for_each(pos, list) {
- dev = list_entry(pos, device_t, list);
+ dev = list_entry(pos, struct stdio_dev, list);
if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) {
inputdev = dev;
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 {
- printf("%s\n", stdio_devices[stdin]->name);
- }
-
- puts("Out: ");
- if (stdio_devices[stdout] == NULL) {
- puts("No output devices available!\n");
- } else {
- printf("%s\n", stdio_devices[stdout]->name);
- }
-
- puts("Err: ");
- if (stdio_devices[stderr] == NULL) {
- puts("No error devices available!\n");
- } else {
- printf("%s\n", stdio_devices[stderr]->name);
- }
-#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
+ stdio_print_current_devices();
/* Setting environment variables */
for (i = 0; i < 3; i++) {