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
"8250" or "PL011"
dbg-base
UART-MMIO base address
dbg-divider
Optional: UART divider. Zero value means to skip initialisation.
Defaults to 0.
dbg-clock_reg
dbg-gate_nr
Optional: Clock Register and Gate Nr
Signed-off-by: Ralf Ramsauer <[email protected]>
---
inmates/lib/arm/Makefile | 5 ++---
inmates/lib/arm/printk.c | 37 ++++++++++++++++++++++++++++++++-----
inmates/lib/arm/uart-8250.c | 2 +-
inmates/lib/arm/uart-pl011.c | 2 +-
inmates/lib/arm64/Makefile | 3 +--
5 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/inmates/lib/arm/Makefile b/inmates/lib/arm/Makefile
index 620b95d7c9..e859db2a7f 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 11651f20bf..9fa5bf25fa 100644
--- a/inmates/lib/arm/printk.c
+++ b/inmates/lib/arm/printk.c
@@ -15,7 +15,9 @@
#include <uart.h>
#include <mach/uart.h>
-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 dbg_init(void)
+{
+ char buf[32];
+ const char *type;
+
+ type = cmdline_parse_str("dbg-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("dbg-base", 0);
+ chip->divider = cmdline_parse_int("dbg-divider", 0);
+ chip->gate_nr = cmdline_parse_int("dbg-gate_nr", 0);
+ chip->clock_reg = (void *)(unsigned long)
+ cmdline_parse_int("dbg-clock_reg", 0);
+
+ chip->init(chip);
+}
+
#include "../../../hypervisor/printk-core.c"
void printk(const char *fmt, ...)
@@ -42,10 +67,12 @@ void printk(const char *fmt, ...)
va_list ap;
if (!inited) {
- uart_ops.base = UART_BASE;
- uart_ops.init(&uart_ops);
+ dbg_init();
inited = true;
}
+
+ if (!chip)
+ return;
va_start(ap, fmt);
diff --git a/inmates/lib/arm/uart-8250.c b/inmates/lib/arm/uart-8250.c
index ad9e268292..aee8cb9914 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 8f661eb4e2..64c434ce63 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 89c6cc9499..ca4e30ca2c 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
--
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.