Skip to content

Commit

Permalink
core: arm: use the uart_chip structure instead of functions
Browse files Browse the repository at this point in the history
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 <ralf.ramsauer@oth-regensburg.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
  • Loading branch information
rralf authored and jan-kiszka committed Nov 29, 2016
1 parent f86f018 commit a974733
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
22 changes: 14 additions & 8 deletions hypervisor/arch/arm-common/dbg-write.c
Expand Up @@ -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)
{
Expand All @@ -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);
}
}

Expand All @@ -49,9 +51,13 @@ void arch_dbg_write_init(void)
if (con_type != JAILHOUSE_CON_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;
}
}
3 changes: 1 addition & 2 deletions hypervisor/arch/arm-common/include/asm/uart.h
Expand Up @@ -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_ */
12 changes: 5 additions & 7 deletions hypervisor/arch/arm-common/uart-8250.c
Expand Up @@ -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,
};
12 changes: 5 additions & 7 deletions hypervisor/arch/arm-common/uart-pl011.c
Expand Up @@ -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,
};

0 comments on commit a974733

Please sign in to comment.