diff --git a/inmates/lib/arm/Makefile b/inmates/lib/arm/Makefile index 620b95d7c..e859db2a7 100644 --- a/inmates/lib/arm/Makefile +++ b/inmates/lib/arm/Makefile @@ -16,9 +16,8 @@ always := lib.a ccflags-y := -ffunction-sections -lib-y := header.o gic.o printk.o timer.o +lib-y := header.o gic.o printk.o timer.o \ + uart-pl011.o uart-8250.o lib-y += ../string.o ../cmdline.o lib-$(CONFIG_ARM_GIC_V2) += gic-v2.o lib-$(CONFIG_ARM_GIC_V3) += gic-v3.o -lib-$(CONFIG_SERIAL_AMBA_PL011) += uart-pl011.o -lib-$(CONFIG_SERIAL_8250) += uart-8250.o diff --git a/inmates/lib/arm/printk.c b/inmates/lib/arm/printk.c index 11651f20b..9089fa108 100644 --- a/inmates/lib/arm/printk.c +++ b/inmates/lib/arm/printk.c @@ -15,7 +15,9 @@ #include #include -extern struct uart_chip uart_ops; +static struct uart_chip *chip = NULL; + +extern struct uart_chip uart_8250_ops, uart_pl011_ops; static void console_write(const char *msg) { @@ -29,11 +31,34 @@ static void console_write(const char *msg) if (!c) break; - uart_ops.wait(&uart_ops); - uart_ops.write(&uart_ops, c); + chip->wait(chip); + chip->write(chip, c); } } +static void console_init(void) +{ + char buf[32]; + const char *type; + + type = cmdline_parse_str("con-type", buf, sizeof(buf), "none"); + if (!strncmp(type, "8250", 4)) + chip = &uart_8250_ops; + else if (!strncmp(type, "PL011", 5)) + chip = &uart_pl011_ops; + + if (!chip) + return; + + chip->base = (void *)(unsigned long) cmdline_parse_int("con-base", 0); + chip->divider = cmdline_parse_int("con-divider", 0); + chip->gate_nr = cmdline_parse_int("con-gate_nr", 0); + chip->clock_reg = (void *)(unsigned long) + cmdline_parse_int("con-clock_reg", 0); + + chip->init(chip); +} + #include "../../../hypervisor/printk-core.c" void printk(const char *fmt, ...) @@ -42,11 +67,13 @@ void printk(const char *fmt, ...) va_list ap; if (!inited) { - uart_ops.base = UART_BASE; - uart_ops.init(&uart_ops); + console_init(); inited = true; } + if (!chip) + return; + va_start(ap, fmt); __vprintk(fmt, ap); diff --git a/inmates/lib/arm/uart-8250.c b/inmates/lib/arm/uart-8250.c index ad9e26829..aee8cb991 100644 --- a/inmates/lib/arm/uart-8250.c +++ b/inmates/lib/arm/uart-8250.c @@ -51,7 +51,7 @@ static void uart_write(struct uart_chip *chip, char c) mmio_write32(chip->base + UART_TX, c); } -struct uart_chip uart_ops = { +struct uart_chip uart_8250_ops = { .init = uart_init, .wait = uart_wait, .write = uart_write, diff --git a/inmates/lib/arm/uart-pl011.c b/inmates/lib/arm/uart-pl011.c index 8f661eb4e..64c434ce6 100644 --- a/inmates/lib/arm/uart-pl011.c +++ b/inmates/lib/arm/uart-pl011.c @@ -66,7 +66,7 @@ static void uart_write(struct uart_chip *chip, char c) mmio_write32(chip->base + UARTDR, c); } -struct uart_chip uart_ops = { +struct uart_chip uart_pl011_ops = { .init = uart_init, .wait = uart_wait, .write = uart_write, diff --git a/inmates/lib/arm64/Makefile b/inmates/lib/arm64/Makefile index 89c6cc949..ca4e30ca2 100644 --- a/inmates/lib/arm64/Makefile +++ b/inmates/lib/arm64/Makefile @@ -17,6 +17,5 @@ always := lib.a lib-y := header.o lib-y += ../arm/gic.o ../arm/printk.o ../arm/timer.o lib-y += ../string.o ../cmdline.o +lib-y += ../arm/uart-pl011.o ../arm/uart-8250.o lib-$(CONFIG_ARM_GIC_V2) += ../arm/gic-v2.o -lib-$(CONFIG_SERIAL_AMBA_PL011) += ../arm/uart-pl011.o -lib-$(CONFIG_SERIAL_8250) += ../arm/uart-8250.o