]> rtime.felk.cvut.cz Git - jailhouse.git/blobdiff - hypervisor/arch/x86/dbg-write.c
Merge remote-tracking branch 'kiszka/master'
[jailhouse.git] / hypervisor / arch / x86 / dbg-write.c
index 77f7256edeb23d71bfca35e62afc5fd5b92db387..df6f45932405c2340328f90559e739d217c16c5c 100644 (file)
@@ -1,44 +1,50 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2013
+ * Copyright (c) Siemens AG, 2013-2016
+ * Copyright (c) Toshiba, 2016
  *
  * Authors:
  *  Jan Kiszka <jan.kiszka@siemens.com>
+ *  Daniel Sangorrin <daniel.sangorrin@toshiba.co.jp>
  *
  * This work is licensed under the terms of the GNU GPL, version 2.  See
  * 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)
@@ -52,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);
        }
 }
 
@@ -74,7 +80,7 @@ static u16 *vga_mem;
 
 static void vga_init(void)
 {
-       vga_mem = (u16 *)hypervisor_header.debug_console_base;
+       vga_mem = hypervisor_header.debug_console_base;
 }
 
 static void vga_scroll(void)
@@ -94,9 +100,6 @@ static void vga_write(const char *msg)
        unsigned int pos;
        u16 row, line;
 
-       if (!vga_mem)
-               return;
-
        /* panic_printk avoids locking 'printk_lock' due to a potential
           deadlock in case a crash occurs while holding it. For avoiding
           a data race between printk and panic_printk we take a local
@@ -135,13 +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)
 {
-       vga_write(msg);
-       if (!vga_mem)
+       if (vga_mem)
+               vga_write(msg);
+       else if (uart_base)
                uart_write(msg);
 }