* the COPYING file in the top-level directory.
*/
+#include <jailhouse/control.h>
#include <jailhouse/entry.h>
#include <jailhouse/printk.h>
#include <jailhouse/processor.h>
#include <asm/io.h>
-#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)
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);
}
}
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);
}