]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/console.c
ppc4xx: (Re-)Enable CONFIG_PCI_PNP on AMCC 440EPx Sequoia
[karo-tx-uboot.git] / common / console.c
index 13ba63b9467545e9d4d53979aa6182f41939c535..d8a0cb6c7e8a1d43e43ad066514e23a72f88327e 100644 (file)
@@ -25,9 +25,9 @@
 #include <stdarg.h>
 #include <malloc.h>
 #include <console.h>
-#include <syscall.h>
+#include <exports.h>
 
-void **syscall_tbl;
+DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_AMIGAONEG3SE
 int console_changed = 0;
@@ -41,11 +41,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 */
@@ -78,13 +76,13 @@ static int console_setfile (int file, device_t * dev)
                 */
                switch (file) {
                case stdin:
-                       syscall_tbl[SYSCALL_GETC] = dev->getc;
-                       syscall_tbl[SYSCALL_TSTC] = dev->tstc;
+                       gd->jt[XF_getc] = dev->getc;
+                       gd->jt[XF_tstc] = dev->tstc;
                        break;
                case stdout:
-                       syscall_tbl[SYSCALL_PUTC] = dev->putc;
-                       syscall_tbl[SYSCALL_PUTS] = dev->puts;
-                       syscall_tbl[SYSCALL_PRINTF] = printf;
+                       gd->jt[XF_putc] = dev->putc;
+                       gd->jt[XF_puts] = dev->puts;
+                       gd->jt[XF_printf] = printf;
                        break;
                }
                break;
@@ -164,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);
@@ -177,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);
@@ -190,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 */
@@ -203,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 */
@@ -232,13 +232,25 @@ void printf (const char *fmt, ...)
        puts (printbuffer);
 }
 
+void vprintf (const char *fmt, va_list args)
+{
+       uint i;
+       char printbuffer[CFG_PBSIZE];
+
+       /* For this to work, printbuffer must be larger than
+        * anything we ever want to print.
+        */
+       i = vsprintf (printbuffer, fmt, args);
+
+       /* Print the string */
+       puts (printbuffer);
+}
+
 /* test if ctrl-c was pressed */
 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 ()) {
@@ -349,13 +361,17 @@ 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
+       if (getenv("silent") != NULL)
+               gd->flags |= GD_FLG_SILENT;
+#endif
+
        return (0);
 }
 
-#ifdef CFG_CONSOLE_IS_IN_ENV
+#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)
 {
@@ -374,7 +390,7 @@ device_t *search_device (int flags, char *name)
        }
        return dev;
 }
-#endif /* CFG_CONSOLE_IS_IN_ENV */
+#endif /* CFG_CONSOLE_IS_IN_ENV || CONFIG_SPLASH_SCREEN */
 
 #ifdef CFG_CONSOLE_IS_IN_ENV
 /* Called after the relocation - use desired console functions */
@@ -382,13 +398,16 @@ int console_init_r (void)
 {
        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 */
-       syscall_tbl[SYSCALL_GETC] = serial_getc;
-       syscall_tbl[SYSCALL_TSTC] = serial_tstc;
-       syscall_tbl[SYSCALL_PUTC] = serial_putc;
-       syscall_tbl[SYSCALL_PUTS] = serial_puts;
-       syscall_tbl[SYSCALL_PRINTF] = serial_printf;
+       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 */
@@ -396,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);
@@ -422,25 +441,27 @@ int console_init_r (void)
                console_setfile (stdin, inputdev);
        }
 
+       gd->flags |= GD_FLG_DEVINIT;    /* device initialization completed */
+
 #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);
        }
@@ -451,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 */
@@ -469,6 +490,13 @@ int console_init_r (void)
        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                                            */
+       if (getenv("splashimage") != NULL)
+               gd->flags |= GD_FLG_SILENT;
+#endif
+
        /* Scan devices looking for input and output devices */
        for (i = 1;
             (i <= items) && ((inputdev == NULL) || (outputdev == NULL));
@@ -495,25 +523,27 @@ int console_init_r (void)
                console_setfile (stdin, inputdev);
        }
 
+       gd->flags |= GD_FLG_DEVINIT;    /* device initialization completed */
+
 #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);
        }