The new struct jailhouse_debug_output allows us to differentiate between different debug output types.
So far, differentiation has mainly been done by flags or by slicing the the base address of the console. This patch makes differentiation of debug output drivers more explicit. Furthermore, introduce an architecture independent dbg_write_stub() that serves as an empty debug output and choose it initially. arch_dbg_write is now a function pointer that can be set by specific architecture output drivers. Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/arch/arm-common/dbg-write.c | 26 ++++++++++++++++++-------- hypervisor/arch/x86/dbg-write.c | 18 +++++++++--------- hypervisor/arch/x86/include/asm/uart.h | 2 -- hypervisor/arch/x86/include/asm/vga.h | 4 ---- hypervisor/arch/x86/uart.c | 8 +------- hypervisor/arch/x86/vga.c | 5 ++--- hypervisor/include/jailhouse/cell-config.h | 1 + hypervisor/include/jailhouse/printk.h | 2 +- hypervisor/printk.c | 6 ++++++ 9 files changed, 38 insertions(+), 34 deletions(-) diff --git a/hypervisor/arch/arm-common/dbg-write.c b/hypervisor/arch/arm-common/dbg-write.c index ccaf23cc69..48f7a4ff9c 100644 --- a/hypervisor/arch/arm-common/dbg-write.c +++ b/hypervisor/arch/arm-common/dbg-write.c @@ -2,9 +2,11 @@ * Jailhouse, a Linux-based partitioning hypervisor * * Copyright (c) ARM Limited, 2014 + * Copyright (c) OTH Regensburg, 2016 * * Authors: * Jean-Philippe Brucker <[email protected]> + * Ralf Ramsauer <[email protected]> * * This work is licensed under the terms of the GNU GPL, version 2. See * the COPYING file in the top-level directory. @@ -18,14 +20,7 @@ static struct uart_chip uart; -void arch_dbg_write_init(void) -{ - uart.virt_base = hypervisor_header.debug_console_base; - - uart_chip_init(&uart); -} - -void arch_dbg_write(const char *msg) +static void arm_uart_write(const char *msg) { char c = 0; @@ -43,3 +38,18 @@ void arch_dbg_write(const char *msg) uart.write(&uart, c); } } + +void arch_dbg_write_init(void) +{ + unsigned char dbg_type = DBG_TYPE(system_config->debug_console.flags); + + if (!DBG_IS_MMIO(system_config->debug_console.flags)) + return; + + if (dbg_type != JAILHOUSE_DBG_TYPE_UART_ARM) + return; + + uart.virt_base = hypervisor_header.debug_console_base; + uart_chip_init(&uart); + arch_dbg_write = arm_uart_write; +} diff --git a/hypervisor/arch/x86/dbg-write.c b/hypervisor/arch/x86/dbg-write.c index d966d294fb..2b4676d065 100644 --- a/hypervisor/arch/x86/dbg-write.c +++ b/hypervisor/arch/x86/dbg-write.c @@ -17,14 +17,14 @@ void arch_dbg_write_init(void) { - vga_init(); - uart_init(); -} + unsigned char dbg_type = DBG_TYPE(system_config->debug_console.flags); -void arch_dbg_write(const char *msg) -{ - if (vga_mem) - vga_write(msg); - else if (uart_base) - uart_write(msg); + /* PIO / MMIO differentiation is done inside the driver code */ + if (dbg_type == JAILHOUSE_DBG_TYPE_UART_X86) { + uart_init(); + arch_dbg_write = uart_write; + } else if (dbg_type == JAILHOUSE_DBG_TYPE_VGA) { + vga_init(); + arch_dbg_write = vga_write; + } } diff --git a/hypervisor/arch/x86/include/asm/uart.h b/hypervisor/arch/x86/include/asm/uart.h index 8dcfa7eb06..a38b12c82e 100644 --- a/hypervisor/arch/x86/include/asm/uart.h +++ b/hypervisor/arch/x86/include/asm/uart.h @@ -10,7 +10,5 @@ * the COPYING file in the top-level directory. */ -extern u64 uart_base; - void uart_init(void); void uart_write(const char *msg); diff --git a/hypervisor/arch/x86/include/asm/vga.h b/hypervisor/arch/x86/include/asm/vga.h index b6ed6096dc..c67c8ba80e 100644 --- a/hypervisor/arch/x86/include/asm/vga.h +++ b/hypervisor/arch/x86/include/asm/vga.h @@ -10,9 +10,5 @@ * the COPYING file in the top-level directory. */ -#define VGA_LIMIT 0x100000 /* <1M means VGA */ - -extern u16 *vga_mem; - void vga_init(void); void vga_write(const char *msg); diff --git a/hypervisor/arch/x86/uart.c b/hypervisor/arch/x86/uart.c index 3e650150de..41e74e83f2 100644 --- a/hypervisor/arch/x86/uart.c +++ b/hypervisor/arch/x86/uart.c @@ -27,7 +27,7 @@ #define UART_LSR 0x5 #define UART_LSR_THRE 0x20 -u64 uart_base; +static u64 uart_base; static void uart_pio_out(unsigned int reg, u8 value) { @@ -56,13 +56,7 @@ void uart_init(void) { u32 flags = system_config->debug_console.flags; - if (system_config->debug_console.address == 0) - return; - if (DBG_IS_MMIO(flags)) { - if (system_config->debug_console.address < VGA_LIMIT) - return; /* VGA memory */ - uart_reg_out = uart_mmio32_out; uart_reg_in = uart_mmio32_in; uart_base = (u64)hypervisor_header.debug_console_base; diff --git a/hypervisor/arch/x86/vga.c b/hypervisor/arch/x86/vga.c index e784448c5d..ef196dc499 100644 --- a/hypervisor/arch/x86/vga.c +++ b/hypervisor/arch/x86/vga.c @@ -26,12 +26,11 @@ #define VGA_U16(c) ((u16)(c) | (u16)VGA_ATTRIBUTE) #define ASCII_NONPRINTABLE '?' -u16 *vga_mem; +static u16 *vga_mem; void vga_init(void) { - if (system_config->debug_console.address < VGA_LIMIT) - vga_mem = hypervisor_header.debug_console_base; + vga_mem = hypervisor_header.debug_console_base; } static void vga_scroll(void) diff --git a/hypervisor/include/jailhouse/cell-config.h b/hypervisor/include/jailhouse/cell-config.h index c1015c3d7b..0c5c8c033f 100644 --- a/hypervisor/include/jailhouse/cell-config.h +++ b/hypervisor/include/jailhouse/cell-config.h @@ -167,6 +167,7 @@ struct jailhouse_iommu { } __attribute__((packed)); /* Bits 0..3 are used to select the particular driver */ +#define JAILHOUSE_DBG_TYPE_NONE 0x0000 #define JAILHOUSE_DBG_TYPE_UART_X86 0x0001 #define JAILHOUSE_DBG_TYPE_UART_ARM 0x0002 #define JAILHOUSE_DBG_TYPE_VGA 0x0003 diff --git a/hypervisor/include/jailhouse/printk.h b/hypervisor/include/jailhouse/printk.h index 12401f0dc0..a506c0fddf 100644 --- a/hypervisor/include/jailhouse/printk.h +++ b/hypervisor/include/jailhouse/printk.h @@ -26,4 +26,4 @@ void __attribute__((format(printf, 1, 2))) panic_printk(const char *fmt, ...); #endif /* !CONFIG_TRACE_ERROR */ void arch_dbg_write_init(void); -void arch_dbg_write(const char *msg); +extern void (*arch_dbg_write)(const char *msg); diff --git a/hypervisor/printk.c b/hypervisor/printk.c index 61d2f7ae99..e8f5ffe289 100644 --- a/hypervisor/printk.c +++ b/hypervisor/printk.c @@ -23,6 +23,12 @@ static DEFINE_SPINLOCK(printk_lock); #define console_write(msg) arch_dbg_write(msg) #include "printk-core.c" +static void dbg_write_stub(const char *msg) +{ +} + +void (*arch_dbg_write)(const char *msg) = dbg_write_stub; + void printk(const char *fmt, ...) { va_list ap; -- 2.11.0.rc2 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
