Also add an initialisation function to struct uart_chip. In this way, all operations are now encapsulated in the structure.
Signed-off-by: Ralf Ramsauer <[email protected]> --- hypervisor/arch/arm-common/dbg-write.c | 22 ++++++++++++++-------- hypervisor/arch/arm-common/include/asm/uart.h | 1 + hypervisor/arch/arm-common/uart-8250.c | 12 +++++------- hypervisor/arch/arm-common/uart-pl011.c | 12 +++++------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/hypervisor/arch/arm-common/dbg-write.c b/hypervisor/arch/arm-common/dbg-write.c index fb40f804e5b2..9c091d0d0be5 100644 --- a/hypervisor/arch/arm-common/dbg-write.c +++ b/hypervisor/arch/arm-common/dbg-write.c @@ -18,7 +18,9 @@ #include <jailhouse/processor.h> #include <asm/uart.h> -static struct uart_chip uart; +extern struct uart_chip uart_ops; + +static struct uart_chip *uart = NULL; static void arm_uart_write(const char *msg) { @@ -32,10 +34,10 @@ static void arm_uart_write(const char *msg) if (!c) break; - uart.wait(&uart); + uart->wait(uart); if (panic_in_progress && panic_cpu != phys_processor_id()) break; - uart.write(&uart, c); + uart->write(uart, c); } } @@ -50,9 +52,13 @@ void arch_dbg_write_init(void) if (dbg_type != JAILHOUSE_DBG_TYPE_UART_ARM) return; - uart.debug_console = &system_config->debug_console; - uart.virt_clock_reg = hypervisor_header.debug_clock_reg; - uart.virt_base = hypervisor_header.debug_console_base; - uart_chip_init(&uart); - arch_dbg_write = arm_uart_write; + uart = &uart_ops; + + if (uart) { + uart->debug_console = &system_config->debug_console; + uart->virt_clock_reg = hypervisor_header.debug_clock_reg; + uart->virt_base = hypervisor_header.debug_console_base; + uart->init(uart); + arch_dbg_write = arm_uart_write; + } } diff --git a/hypervisor/arch/arm-common/include/asm/uart.h b/hypervisor/arch/arm-common/include/asm/uart.h index 77c8024a8dec..b781a8a5c262 100644 --- a/hypervisor/arch/arm-common/include/asm/uart.h +++ b/hypervisor/arch/arm-common/include/asm/uart.h @@ -21,6 +21,7 @@ struct uart_chip { void *virt_clock_reg; struct jailhouse_debug_console *debug_console; + void (*init)(struct uart_chip*); void (*wait)(struct uart_chip *); void (*write)(struct uart_chip *, char c); }; diff --git a/hypervisor/arch/arm-common/uart-8250.c b/hypervisor/arch/arm-common/uart-8250.c index e7c8d2d61d7d..1224d0332e30 100644 --- a/hypervisor/arch/arm-common/uart-8250.c +++ b/hypervisor/arch/arm-common/uart-8250.c @@ -55,10 +55,8 @@ static void uart_write(struct uart_chip *chip, char c) mmio_write32(chip->virt_base + UART_TX, c); } -void uart_chip_init(struct uart_chip *chip) -{ - chip->wait = uart_wait; - chip->write = uart_write; - - uart_init(chip); -} +struct uart_chip uart_ops = { + .wait = uart_wait, + .write = uart_write, + .init = uart_init, +}; diff --git a/hypervisor/arch/arm-common/uart-pl011.c b/hypervisor/arch/arm-common/uart-pl011.c index 2716ea4da8f2..ba8560bb1a5a 100644 --- a/hypervisor/arch/arm-common/uart-pl011.c +++ b/hypervisor/arch/arm-common/uart-pl011.c @@ -67,10 +67,8 @@ static void uart_write(struct uart_chip *chip, char c) mmio_write32(chip->virt_base + UARTDR, c); } -void uart_chip_init(struct uart_chip *chip) -{ - chip->wait = uart_wait; - chip->write = uart_write; - - uart_init(chip); -} +struct uart_chip uart_ops = { + .wait = uart_wait, + .write = uart_write, + .init = uart_init, +}; -- 2.10.2 -- 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.
