]> rtime.felk.cvut.cz Git - jailhouse.git/blob - hypervisor/arch/arm/dbg-write.c
core, inmates: Move \r injection into console_write / arch_dbg_write
[jailhouse.git] / hypervisor / arch / arm / dbg-write.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 <jailhouse/entry.h>
14 #include <jailhouse/printk.h>
15 #include <jailhouse/processor.h>
16 #include <asm/debug.h>
17 #include <asm/platform.h>
18
19 static struct uart_chip uart;
20
21 void arch_dbg_write_init(void)
22 {
23         /* FIXME: parse a device tree */
24         uart.baudrate = 115200;
25         uart.fifo_enabled = true;
26         uart.virt_base = hypervisor_header.debug_uart_base;
27
28         uart_chip_init(&uart);
29 }
30
31 void arch_dbg_write(const char *msg)
32 {
33         char c = 0;
34
35         while (1) {
36                 if (c == '\n')
37                         c = '\r';
38                 else
39                         c = *msg++;
40                 if (!c)
41                         break;
42
43                 uart.wait(&uart);
44                 if (panic_in_progress && panic_cpu != phys_processor_id())
45                         break;
46                 uart.write(&uart, c);
47                 uart.busy(&uart);
48         }
49 }