]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/console.c
Merge branch 'master' of /home/stefan/git/u-boot/u-boot into next
[karo-tx-uboot.git] / common / console.c
index da49c968272068235ac79edbd9ef7a520eea3d68..1b095b1ca54fc331e1de9c4aef34efecc43684e2 100644 (file)
@@ -27,6 +27,8 @@
 #include <console.h>
 #include <exports.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifdef CONFIG_AMIGAONEG3SE
 int console_changed = 0;
 #endif
@@ -39,18 +41,15 @@ int console_changed = 0;
  */
 #ifdef CFG_CONSOLE_OVERWRITE_ROUTINE
 extern int overwrite_console (void);
+#define OVERWRITE_CONSOLE overwrite_console ()
 #else
-int overwrite_console (void)
-{
-       return (0);
-}
+#define OVERWRITE_CONSOLE 0
 #endif /* CFG_CONSOLE_OVERWRITE_ROUTINE */
 
 #endif /* CFG_CONSOLE_IS_IN_ENV */
 
 static int console_setfile (int file, device_t * dev)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        int error = 0;
 
        if (dev == NULL)
@@ -163,8 +162,6 @@ void fprintf (int file, const char *fmt, ...)
 
 int getc (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (gd->flags & GD_FLG_DEVINIT) {
                /* Get from the standard input */
                return fgetc (stdin);
@@ -176,8 +173,6 @@ int getc (void)
 
 int tstc (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (gd->flags & GD_FLG_DEVINIT) {
                /* Test the standard input */
                return ftstc (stdin);
@@ -189,7 +184,10 @@ int tstc (void)
 
 void putc (const char c)
 {
-       DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_SILENT_CONSOLE
+       if (gd->flags & GD_FLG_SILENT)
+               return;
+#endif
 
        if (gd->flags & GD_FLG_DEVINIT) {
                /* Send to the standard output */
@@ -202,7 +200,10 @@ void putc (const char c)
 
 void puts (const char *s)
 {
-       DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_SILENT_CONSOLE
+       if (gd->flags & GD_FLG_SILENT)
+               return;
+#endif
 
        if (gd->flags & GD_FLG_DEVINIT) {
                /* Send to the standard output */
@@ -250,8 +251,6 @@ static int ctrlc_disabled = 0;      /* see disable_ctrl() */
 static int ctrlc_was_pressed = 0;
 int ctrlc (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (!ctrlc_disabled && gd->have_console) {
                if (tstc ()) {
                        switch (getc ()) {
@@ -362,8 +361,6 @@ int console_assign (int file, char *devname)
 /* Called before relocation - use serial functions */
 int console_init_f (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        gd->have_console = 1;
 
 #ifdef CONFIG_SILENT_CONSOLE
@@ -399,9 +396,11 @@ device_t *search_device (int flags, char *name)
 /* Called after the relocation - use desired console functions */
 int console_init_r (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        char *stdinname, *stdoutname, *stderrname;
        device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL;
+#ifdef CFG_CONSOLE_ENV_OVERWRITE
+       int i;
+#endif /* CFG_CONSOLE_ENV_OVERWRITE */
 
        /* set default handlers at first */
        gd->jt[XF_getc] = serial_getc;
@@ -416,7 +415,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);
@@ -446,23 +445,23 @@ int console_init_r (void)
 
 #ifndef CFG_CONSOLE_INFO_QUIET
        /* Print information */
-       printf ("In:    ");
+       puts ("In:    ");
        if (stdio_devices[stdin] == NULL) {
-               printf ("No input devices available!\n");
+               puts ("No input devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stdin]->name);
        }
 
-       printf ("Out:   ");
+       puts ("Out:   ");
        if (stdio_devices[stdout] == NULL) {
-               printf ("No output devices available!\n");
+               puts ("No output devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stdout]->name);
        }
 
-       printf ("Err:   ");
+       puts ("Err:   ");
        if (stdio_devices[stderr] == NULL) {
-               printf ("No error devices available!\n");
+               puts ("No error devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stderr]->name);
        }
@@ -473,7 +472,7 @@ int console_init_r (void)
        for (i = 0; i < 3; i++) {
                setenv (stdio_names[i], stdio_devices[i]->name);
        }
-#endif /*  CFG_CONSOLE_ENV_OVERWRITE */
+#endif /* CFG_CONSOLE_ENV_OVERWRITE */
 
 #if 0
        /* If nothing usable installed, use only the initial console */
@@ -488,22 +487,14 @@ int console_init_r (void)
 /* Called after the relocation - use desired console functions */
 int console_init_r (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        device_t *inputdev = NULL, *outputdev = NULL;
        int i, items = ListNumItems (devlist);
 
 #ifdef CONFIG_SPLASH_SCREEN
        /* suppress all output if splash screen is enabled and we have
-           a bmp to display                                            */
+          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 */
@@ -536,23 +527,23 @@ int console_init_r (void)
 
 #ifndef CFG_CONSOLE_INFO_QUIET
        /* Print information */
-       printf ("In:    ");
+       puts ("In:    ");
        if (stdio_devices[stdin] == NULL) {
-               printf ("No input devices available!\n");
+               puts ("No input devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stdin]->name);
        }
 
-       printf ("Out:   ");
+       puts ("Out:   ");
        if (stdio_devices[stdout] == NULL) {
-               printf ("No output devices available!\n");
+               puts ("No output devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stdout]->name);
        }
 
-       printf ("Err:   ");
+       puts ("Err:   ");
        if (stdio_devices[stderr] == NULL) {
-               printf ("No error devices available!\n");
+               puts ("No error devices available!\n");
        } else {
                printf ("%s\n", stdio_devices[stderr]->name);
        }