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 | 3 +-- hypervisor/arch/arm-common/uart-8250.c | 12 +++++------- hypervisor/arch/arm-common/uart-pl011.c | 12 +++++------- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/hypervisor/arch/arm-common/dbg-write.c b/hypervisor/arch/arm-common/dbg-write.c index fed8492acc..ab5f2ba0f8 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); } } @@ -49,9 +51,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 77c8024a8d..c45296ee3d 100644 --- a/hypervisor/arch/arm-common/include/asm/uart.h +++ b/hypervisor/arch/arm-common/include/asm/uart.h @@ -21,11 +21,10 @@ 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); }; -void uart_chip_init(struct uart_chip *chip); - #endif /* !__ASSEMBLY__ */ #endif /* !JAILHOUSE_ASM_UART_H_ */ diff --git a/hypervisor/arch/arm-common/uart-8250.c b/hypervisor/arch/arm-common/uart-8250.c index e7c8d2d61d..1224d0332e 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 2716ea4da8..ba8560bb1a 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.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.
