9
0
Fork 0

Merge branch 'for-next/console'

This commit is contained in:
Sascha Hauer 2012-11-16 14:00:45 +01:00
commit cce8e6ed41
6 changed files with 94 additions and 36 deletions

View File

@ -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

View File

@ -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:

View File

@ -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')

View File

@ -714,11 +714,15 @@ static void __of_probe(struct device_node *node)
__of_probe(n);
}
struct device_node *of_chosen;
int of_probe(void)
{
if(!root_node)
return -ENODEV;
of_chosen = of_find_node_by_path("/chosen");
__of_probe(root_node);
return 0;
@ -803,3 +807,22 @@ int of_parse_dtb(struct fdt_header *fdt)
return 0;
}
int of_device_is_stdout_path(struct device_d *dev)
{
struct device_node *dn;
const char *name;
name = of_get_property(of_chosen, "linux,stdout-path", NULL);
if (name == NULL)
return 0;
dn = of_find_node_by_path(name);
if (!dn)
return 0;
if (dn == dev->device_node)
return 1;
return 0;
}

View File

@ -30,7 +30,7 @@
ch += (ch >= 10) ? 'a' - 10 : '0';\
PUTC_LL (ch); }})
static __inline__ void PUTS_LL(char * str)
static __inline__ void PUTS_LL(const char * str)
{
while (*str) {
if (*str == '\n') {

View File

@ -114,6 +114,7 @@ int of_parse_partitions(const char *cdevname,
struct device_node *of_get_root_node(void);
int of_alias_get_id(struct device_node *np, const char *stem);
int of_device_is_stdout_path(struct device_d *dev);
#else
static inline int of_parse_partitions(const char *cdevname,
struct device_node *node)
@ -130,6 +131,11 @@ static inline int of_alias_get_id(struct device_node *np, const char *stem)
{
return -ENOENT;
}
static inline int of_device_is_stdout_path(struct device_d *dev)
{
return 0;
}
#endif
#endif /* __OF_H */