]> rtime.felk.cvut.cz Git - jailhouse.git/blob - inmates/lib/arm/printk.c
inmates: Avoid jailhouse/types.h
[jailhouse.git] / inmates / lib / arm / printk.c
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) ARM Limited, 2014
5  *
6  * Authors:
7  *  Jean-Philippe Brucker <jean-philippe.brucker@arm.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 <inmate.h>
14 #include <asm/debug.h>
15 #include <stdarg.h>
16
17 static struct uart_chip chip;
18
19 static void console_write(const char *msg)
20 {
21         char c = 0;
22
23         while (1) {
24                 if (c == '\n')
25                         c = '\r';
26                 else
27                         c = *msg++;
28                 if (!c)
29                         break;
30
31                 chip.wait(&chip);
32                 chip.write(&chip, c);
33                 chip.busy(&chip);
34         }
35 }
36
37 #include "../../../hypervisor/printk-core.c"
38
39 void printk(const char *fmt, ...)
40 {
41         static bool inited = false;
42         va_list ap;
43
44         if (!inited) {
45                 uart_chip_init(&chip);
46                 inited = true;
47         }
48
49         va_start(ap, fmt);
50
51         __vprintk(fmt, ap);
52
53         va_end(ap);
54 }