Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / kernel / console.c
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>
6 #include <lwk/errno.h>
7 #include <arch/uaccess.h>
8
9 /**
10  * List of all registered consoles in the system.
11  *
12  * Kernel messages output via printk() will be written to
13  * all consoles in this list.
14  */
15 static LIST_HEAD(console_list);
16
17 /**
18  * Serializes access to the console.
19  */
20 static DEFINE_SPINLOCK(console_lock);
21
22 /**
23  * Holds a comma separated list of consoles to configure.
24  */
25 static char console_str[128];
26 param_string(console, console_str, sizeof(console_str));
27
28 /**
29  * Registers a new console.
30  */
31 void console_register(struct console *con)
32 {
33         list_add(&con->next, &console_list);
34 }
35
36 /**
37  * Writes a string to all registered consoles.
38  */
39 void console_write(const char *str)
40 {
41         struct console *con;
42         unsigned long flags;
43
44         spin_lock_irqsave(&console_lock, flags);
45         list_for_each_entry(con, &console_list, next)
46                 con->write(con, str);
47         spin_unlock_irqrestore(&console_lock, flags);
48 }
49
50 /**
51  * Initializes the console subsystem; called once at boot.
52  */
53 void console_init(void)
54 {
55         char *p, *con;
56         
57         // console_str contains comma separated list of console
58         // driver names.  Try to install a driver for each
59         // console name con.
60         p = con = console_str;
61         while (*p != '\0') {
62                 if (*p == ',') {
63                         *p = '\0'; // null terminate con
64                         if (driver_init_by_name(con))
65                                 printk(KERN_WARNING
66                                        "failed to install console=%s\n", con);
67                         con = p + 1;
68                 }
69                 ++p;
70         }
71
72         // Catch the last one
73         if (p != console_str)
74                 driver_init_by_name(con);
75 }
76