1 #include <lwk/kernel.h>
2 #include <lwk/console.h>
3 #include <lwk/spinlock.h>
4 #include <lwk/params.h>
5 #include <lwk/driver.h>
7 #include <arch/uaccess.h>
10 * List of all registered consoles in the system.
12 * Kernel messages output via printk() will be written to
13 * all consoles in this list.
15 static LIST_HEAD(console_list);
18 * Serializes access to the console.
20 static DEFINE_SPINLOCK(console_lock);
23 * Holds a comma separated list of consoles to configure.
25 static char console_str[128];
26 param_string(console, console_str, sizeof(console_str));
29 * Registers a new console.
31 void console_register(struct console *con)
33 list_add(&con->next, &console_list);
37 * Writes a string to all registered consoles.
39 void console_write(const char *str)
44 spin_lock_irqsave(&console_lock, flags);
45 list_for_each_entry(con, &console_list, next)
47 spin_unlock_irqrestore(&console_lock, flags);
51 * Initializes the console subsystem; called once at boot.
53 void console_init(void)
57 // console_str contains comma separated list of console
58 // driver names. Try to install a driver for each
60 p = con = console_str;
63 *p = '\0'; // null terminate con
64 if (driver_init_by_name(con))
66 "failed to install console=%s\n", con);
74 driver_init_by_name(con);