]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/printk.c
core, driver: Pass rounded-up core size in hypervisor header
[jailhouse.git] / hypervisor / printk.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2013
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <stdarg.h>
14 #include <jailhouse/printk.h>
15 #include <jailhouse/processor.h>
16 #include <jailhouse/string.h>
17 #include <asm/bitops.h>
18 #include <asm/spinlock.h>
19
20 volatile unsigned long panic_in_progress;
21 unsigned int panic_cpu = -1;
22
23 static DEFINE_SPINLOCK(printk_lock);
24
25 #define console_write(msg)      arch_dbg_write(msg)
26 #include "printk-core.c"
27
28 void printk(const char *fmt, ...)
29 {
30         va_list ap;
31
32         va_start(ap, fmt);
33
34         spin_lock(&printk_lock);
35         __vprintk(fmt, ap);
36         spin_unlock(&printk_lock);
37
38         va_end(ap);
39 }
40
41 void panic_printk(const char *fmt, ...)
42 {
43         unsigned int cpu_id = phys_processor_id();
44         va_list ap;
45
46         if (test_and_set_bit(0, &panic_in_progress) && panic_cpu != cpu_id)
47                 return;
48         panic_cpu = cpu_id;
49
50         va_start(ap, fmt);
51
52         __vprintk(fmt, ap);
53
54         va_end(ap);
55 }