]> git.sur5r.net Git - u-boot/blobdiff - common/console.c
Add GIT version information (commid ID) to untagged U-Boot versions
[u-boot] / common / console.c
index 3ef60fd7ac39dd2c6b4b8e02f4b908867280883b..3c535d23d6d5ea592d982e57b41303c019a470f2 100644 (file)
@@ -39,11 +39,9 @@ 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 */
@@ -191,6 +189,11 @@ 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 */
                fputc (stdout, c);
@@ -204,6 +207,11 @@ 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 */
                fputs (stdout, s);
@@ -365,10 +373,16 @@ int console_init_f (void)
        DECLARE_GLOBAL_DATA_PTR;
 
        gd->have_console = 1;
+
+#ifdef CONFIG_SILENT_CONSOLE
+       if (getenv("silent") != NULL)
+               gd->flags |= GD_FLG_SILENT;
+#endif
+
        return (0);
 }
 
-#if defined(CFG_CONSOLE_IS_IN_ENV) || defined(CONFIG_SPLASH_SCREEN)
+#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)
 {
@@ -396,6 +410,9 @@ 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;
@@ -410,7 +427,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);
@@ -440,23 +457,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);
        }
@@ -467,7 +484,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 */
@@ -489,11 +506,17 @@ int console_init_r (void)
 
 #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");
+#endif
+
        /* Scan devices looking for input and output devices */
        for (i = 1;
             (i <= items) && ((inputdev == NULL) || (outputdev == NULL));
@@ -524,23 +547,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);
        }