From 62486b40f309a18209a862130c787caedfe3c5cb Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Tue, 26 Jan 2016 09:27:40 +0100 Subject: [PATCH] x86: Make debug UART port configurable via system config We already allow to enable a VGA console via the system config, so let's make the UART port configurable this way as well: phys_start will hold the port, and flags must not have JAILHOUSE_MEM_IO set, in order to differentiate us from the memory-mapped VGA console. And by leaving phys_start at 0, we can even turn off the console now. Signed-off-by: Jan Kiszka --- hypervisor/arch/x86/dbg-write.c | 49 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/hypervisor/arch/x86/dbg-write.c b/hypervisor/arch/x86/dbg-write.c index cdb6b85..df6f459 100644 --- a/hypervisor/arch/x86/dbg-write.c +++ b/hypervisor/arch/x86/dbg-write.c @@ -12,35 +12,39 @@ * the COPYING file in the top-level directory. */ +#include #include #include #include #include -#ifdef CONFIG_UART_OXPCIE952 -#define UART_BASE 0xe010 -#else -#define UART_BASE 0x3f8 -#endif -#define UART_TX 0x0 -#define UART_DLL 0x0 -#define UART_DLM 0x1 -#define UART_LCR 0x3 -#define UART_LCR_8N1 0x03 -#define UART_LCR_DLAB 0x80 -#define UART_LSR 0x5 -#define UART_LSR_THRE 0x20 +#define UART_TX 0x0 +#define UART_DLL 0x0 +#define UART_DLM 0x1 +#define UART_LCR 0x3 +#define UART_LCR_8N1 0x03 +#define UART_LCR_DLAB 0x80 +#define UART_LSR 0x5 +#define UART_LSR_THRE 0x20 + +static u16 uart_base; static void uart_init(void) { - outb(UART_LCR_DLAB, UART_BASE + UART_LCR); + if (system_config->debug_console.phys_start == 0 || + system_config->debug_console.flags & JAILHOUSE_MEM_IO) + return; + + uart_base = system_config->debug_console.phys_start; + + outb(UART_LCR_DLAB, uart_base + UART_LCR); #ifdef CONFIG_UART_OXPCIE952 - outb(0x22, UART_BASE + UART_DLL); + outb(0x22, uart_base + UART_DLL); #else - outb(1, UART_BASE + UART_DLL); + outb(1, uart_base + UART_DLL); #endif - outb(0, UART_BASE + UART_DLM); - outb(UART_LCR_8N1, UART_BASE + UART_LCR); + outb(0, uart_base + UART_DLM); + outb(UART_LCR_8N1, uart_base + UART_LCR); } static void uart_write(const char *msg) @@ -54,11 +58,11 @@ static void uart_write(const char *msg) c = *msg++; if (!c) break; - while (!(inb(UART_BASE + UART_LSR) & UART_LSR_THRE)) + while (!(inb(uart_base + UART_LSR) & UART_LSR_THRE)) cpu_relax(); if (panic_in_progress && panic_cpu != phys_processor_id()) break; - outb(c, UART_BASE + UART_TX); + outb(c, uart_base + UART_TX); } } @@ -134,14 +138,13 @@ static void vga_write(const char *msg) void arch_dbg_write_init(void) { vga_init(); - if (!vga_mem) - uart_init(); + uart_init(); } void arch_dbg_write(const char *msg) { if (vga_mem) vga_write(msg); - else + else if (uart_base) uart_write(msg); } -- 2.39.2