diff --git a/common/Kconfig b/common/Kconfig index c0112a5..a2bb5e8 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -223,6 +223,20 @@ commands like bootm or iminfo. This option is automatically enabled when you select CFG_CMD_DATE . +config CONSOLE_FULL + bool + default y + prompt "Enable full console support" + help + This option enables full console support capable of + handling multiple consoles. + +config CONSOLE_SIMPLE + bool + default y + depends on !CONSOLE_FULL + + config CONSOLE_ACTIVATE_FIRST bool default y diff --git a/common/Makefile b/common/Makefile index c5b47ea..f0555a6 100644 --- a/common/Makefile +++ b/common/Makefile @@ -10,7 +10,8 @@ obj-y += dlmalloc.o obj-y += clock.o obj-y += command.o -obj-y += console.o +obj-$(CONFIG_CONSOLE_FULL) += console.o +obj-$(CONFIG_CONSOLE_SIMPLE) += console_simple.o obj-$(CONFIG_PARTITION) += partition.o obj-y += env.o obj-y += startup.o diff --git a/common/command.c b/common/command.c index d1b19c0..c86b005 100644 --- a/common/command.c +++ b/common/command.c @@ -33,13 +33,16 @@ #include #include #include +#include + +const char version_string[] = + "U-Boot " UTS_RELEASE " (" __DATE__ " - " __TIME__ ")"; LIST_HEAD(command_list); EXPORT_SYMBOL(command_list); static int do_version (cmd_tbl_t *cmdtp, int argc, char *argv[]) { - extern char version_string[]; printf ("\n%s\n", version_string); return 0; } diff --git a/common/console.c b/common/console.c index e47c460..7a94f57 100644 --- a/common/console.c +++ b/common/console.c @@ -35,7 +35,6 @@ #include #include #include -#include LIST_HEAD(console_list); EXPORT_SYMBOL(console_list); @@ -44,8 +43,7 @@ #define CONSOLE_INIT_EARLY 1 #define CONSOLE_INIT_FULL 2 -const char version_string[] = - "U-Boot " UTS_RELEASE " (" __DATE__ " - " __TIME__ ")"; +extern char version_string[]; static void display_banner (void) { diff --git a/common/console_simple.c b/common/console_simple.c new file mode 100644 index 0000000..5a80f76 --- /dev/null +++ b/common/console_simple.c @@ -0,0 +1,117 @@ +#include +#include +#include + +static struct console_device *console; + +int printf (const char *fmt, ...) +{ + va_list args; + uint i; + char printbuffer[CFG_PBSIZE]; + + va_start (args, fmt); + + /* For this to work, printbuffer must be larger than + * anything we ever want to print. + */ + i = vsprintf (printbuffer, fmt, args); + va_end (args); + + /* Print the string */ + puts(printbuffer); + + return i; +} +EXPORT_SYMBOL(printf); + +int 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); + + return i; +} +EXPORT_SYMBOL(vprintf); + +void console_puts(unsigned int ch, const char *str) +{ + const char *s = str; + while (*s) { + console_putc(ch, *s); + if (*s == '\n') + console_putc(ch, '\r'); + s++; + } +} +EXPORT_SYMBOL(console_puts); + +void console_putc(unsigned int ch, char c) +{ + console->putc(console, c); + if (c == '\n') + console->putc(console, '\r'); +} +EXPORT_SYMBOL(console_putc); + +int fputc(int fd, char c) +{ + if (fd == 1) + putchar(c); + else if (fd == 2) + eputc(c); + else + return write(fd, &c, 1); + return 0; +} +EXPORT_SYMBOL(fputc); + +int fputs(int fd, const char *s) +{ + if (fd == 1) + puts(s); + else if (fd == 2) + eputs(s); + else + return write(fd, s, strlen(s)); + return 0; +} +EXPORT_SYMBOL(fputs); + +int tstc(void) +{ + return console->tstc(console); +} +EXPORT_SYMBOL(tstc); + +int getc(void) +{ + return console->getc(console); +} +EXPORT_SYMBOL(getc); + +#ifndef ARCH_HAS_CTRLC +/* test if ctrl-c was pressed */ +int ctrlc (void) +{ + if (tstc() && getc() == 3) + return 1; + return 0; +} +EXPORT_SYMBOL(ctrlc); +#endif /* ARCH_HAS_CTRC */ + +int console_register(struct console_device *newcdev) +{ + if (!console) + console = newcdev; + return 0; +}