diff options
-rw-r--r-- | common/Kconfig | 14 | ||||
-rw-r--r-- | common/Makefile | 3 | ||||
-rw-r--r-- | common/command.c | 5 | ||||
-rw-r--r-- | common/console.c | 4 | ||||
-rw-r--r-- | common/console_simple.c | 117 |
5 files changed, 138 insertions, 5 deletions
diff --git a/common/Kconfig b/common/Kconfig index c0112a54e2..a2bb5e8c03 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -223,6 +223,20 @@ config TIMESTAMP 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 c5b47ea74d..f0555a628e 100644 --- a/common/Makefile +++ b/common/Makefile @@ -10,7 +10,8 @@ obj-$(CONFIG_AUTO_COMPLETE) += complete.o 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 d1b19c076f..c86b0058f5 100644 --- a/common/command.c +++ b/common/command.c @@ -33,13 +33,16 @@ #include <list.h> #include <init.h> #include <complete.h> +#include <linux/utsrelease.h> + +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 e47c46061e..7a94f57392 100644 --- a/common/console.c +++ b/common/console.c @@ -35,7 +35,6 @@ #include <kfifo.h> #include <module.h> #include <list.h> -#include <linux/utsrelease.h> LIST_HEAD(console_list); EXPORT_SYMBOL(console_list); @@ -44,8 +43,7 @@ EXPORT_SYMBOL(console_list); #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 0000000000..5a80f76242 --- /dev/null +++ b/common/console_simple.c @@ -0,0 +1,117 @@ +#include <config.h> +#include <common.h> +#include <fs.h> + +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; +} |