X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fconsole.c;h=56d9118cb2d847c32c08f076a182cf2e6f89d789;hb=9029b68f3f81b3013044f167ea025e836e6c8c0e;hp=e9f23bec1820f178e3f4a67e3241182a0c65dc9d;hpb=71b405df4e8efc0d6ac3b308d15e74eaa029eb5c;p=u-boot diff --git a/common/console.c b/common/console.c index e9f23bec18..56d9118cb2 100644 --- a/common/console.c +++ b/common/console.c @@ -162,6 +162,11 @@ void fprintf (int file, const char *fmt, ...) int getc (void) { +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return 0; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Get from the standard input */ return fgetc (stdin); @@ -173,6 +178,11 @@ int getc (void) int tstc (void) { +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return 0; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Test the standard input */ return ftstc (stdin); @@ -189,6 +199,11 @@ void putc (const char c) return; #endif +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Send to the standard output */ fputc (stdout, c); @@ -205,6 +220,11 @@ void puts (const char *s) return; #endif +#ifdef CONFIG_DISABLE_CONSOLE + if (gd->flags & GD_FLG_DISABLE_CONSOLE) + return; +#endif + if (gd->flags & GD_FLG_DEVINIT) { /* Send to the standard output */ fputs (stdout, s); @@ -325,9 +345,22 @@ inline void dbg(const char *fmt, ...) /** U-Boot INIT FUNCTIONS *************************************************/ +device_t *search_device (int flags, char *name) +{ + device_t *dev; + + dev = device_get_by_name(name); + + if(dev && (dev->flags & flags)) + return dev; + + return NULL; +} + int console_assign (int file, char *devname) { - int flag, i; + int flag; + device_t *dev; /* Check for valid file */ switch (file) { @@ -344,16 +377,10 @@ int console_assign (int file, char *devname) /* Check for valid device name */ - for (i = 1; i <= ListNumItems (devlist); i++) { - device_t *dev = ListGetPtrToItem (devlist, i); - - if (strcmp (devname, dev->name) == 0) { - if (dev->flags & flag) - return console_setfile (file, dev); + dev = search_device(flag, devname); - return -1; - } - } + if(dev) + return console_setfile (file, dev); return -1; } @@ -371,27 +398,6 @@ int console_init_f (void) return (0); } -#if defined(CFG_CONSOLE_IS_IN_ENV) || defined(CONFIG_SPLASH_SCREEN) || defined(CONFIG_SILENT_CONSOLE) -/* search a device */ -device_t *search_device (int flags, char *name) -{ - int i, items; - device_t *dev = NULL; - - items = ListNumItems (devlist); - if (name == NULL) - return dev; - - for (i = 1; i <= items; i++) { - dev = ListGetPtrToItem (devlist, i); - if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) { - break; - } - } - return dev; -} -#endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */ - #ifdef CFG_CONSOLE_IS_IN_ENV /* Called after the relocation - use desired console functions */ int console_init_r (void) @@ -415,7 +421,7 @@ int console_init_r (void) stdoutname = getenv ("stdout"); stderrname = getenv ("stderr"); - if (OVERWRITE_CONSOLE == 0) { /* if not overwritten by config switch */ + 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); @@ -488,27 +494,21 @@ int console_init_r (void) int console_init_r (void) { device_t *inputdev = NULL, *outputdev = NULL; - int i, items = ListNumItems (devlist); + int i; + struct list_head *list = device_get_list(); + struct list_head *pos; + device_t *dev; #ifdef CONFIG_SPLASH_SCREEN /* suppress all output if splash screen is enabled and we have a bmp to display */ if (getenv("splashimage") != NULL) - outputdev = search_device (DEV_FLAGS_OUTPUT, "nulldev"); -#endif - -#ifdef CONFIG_SILENT_CONSOLE - /* Suppress all output if "silent" mode requested */ - if (gd->flags & GD_FLG_SILENT) - outputdev = search_device (DEV_FLAGS_OUTPUT, "nulldev"); + gd->flags |= GD_FLG_SILENT; #endif /* Scan devices looking for input and output devices */ - for (i = 1; - (i <= items) && ((inputdev == NULL) || (outputdev == NULL)); - i++ - ) { - device_t *dev = ListGetPtrToItem (devlist, i); + list_for_each(pos, list) { + dev = list_entry(pos, device_t, list); if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) { inputdev = dev; @@ -516,6 +516,8 @@ int console_init_r (void) if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev == NULL)) { outputdev = dev; } + if(inputdev && outputdev) + break; } /* Initializes output console first */