diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-07-29 11:41:06 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-07-31 08:49:42 +0200 |
commit | ca8a4b0ff52a7505d3970c2619a309a52f7479fc (patch) | |
tree | aef68446454edad57f9ee72ff0d03f53569208e8 /pbl | |
parent | 37b8e171350d8803f3a637813c28fdd89a18d28a (diff) | |
download | barebox-ca8a4b0ff52a7505d3970c2619a309a52f7479fc.tar.gz barebox-ca8a4b0ff52a7505d3970c2619a309a52f7479fc.tar.xz |
PBL: console: Make independent of DEBUG_LL
With more stuff being done in PBL regular console support gets more and more
useful. This makes the PBL console independent of DEBUG_LL which is only
meant for early debugging but not regular output.
To use the regular PBL console a board must call pbl_set_putc() which stores
a pointer to the putc function to be used.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'pbl')
-rw-r--r-- | pbl/console.c | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/pbl/console.c b/pbl/console.c index a9859ad162..3574753d23 100644 --- a/pbl/console.c +++ b/pbl/console.c @@ -1,6 +1,47 @@ #include <common.h> #include <debug_ll.h> +static void (*__putc)(void *ctx, int c); +static void *putc_ctx; + +/** + * pbl_set_putc() - setup UART used for PBL console + * @putc: The putc function. + * @ctx: The context pointer passed back to putc + * + * This sets the putc function which is afterwards used to output + * characters in the PBL. + */ +void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx) +{ + __putc = putcf; + putc_ctx = ctx; +} + +void console_putc(unsigned int ch, char c) +{ + if (!__putc) + putc_ll(c); + else + __putc(putc_ctx, c); +} + +int console_puts(unsigned int ch, const char *str) +{ + int n = 0; + + while (*str) { + if (*str == '\n') + putc_ll('\r'); + + console_putc(CONSOLE_STDOUT, *str); + str++; + n++; + } + + return n; +} + int printf(const char *fmt, ...) { va_list args; @@ -11,7 +52,7 @@ int printf(const char *fmt, ...) i = vsprintf(printbuffer, fmt, args); va_end(args); - puts_ll(printbuffer); + console_puts(CONSOLE_STDOUT, printbuffer); return i; } @@ -26,7 +67,7 @@ int pr_print(int level, const char *fmt, ...) i = vsprintf(printbuffer, fmt, args); va_end(args); - puts_ll(printbuffer); + console_puts(CONSOLE_STDOUT, printbuffer); return i; } @@ -35,8 +76,3 @@ int ctrlc(void) { return 0; } - -void console_putc(unsigned int ch, char c) -{ - putc_ll(c); -} |