From d61d98cf800e3222e627f3a6518ebe8fae37c409 Mon Sep 17 00:00:00 2001 From: Wei6 Zhang Date: Tue, 19 Aug 2025 15:54:11 +0800 Subject: [PATCH] hv: use the CONFIG_SERIAL_REG_WIDTH Tracked-On: #8721 Signed-off-by: Wei6 Zhang --- hypervisor/debug/uart16550.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/hypervisor/debug/uart16550.c b/hypervisor/debug/uart16550.c index c917acd6b..ee0ef2597 100644 --- a/hypervisor/debug/uart16550.c +++ b/hypervisor/debug/uart16550.c @@ -28,26 +28,38 @@ struct console_uart { uint32_t reg_width; }; +#ifndef CONFIG_SERIAL_REG_WIDTH + #if defined(CONFIG_SERIAL_PIO_BASE) + #define CONFIG_SERIAL_REG_WIDTH 1 + #elif defined(CONFIG_SERIAL_PCI_BDF) + #define CONFIG_SERIAL_REG_WIDTH 4 + #elif defined(CONFIG_SERIAL_MMIO_BASE) + #define CONFIG_SERIAL_REG_WIDTH 1 + #else + #define CONFIG_SERIAL_REG_WIDTH 1 + #endif +#endif + #if defined(CONFIG_SERIAL_PIO_BASE) static struct console_uart uart = { - .enabled = true, - .type = PIO, - .port_address = CONFIG_SERIAL_PIO_BASE, - .reg_width = 1, + .enabled = true, + .type = PIO, + .port_address = CONFIG_SERIAL_PIO_BASE, + .reg_width = CONFIG_SERIAL_REG_WIDTH, }; #elif defined(CONFIG_SERIAL_PCI_BDF) static struct console_uart uart = { - .enabled = true, - .type = PCI, - .bdf.value = CONFIG_SERIAL_PCI_BDF, - .reg_width = 4, + .enabled = true, + .type = PCI, + .bdf.value = CONFIG_SERIAL_PCI_BDF, + .reg_width = CONFIG_SERIAL_REG_WIDTH, }; #elif defined(CONFIG_SERIAL_MMIO_BASE) static struct console_uart uart = { - .enabled = true, - .type = MMIO, - .mmio_base_vaddr = (void *)CONFIG_SERIAL_MMIO_BASE, - .reg_width = 1, + .enabled = true, + .type = MMIO, + .mmio_base_vaddr = (void *)CONFIG_SERIAL_MMIO_BASE, + .reg_width = CONFIG_SERIAL_REG_WIDTH, }; #endif