Without additional cmdline arguments, inmates will use an empty debug
output driver. Following cmdline arguments can be used to select a
specific driver:
dbg-type
not used for x86, as x86 only has one generic uart driver at the
moment. Should stay empty. Inmates do not support VGA output.
dbg-base
UART-{MMIO or PIO} base address. Defaults to 0x3f8
dbg-divider
Optional: UART divider. Like ARM, zero value means that no
initialisation is done. Defaults to 0.
Signed-off-by: Ralf Ramsauer <[email protected]>
---
inmates/demos/x86/32-bit-demo.c | 7 -------
inmates/demos/x86/apic-demo.c | 17 -----------------
inmates/demos/x86/e1000-demo.c | 8 --------
inmates/demos/x86/ioapic-demo.c | 8 --------
inmates/demos/x86/ivshmem-demo.c | 2 --
inmates/demos/x86/pci-demo.c | 8 --------
inmates/demos/x86/smp-demo.c | 8 --------
inmates/demos/x86/tiny-demo.c | 7 -------
inmates/lib/inmate_common.h | 1 -
inmates/lib/x86/printk.c | 31 ++++++++++++++++++++++---------
10 files changed, 22 insertions(+), 75 deletions(-)
diff --git a/inmates/demos/x86/32-bit-demo.c b/inmates/demos/x86/32-bit-demo.c
index e95c7e9de8..ebac4dbdf2 100644
--- a/inmates/demos/x86/32-bit-demo.c
+++ b/inmates/demos/x86/32-bit-demo.c
@@ -15,16 +15,9 @@
#include <inmate.h>
-#ifdef CONFIG_SERIAL_OXPCIE952
-#define UART_BASE 0xe000
-#else
-#define UART_BASE 0x2f8
-#endif
-
#define IA32_EFER 0xc0000080
void inmate_main(void)
{
- printk_uart_base = UART_BASE;
printk("This runs in 32-bit mode (EFER: %x)\n", read_msr(IA32_EFER));
}
diff --git a/inmates/demos/x86/apic-demo.c b/inmates/demos/x86/apic-demo.c
index e501203755..d032242320 100644
--- a/inmates/demos/x86/apic-demo.c
+++ b/inmates/demos/x86/apic-demo.c
@@ -14,15 +14,6 @@
#define POLLUTE_CACHE_SIZE (512 * 1024)
-#ifdef CONFIG_SERIAL_OXPCIE952
-#define UART_BASE 0xe010
-#else
-#define UART_BASE 0x3f8
-#endif
-#define UART_LSR 0x5
-#define UART_LSR_THRE 0x20
-#define UART_IDLE_LOOPS 100
-
#define APIC_TIMER_VECTOR 32
static unsigned long expected_time;
@@ -80,14 +71,6 @@ void inmate_main(void)
bool terminate = false;
unsigned long tsc_freq;
bool cache_pollution;
- unsigned int n;
-
- printk_uart_base = UART_BASE;
- do {
- for (n = 0; n < UART_IDLE_LOOPS; n++)
- if (!(inb(UART_BASE + UART_LSR) & UART_LSR_THRE))
- break;
- } while (n < UART_IDLE_LOOPS);
comm_region->cell_state = JAILHOUSE_CELL_RUNNING_LOCKED;
diff --git a/inmates/demos/x86/e1000-demo.c b/inmates/demos/x86/e1000-demo.c
index 33b353b8c0..6dc96b8cd7 100644
--- a/inmates/demos/x86/e1000-demo.c
+++ b/inmates/demos/x86/e1000-demo.c
@@ -17,12 +17,6 @@
#include <inmate.h>
-#ifdef CONFIG_SERIAL_OXPCIE952
-#define UART_BASE 0xe000
-#else
-#define UART_BASE 0x2f8
-#endif
-
#define E1000_REG_CTRL 0x0000
# define E1000_CTRL_LRST (1 << 3)
# define E1000_CTRL_SLU (1 << 6)
@@ -213,8 +207,6 @@ void inmate_main(void)
u64 bar;
int bdf;
- printk_uart_base = UART_BASE;
-
bdf = pci_find_device(PCI_ID_ANY, PCI_ID_ANY, 0);
if (bdf < 0) {
printk("No device found!\n");
diff --git a/inmates/demos/x86/ioapic-demo.c b/inmates/demos/x86/ioapic-demo.c
index 28023fd6e1..7cb491d8a7 100644
--- a/inmates/demos/x86/ioapic-demo.c
+++ b/inmates/demos/x86/ioapic-demo.c
@@ -22,12 +22,6 @@
#include <inmate.h>
-#ifdef CONFIG_SERIAL_OXPCIE952
-#define UART_BASE 0xe000
-#else
-#define UART_BASE 0x2f8
-#endif
-
#define PM1_STATUS 0
#define PM1_ENABLE 2
# define PM1_TMR_EN (1 << 0)
@@ -48,8 +42,6 @@ static void irq_handler(void)
void inmate_main(void)
{
- printk_uart_base = UART_BASE;
-
int_init();
int_set_handler(IRQ_VECTOR, irq_handler);
diff --git a/inmates/demos/x86/ivshmem-demo.c b/inmates/demos/x86/ivshmem-demo.c
index acfeb08cf4..82461178db 100644
--- a/inmates/demos/x86/ivshmem-demo.c
+++ b/inmates/demos/x86/ivshmem-demo.c
@@ -117,8 +117,6 @@ void inmate_main(void)
struct ivshmem_dev_data *d;
volatile char *shmem;
- printk_uart_base = UART_BASE;
-
int_init();
again:
diff --git a/inmates/demos/x86/pci-demo.c b/inmates/demos/x86/pci-demo.c
index 5f00d3173a..53e9b735e6 100644
--- a/inmates/demos/x86/pci-demo.c
+++ b/inmates/demos/x86/pci-demo.c
@@ -17,12 +17,6 @@
#include <inmate.h>
-#ifdef CONFIG_SERIAL_OXPCIE952
-#define UART_BASE 0xe000
-#else
-#define UART_BASE 0x2f8
-#endif
-
#define IRQ_VECTOR 32
#define HDA_GCTL 0x08
@@ -45,8 +39,6 @@ void inmate_main(void)
u64 bar;
int bdf;
- printk_uart_base = UART_BASE;
-
int_init();
int_set_handler(IRQ_VECTOR, irq_handler);
diff --git a/inmates/demos/x86/smp-demo.c b/inmates/demos/x86/smp-demo.c
index 29c509d3eb..d8dac073a7 100644
--- a/inmates/demos/x86/smp-demo.c
+++ b/inmates/demos/x86/smp-demo.c
@@ -12,12 +12,6 @@
#include <inmate.h>
-#ifdef CONFIG_SERIAL_OXPCIE952
-#define UART_BASE 0xe000
-#else
-#define UART_BASE 0x2f8
-#endif
-
#define IPI_VECTOR 40
static volatile bool done;
@@ -39,8 +33,6 @@ void inmate_main(void)
{
unsigned int n;
- printk_uart_base = UART_BASE;
-
main_cpu = cpu_id();
printk("SMP demo, primary CPU: %d\n", main_cpu);
diff --git a/inmates/demos/x86/tiny-demo.c b/inmates/demos/x86/tiny-demo.c
index 0c00d9177b..1671dd48c9 100644
--- a/inmates/demos/x86/tiny-demo.c
+++ b/inmates/demos/x86/tiny-demo.c
@@ -12,18 +12,11 @@
#include <inmate.h>
-#ifdef CONFIG_SERIAL_OXPCIE952
-#define UART_BASE 0xe000
-#else
-#define UART_BASE 0x2f8
-#endif
-
void inmate_main(void)
{
unsigned long long start, now;
int n;
- printk_uart_base = UART_BASE;
printk("Hello from this tiny cell!\n");
start = pm_timer_read();
diff --git a/inmates/lib/inmate_common.h b/inmates/lib/inmate_common.h
index 1a27b1ae6c..dd5d440b8a 100644
--- a/inmates/lib/inmate_common.h
+++ b/inmates/lib/inmate_common.h
@@ -35,7 +35,6 @@ typedef enum { true = 1, false = 0 } bool;
#define comm_region ((struct jailhouse_comm_region *)COMM_REGION_BASE)
-extern unsigned int printk_uart_base;
void printk(const char *fmt, ...);
void *memset(void *s, int c, unsigned long n);
diff --git a/inmates/lib/x86/printk.c b/inmates/lib/x86/printk.c
index d5451ebac4..9939e61158 100644
--- a/inmates/lib/x86/printk.c
+++ b/inmates/lib/x86/printk.c
@@ -13,6 +13,7 @@
#include <stdarg.h>
#include <inmate.h>
+#define UART_BASE 0x3f8
#define UART_TX 0x0
#define UART_DLL 0x0
#define UART_DLM 0x1
@@ -22,12 +23,15 @@
#define UART_LSR 0x5
#define UART_LSR_THRE 0x20
-unsigned int printk_uart_base;
+static unsigned int printk_uart_base;
static void uart_write(const char *msg)
{
char c = 0;
+ if (!printk_uart_base)
+ return;
+
while (1) {
if (c == '\n')
c = '\r';
@@ -44,21 +48,30 @@ static void uart_write(const char *msg)
#define console_write(msg) uart_write(msg)
#include "../../../hypervisor/printk-core.c"
+static void dbg_init(void)
+{
+ unsigned int divider;
+
+ printk_uart_base = cmdline_parse_int("dbg-base", UART_BASE);
+ divider = cmdline_parse_int("dbg-divider", 0);
+
+ if (!printk_uart_base || !divider)
+ return;
+
+ outb(UART_LCR_DLAB, printk_uart_base + UART_LCR);
+ outb(divider, printk_uart_base + UART_DLL);
+ outb(0, printk_uart_base + UART_DLM);
+ outb(UART_LCR_8N1, printk_uart_base + UART_LCR);
+}
+
void printk(const char *fmt, ...)
{
static bool inited;
va_list ap;
if (!inited) {
+ dbg_init();
inited = true;
- outb(UART_LCR_DLAB, printk_uart_base + UART_LCR);
-#ifdef CONFIG_SERIAL_OXPCIE952
- outb(0x22, printk_uart_base + UART_DLL);
-#else
- outb(1, printk_uart_base + UART_DLL);
-#endif
- outb(0, printk_uart_base + UART_DLM);
- outb(UART_LCR_8N1, printk_uart_base + UART_LCR);
}
va_start(ap, fmt);
--
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.