summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-05-13 16:23:09 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2009-05-13 16:23:09 +0200
commit49321a5cd33cff11c5691c6b9744eacc0089f83d (patch)
treeb784f0bb01c4f0589afd7ec54374ec83ee54121a
parent2e8254e387ba898132ca80f80bc7ae7d918ba312 (diff)
downloadbarebox-49321a5cd33cff11c5691c6b9744eacc0089f83d.tar.gz
barebox-49321a5cd33cff11c5691c6b9744eacc0089f83d.tar.xz
console: buffer characters before console is initialized
instead of throwing all output away when the console is not initialized, buffer it in a kfifo and print it later when the first console gets initialized. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/console.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/common/console.c b/common/console.c
index 9f0524f834..c97a4f41e5 100644
--- a/common/console.c
+++ b/common/console.c
@@ -106,10 +106,23 @@ static int console_baudrate_set(struct device_d *dev, struct param_d *param,
return 0;
}
+static struct kfifo *console_input_buffer;
+static struct kfifo *console_output_buffer;
+
+int getc_buffer_flush(void)
+{
+ console_input_buffer = kfifo_alloc(1024);
+ console_output_buffer = kfifo_alloc(1024);
+ return 0;
+}
+
+postcore_initcall(getc_buffer_flush);
+
int console_register(struct console_device *newcdev)
{
struct device_d *dev = newcdev->dev;
int first = 0;
+ char ch;
if (newcdev->setbrg) {
newcdev->baudrate_param.set = console_baudrate_set;
@@ -140,6 +153,13 @@ int console_register(struct console_device *newcdev)
list_add_tail(&newcdev->list, &console_list);
+ if (console_output_buffer) {
+ while (kfifo_getc(console_output_buffer, &ch) == 0)
+ console_putc(CONSOLE_STDOUT, ch);
+ kfifo_free(console_output_buffer);
+ console_output_buffer = NULL;
+ }
+
#ifndef CONFIG_HAS_EARLY_INIT
if (first)
display_banner();
@@ -168,16 +188,6 @@ int getc_raw(void)
}
}
-static struct kfifo *console_input_buffer;
-
-int getc_buffer_flush(void)
-{
- console_input_buffer = kfifo_alloc(1024);
- return 0;
-}
-
-postcore_initcall(getc_buffer_flush);
-
int getc(void)
{
unsigned char ch;
@@ -239,6 +249,7 @@ void console_putc(unsigned int ch, char c)
switch (init) {
case CONSOLE_UNINITIALIZED:
+ kfifo_putc(console_output_buffer, c);
return;
#ifdef CONFIG_HAS_EARLY_INIT