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 / printk.c
1 #include <lwk/kernel.h>
2 #include <lwk/console.h>
3 #include <lwk/smp.h>
4
5 /**
6  * Prints a message to the console.
7  */
8 int printk(const char *fmt, ...)
9 {
10         va_list args;
11         va_start(args, fmt);
12         int rc = vprintk( fmt, args );
13         va_end(args);
14         return rc;
15 }
16
17
18 int printk_print_cpu_number;
19
20
21 int
22 vprintk(
23         const char *            fmt,
24         va_list                 args
25 )
26 {
27         int len;
28         char buf[1024];
29         char *p = buf;
30         int remain = sizeof(buf);
31
32         /* Start with a NULL terminated string */
33         *p = '\0';
34
35         /* Tack on the logical CPU ID */
36         if( printk_print_cpu_number )
37         {
38                 len = sprintf(p, "[%u]:", this_cpu);
39                 p      += len;
40                 remain -= len;
41         }
42
43         /* Construct the string... */
44         len = vscnprintf(p, remain, fmt, args);
45
46         /* Pass the string to the console subsystem */
47         console_write(buf);
48
49         /* Return number of characters printed */
50         return len;
51 }
52