#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;
#endif
-#ifdef CFG_CONSOLE_IS_IN_ENV
+#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV
/*
* if overwrite_console returns 1, the stdin, stderr and stdout
* are switched to the serial port, else the settings in the
* environment are used
*/
-#ifdef CFG_CONSOLE_OVERWRITE_ROUTINE
+#ifdef CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE
extern int overwrite_console (void);
+#define OVERWRITE_CONSOLE overwrite_console ()
#else
-int overwrite_console (void)
-{
- return (0);
-}
-#endif /* CFG_CONSOLE_OVERWRITE_ROUTINE */
+#define OVERWRITE_CONSOLE 0
+#endif /* CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE */
-#endif /* CFG_CONSOLE_IS_IN_ENV */
+#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
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;
{
va_list args;
uint i;
- char printbuffer[CFG_PBSIZE];
+ char printbuffer[CONFIG_SYS_PBSIZE];
va_start (args, fmt);
{
va_list args;
uint i;
- char printbuffer[CFG_PBSIZE];
+ char printbuffer[CONFIG_SYS_PBSIZE];
va_start (args, fmt);
int getc (void)
{
- DECLARE_GLOBAL_DATA_PTR;
+#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 */
int tstc (void)
{
- DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_DISABLE_CONSOLE
+ if (gd->flags & GD_FLG_DISABLE_CONSOLE)
+ return 0;
+#endif
if (gd->flags & GD_FLG_DEVINIT) {
/* Test the standard input */
void putc (const char c)
{
- DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_SILENT_CONSOLE
+ if (gd->flags & GD_FLG_SILENT)
+ 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 */
void puts (const char *s)
{
- DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_SILENT_CONSOLE
+ if (gd->flags & GD_FLG_SILENT)
+ 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 */
{
va_list args;
uint i;
- char printbuffer[CFG_PBSIZE];
+ char printbuffer[CONFIG_SYS_PBSIZE];
va_start (args, fmt);
puts (printbuffer);
}
+void vprintf (const char *fmt, va_list args)
+{
+ uint i;
+ char printbuffer[CONFIG_SYS_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 ()) {
{
va_list args;
uint i;
- char printbuffer[CFG_PBSIZE];
+ char printbuffer[CONFIG_SYS_PBSIZE];
if (!once) {
memset(screen, 0, sizeof(screen));
/** 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) {
/* Check for valid device name */
- for (i = 1; i <= ListNumItems (devlist); i++) {
- device_t *dev = ListGetPtrToItem (devlist, i);
+ dev = search_device(flag, devname);
- if (strcmp (devname, dev->name) == 0) {
- if (dev->flags & flag)
- return console_setfile (file, dev);
-
- return -1;
- }
- }
+ if(dev)
+ return console_setfile (file, dev);
return -1;
}
/* Called before relocation - use serial functions */
int console_init_f (void)
{
- DECLARE_GLOBAL_DATA_PTR;
-
gd->have_console = 1;
- return (0);
-}
-
-#ifdef CFG_CONSOLE_IS_IN_ENV
-/* 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;
+#ifdef CONFIG_SILENT_CONSOLE
+ if (getenv("silent") != NULL)
+ gd->flags |= GD_FLG_SILENT;
+#endif
- for (i = 1; i <= items; i++) {
- dev = ListGetPtrToItem (devlist, i);
- if ((dev->flags & flags) && (strcmp (name, dev->name) == 0)) {
- break;
- }
- }
- return dev;
+ return (0);
}
-#endif /* CFG_CONSOLE_IS_IN_ENV */
-#ifdef CFG_CONSOLE_IS_IN_ENV
+#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;
+#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
+ int i;
+#endif /* CONFIG_SYS_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 */
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);
console_setfile (stdin, inputdev);
}
-#ifndef CFG_CONSOLE_INFO_QUIET
+ gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+
+#ifndef CONFIG_SYS_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);
}
-#endif /* CFG_CONSOLE_INFO_QUIET */
+#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
-#ifdef CFG_CONSOLE_ENV_OVERWRITE
+#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
/* set the environment variables (will overwrite previous env settings) */
for (i = 0; i < 3; i++) {
setenv (stdio_names[i], stdio_devices[i]->name);
}
-#endif /* CFG_CONSOLE_ENV_OVERWRITE */
+#endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
#if 0
/* If nothing usable installed, use only the initial console */
return (0);
}
-#else /* CFG_CONSOLE_IS_IN_ENV */
+#else /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
/* Called after the relocation - use desired console functions */
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)
+ 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;
if ((dev->flags & DEV_FLAGS_OUTPUT) && (outputdev == NULL)) {
outputdev = dev;
}
+ if(inputdev && outputdev)
+ break;
}
/* Initializes output console first */
console_setfile (stdin, inputdev);
}
-#ifndef CFG_CONSOLE_INFO_QUIET
- /* Print informations */
- printf ("In: ");
+ gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+
+#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET
+ /* Print information */
+ 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);
}
-#endif /* CFG_CONSOLE_INFO_QUIET */
+#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
/* Setting environment variables */
for (i = 0; i < 3; i++) {
return (0);
}
-#endif /* CFG_CONSOLE_IS_IN_ENV */
+#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */