Everything is now in place, inmates are only missing the semantics of
struct jailhouse_console.

But this can be done easily by extending struct uart by a matching .flag
field that corresponds to jailhouse_console's .flag.

Passing con-type (et. al.) as inmate command line argument can still
override the configuration.

Signed-off-by: Ralf Ramsauer <[email protected]>
---
 inmates/lib/arm-common/include/uart.h   |  4 +++-
 inmates/lib/arm-common/printk.c         | 27 ++++++++-----------------
 inmates/lib/arm-common/uart-8250-8.c    |  5 ++++-
 inmates/lib/arm-common/uart-8250.c      |  5 ++++-
 inmates/lib/arm-common/uart-hscif.c     |  5 ++++-
 inmates/lib/arm-common/uart-imx.c       |  5 ++++-
 inmates/lib/arm-common/uart-jailhouse.c |  2 +-
 inmates/lib/arm-common/uart-mvebu.c     |  5 ++++-
 inmates/lib/arm-common/uart-pl011.c     |  5 ++++-
 inmates/lib/arm-common/uart-scifa.c     |  5 ++++-
 inmates/lib/arm-common/uart-xuartps.c   |  5 ++++-
 11 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/inmates/lib/arm-common/include/uart.h 
b/inmates/lib/arm-common/include/uart.h
index 25eaef5a..7b01cbd8 100644
--- a/inmates/lib/arm-common/include/uart.h
+++ b/inmates/lib/arm-common/include/uart.h
@@ -38,6 +38,7 @@
 
 struct uart_chip {
        const char *name;
+       const __u32 flags;
 
        void *base;
 
@@ -59,9 +60,10 @@ extern struct uart_chip *uart_array[];
 #define DECLARE_UART(__name) \
        extern struct uart_chip UART_OPS_NAME(__name)
 
-#define DEFINE_UART(__name, __description) \
+#define DEFINE_UART(__name, __description, __flags) \
        struct uart_chip UART_OPS_NAME(__name) = { \
                .name = __description, \
+               .flags = __flags, \
                .init = uart_##__name##_init, \
                .is_busy = uart_##__name##_is_busy, \
                .write = uart_##__name##_write, \
diff --git a/inmates/lib/arm-common/printk.c b/inmates/lib/arm-common/printk.c
index 3c4d6211..0b3f0a70 100644
--- a/inmates/lib/arm-common/printk.c
+++ b/inmates/lib/arm-common/printk.c
@@ -39,19 +39,6 @@
 #include <inmate.h>
 #include <stdarg.h>
 #include <uart.h>
-#include <mach.h>
-
-#ifndef CON_DIVIDER
-#define CON_DIVIDER 0
-#endif
-
-#ifndef CON_CLOCK_REG
-#define CON_CLOCK_REG 0
-#endif
-
-#ifndef CON_GATE_NR
-#define CON_GATE_NR 0
-#endif
 
 #define UART_IDLE_LOOPS                100
 
@@ -77,14 +64,16 @@ static void console_write(const char *msg)
 
 static void console_init(void)
 {
+       struct jailhouse_console *console = &comm_region->console;
        struct uart_chip **c;
        char buf[32];
        const char *type;
        unsigned int n;
 
-       type = cmdline_parse_str("con-type", buf, sizeof(buf), CON_TYPE);
+       type = cmdline_parse_str("con-type", buf, sizeof(buf), "");
        for (c = uart_array; *c; c++)
-               if (!strcmp(type, (*c)->name)) {
+               if (!strcmp(type, (*c)->name) ||
+                   (!*type && console->flags == (*c)->flags)) {
                        chip = *c;
                        break;
                }
@@ -93,11 +82,11 @@ static void console_init(void)
                return;
 
        chip->base = (void *)(unsigned long)
-               cmdline_parse_int("con-base", CON_BASE);
-       chip->divider = cmdline_parse_int("con-divider", CON_DIVIDER);
-       chip->gate_nr = cmdline_parse_int("con-gate-nr", CON_GATE_NR);
+               cmdline_parse_int("con-base", console->address);
+       chip->divider = cmdline_parse_int("con-divider", console->divider);
+       chip->gate_nr = cmdline_parse_int("con-gate-nr", console->gate_nr);
        chip->clock_reg = (void *)(unsigned long)
-               cmdline_parse_int("con-clock-reg", CON_CLOCK_REG);
+               cmdline_parse_int("con-clock-reg", console->clock_reg);
 
        chip->init(chip);
 
diff --git a/inmates/lib/arm-common/uart-8250-8.c 
b/inmates/lib/arm-common/uart-8250-8.c
index a109848d..36a0f5c4 100644
--- a/inmates/lib/arm-common/uart-8250-8.c
+++ b/inmates/lib/arm-common/uart-8250-8.c
@@ -75,4 +75,7 @@ static void uart_8250_8_write(struct uart_chip *chip, char c)
        mmio_write8(chip->base + UART_TX, c);
 }
 
-DEFINE_UART(8250_8, "8250-8");
+DEFINE_UART(8250_8, "8250-8",
+       JAILHOUSE_CON1_TYPE_8250 |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_1);
diff --git a/inmates/lib/arm-common/uart-8250.c 
b/inmates/lib/arm-common/uart-8250.c
index a0d97281..71b51a05 100644
--- a/inmates/lib/arm-common/uart-8250.c
+++ b/inmates/lib/arm-common/uart-8250.c
@@ -75,4 +75,7 @@ static void uart_8250_write(struct uart_chip *chip, char c)
        mmio_write32(chip->base + UART_TX, c);
 }
 
-DEFINE_UART(8250, "8250");
+DEFINE_UART(8250, "8250",
+       JAILHOUSE_CON1_TYPE_8250 |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_4);
diff --git a/inmates/lib/arm-common/uart-hscif.c 
b/inmates/lib/arm-common/uart-hscif.c
index c3c9aadb..80eb9076 100644
--- a/inmates/lib/arm-common/uart-hscif.c
+++ b/inmates/lib/arm-common/uart-hscif.c
@@ -80,4 +80,7 @@ static void uart_hscif_write(struct uart_chip *chip, char c)
                                 ~(HSCIF_HSFSR_TDFE | HSCIF_HSFSR_TEND));
 }
 
-DEFINE_UART(hscif, "HSCIF");
+DEFINE_UART(hscif, "HSCIF",
+       JAILHOUSE_CON1_TYPE_HSCIF |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_4);
diff --git a/inmates/lib/arm-common/uart-imx.c 
b/inmates/lib/arm-common/uart-imx.c
index 88db0813..2d03bc4f 100644
--- a/inmates/lib/arm-common/uart-imx.c
+++ b/inmates/lib/arm-common/uart-imx.c
@@ -56,4 +56,7 @@ static void uart_imx_write(struct uart_chip *chip, char c)
        mmio_write32(chip->base + UTXD, c);
 }
 
-DEFINE_UART(imx, "IMX");
+DEFINE_UART(imx, "IMX",
+       JAILHOUSE_CON1_TYPE_IMX |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_4);
diff --git a/inmates/lib/arm-common/uart-jailhouse.c 
b/inmates/lib/arm-common/uart-jailhouse.c
index 096ae85b..fbe009e6 100644
--- a/inmates/lib/arm-common/uart-jailhouse.c
+++ b/inmates/lib/arm-common/uart-jailhouse.c
@@ -53,4 +53,4 @@ static void uart_jailhouse_write(struct uart_chip *chip, char 
c)
        jailhouse_call_arg1(JAILHOUSE_HC_DEBUG_CONSOLE_PUTC, c);
 }
 
-DEFINE_UART(jailhouse, "JAILHOUSE");
+DEFINE_UART(jailhouse, "JAILHOUSE", JAILHOUSE_CON2_TYPE_ROOTPAGE);
diff --git a/inmates/lib/arm-common/uart-mvebu.c 
b/inmates/lib/arm-common/uart-mvebu.c
index c40b42eb..3fb4c830 100644
--- a/inmates/lib/arm-common/uart-mvebu.c
+++ b/inmates/lib/arm-common/uart-mvebu.c
@@ -57,4 +57,7 @@ static void uart_mvebu_write(struct uart_chip *chip, char c)
        mmio_write32(chip->base + UART_TSH, c);
 }
 
-DEFINE_UART(mvebu, "MVEBU");
+DEFINE_UART(mvebu, "MVEBU",
+       JAILHOUSE_CON1_TYPE_MVEBU |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_4);
diff --git a/inmates/lib/arm-common/uart-pl011.c 
b/inmates/lib/arm-common/uart-pl011.c
index 3bbf0f94..a84e30da 100644
--- a/inmates/lib/arm-common/uart-pl011.c
+++ b/inmates/lib/arm-common/uart-pl011.c
@@ -88,4 +88,7 @@ static void uart_pl011_write(struct uart_chip *chip, char c)
        mmio_write32(chip->base + UARTDR, c);
 }
 
-DEFINE_UART(pl011, "PL011");
+DEFINE_UART(pl011, "PL011",
+       JAILHOUSE_CON1_TYPE_PL011 |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_4);
diff --git a/inmates/lib/arm-common/uart-scifa.c 
b/inmates/lib/arm-common/uart-scifa.c
index 9d7939c4..36d80aa5 100644
--- a/inmates/lib/arm-common/uart-scifa.c
+++ b/inmates/lib/arm-common/uart-scifa.c
@@ -81,4 +81,7 @@ static void uart_scifa_write(struct uart_chip *chip, char c)
                                 ~(SCIFA_SCASSR_TDFE | SCIFA_SCASSR_TEND));
 }
 
-DEFINE_UART(scifa, "SCIFA");
+DEFINE_UART(scifa, "SCIFA",
+       JAILHOUSE_CON1_TYPE_SCIFA |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_4);
diff --git a/inmates/lib/arm-common/uart-xuartps.c 
b/inmates/lib/arm-common/uart-xuartps.c
index 92de9ddd..f82af76a 100644
--- a/inmates/lib/arm-common/uart-xuartps.c
+++ b/inmates/lib/arm-common/uart-xuartps.c
@@ -57,4 +57,7 @@ static void uart_xuartps_write(struct uart_chip *chip, char c)
        mmio_write32(chip->base + UART_FIFO, c);
 }
 
-DEFINE_UART(xuartps, "XUARTPS");
+DEFINE_UART(xuartps, "XUARTPS",
+       JAILHOUSE_CON1_TYPE_XUARTPS |
+       JAILHOUSE_CON1_ACCESS_MMIO |
+       JAILHOUSE_CON1_REGDIST_4);
-- 
2.17.0

-- 
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.

Reply via email to