summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-11-16 14:00:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-16 14:00:45 +0100
commitcce8e6ed412ea79f7a1c256a4320e9fce7851d2c (patch)
treebc99320b1435c7244cb233342679a1a13d805fa0 /common
parentee69df5a108a4ed09e113a9d0b17a73c2be268a5 (diff)
parentba526393dd7f29e829a2124a092233aad45114e8 (diff)
downloadbarebox-cce8e6ed412ea79f7a1c256a4320e9fce7851d2c.tar.gz
barebox-cce8e6ed412ea79f7a1c256a4320e9fce7851d2c.tar.xz
Merge branch 'for-next/console'
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig35
-rw-r--r--common/console.c59
-rw-r--r--common/console_simple.c5
3 files changed, 64 insertions, 35 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 9210739ee4..107774c66d 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -468,17 +468,19 @@ config CONSOLE_FULL
prompt "Enable full console support"
help
This option enables full console support capable of
- handling multiple consoles.
+ handling multiple consoles. Also the full console support
+ is able to store the output which comes before a console
+ is registered in a circular buffer which will be printed
+ once the first console is registered. Recommended for most
+ usecases.
-config CONSOLE_SIMPLE
- bool
- default y
- depends on !CONSOLE_FULL
+choice
+ prompt "Console activation strategy"
+ depends on CONSOLE_FULL
+ default CONSOLE_ACTIVATE_FIRST
config CONSOLE_ACTIVATE_FIRST
- depends on CONSOLE_FULL
bool
- default y
prompt "activate first console on startup"
help
Normally on startup all consoles are disabled, so you won't
@@ -486,13 +488,28 @@ config CONSOLE_ACTIVATE_FIRST
enables the first console.
config CONSOLE_ACTIVATE_ALL
- depends on CONSOLE_FULL
- depends on !CONSOLE_ACTIVATE_FIRST
bool
prompt "activate all consoles on startup"
help
Enabling this options activates all consoles on startup, so
you will get output and a prompt on all consoles simultaneously.
+ Only the first registered console will have the full startup
+ log though.
+
+config CONSOLE_ACTIVATE_NONE
+ prompt "leave all consoles disabled"
+ bool
+ help
+ Leave all consoles disabled on startup. Board code or environment
+ is responsible for enabling a console. Otherwise you'll get a working
+ barebox, you just won't see anything.
+
+endchoice
+
+config CONSOLE_SIMPLE
+ bool
+ default y
+ depends on !CONSOLE_FULL
config PARTITION
bool
diff --git a/common/console.c b/common/console.c
index 3dd964cf6f..fdd5f422dc 100644
--- a/common/console.c
+++ b/common/console.c
@@ -32,6 +32,7 @@
#include <poller.h>
#include <linux/list.h>
#include <linux/stringify.h>
+#include <debug_ll.h>
LIST_HEAD(console_list);
EXPORT_SYMBOL(console_list);
@@ -44,6 +45,16 @@ EXPORT_SYMBOL(console_list);
static int initialized = 0;
+#define CONSOLE_BUFFER_SIZE 1024
+
+static char console_input_buffer[CONSOLE_BUFFER_SIZE];
+static char console_output_buffer[CONSOLE_BUFFER_SIZE];
+
+static struct kfifo __console_input_fifo;
+static struct kfifo __console_output_fifo;
+static struct kfifo *console_input_fifo = &__console_input_fifo;
+static struct kfifo *console_output_fifo = &__console_output_fifo;
+
static int console_std_set(struct device_d *dev, struct param_d *param,
const char *val)
{
@@ -74,6 +85,17 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
dev_param_set_generic(dev, param, active);
+ if (initialized < CONSOLE_INIT_FULL) {
+ char ch;
+ initialized = CONSOLE_INIT_FULL;
+ PUTS_LL("Switch to console [");
+ PUTS_LL(dev_name(dev));
+ PUTS_LL("]\n");
+ barebox_banner();
+ while (kfifo_getc(console_output_fifo, &ch) == 0)
+ console_putc(CONSOLE_STDOUT, ch);
+ }
+
return 0;
}
@@ -108,16 +130,6 @@ static int console_baudrate_set(struct device_d *dev, struct param_d *param,
return 0;
}
-#define CONSOLE_BUFFER_SIZE 1024
-
-static char console_input_buffer[CONSOLE_BUFFER_SIZE];
-static char console_output_buffer[CONSOLE_BUFFER_SIZE];
-
-static struct kfifo __console_input_fifo;
-static struct kfifo __console_output_fifo;
-static struct kfifo *console_input_fifo = &__console_input_fifo;
-static struct kfifo *console_output_fifo = &__console_output_fifo;
-
static void console_init_early(void)
{
kfifo_init(console_input_fifo, console_input_buffer,
@@ -131,8 +143,7 @@ static void console_init_early(void)
int console_register(struct console_device *newcdev)
{
struct device_d *dev = &newcdev->class_dev;
- int first = 0;
- char ch;
+ int activate = 0;
if (initialized == CONSOLE_UNINITIALIZED)
console_init_early();
@@ -150,23 +161,20 @@ int console_register(struct console_device *newcdev)
dev_add_param(dev, "active", console_std_set, NULL, 0);
- initialized = CONSOLE_INIT_FULL;
-#ifdef CONFIG_CONSOLE_ACTIVATE_ALL
- dev_set_param(dev, "active", "ioe");
-#endif
-#ifdef CONFIG_CONSOLE_ACTIVATE_FIRST
- if (list_empty(&console_list)) {
- first = 1;
- dev_set_param(dev, "active", "ioe");
+ if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_FIRST)) {
+ if (list_empty(&console_list))
+ activate = 1;
+ } else if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_ALL)) {
+ activate = 1;
}
-#endif
+
+ if (newcdev->dev && of_device_is_stdout_path(newcdev->dev))
+ activate = 1;
list_add_tail(&newcdev->list, &console_list);
- while (kfifo_getc(console_output_fifo, &ch) == 0)
- console_putc(CONSOLE_STDOUT, ch);
- if (first)
- barebox_banner();
+ if (activate)
+ dev_set_param(dev, "active", "ioe");
return 0;
}
@@ -276,6 +284,7 @@ void console_putc(unsigned int ch, char c)
case CONSOLE_INITIALIZED_BUFFER:
kfifo_putc(console_output_fifo, c);
+ PUTC_LL(c);
return;
case CONSOLE_INIT_FULL:
diff --git a/common/console_simple.c b/common/console_simple.c
index 7ad88d9a99..a4d4315c72 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -2,6 +2,7 @@
#include <common.h>
#include <fs.h>
#include <errno.h>
+#include <debug_ll.h>
LIST_HEAD(console_list);
EXPORT_SYMBOL(console_list);
@@ -85,8 +86,10 @@ EXPORT_SYMBOL(console_puts);
void console_putc(unsigned int ch, char c)
{
- if (!console)
+ if (!console) {
+ PUTC_LL(c);
return;
+ }
console->putc(console, c);
if (c == '\n')