From a5ca305cf62a41751fbbe0bebc41ac0d8b992601 Mon Sep 17 00:00:00 2001 From: Minggui Cao Date: Tue, 25 Dec 2018 10:06:37 +0800 Subject: [PATCH] HV: add API to change vuart base & irq config 1. add an API to support vuart COM base and irq configured; 2. add the HV cmd to be parsed for vuart COM base & irq. Tracked-On: #2170 Signed-off-by: Minggui Cao Acked-by: Eddie Dong --- hypervisor/bsp/uefi/cmdline.c | 9 +++++++++ hypervisor/debug/vuart.c | 16 ++++++++++++++++ hypervisor/include/debug/vuart.h | 1 + hypervisor/release/vuart.c | 2 ++ 4 files changed, 28 insertions(+) diff --git a/hypervisor/bsp/uefi/cmdline.c b/hypervisor/bsp/uefi/cmdline.c index c7df602b9..96f2ed11e 100644 --- a/hypervisor/bsp/uefi/cmdline.c +++ b/hypervisor/bsp/uefi/cmdline.c @@ -18,12 +18,19 @@ static const char * const cmd_list[] = { "uart=disabled", /* to disable uart */ "uart=port@", /* like uart=port@0x3F8 */ "uart=bdf@", /*like: uart=bdf@0:18.2, it is for ttyS2 */ + + /* format: vuart=ttySx@irqN, like vuart=ttyS1@irq6; better to unify + * uart & vuart & SOS console the same one, and irq same with the native. + * ttySx range (0-3), irqN (0-255) + */ + "vuart=ttyS", }; enum IDX_CMD { IDX_DISABLE_UART, IDX_PORT_UART, IDX_PCI_UART, + IDX_SET_VUART, IDX_MAX_CMD, }; @@ -55,6 +62,8 @@ static void handle_cmd(const char *cmd, int32_t len) } else if (i == IDX_PCI_UART) { uart16550_set_property(true, false, (uint64_t)(cmd+tmp)); + } else if (i == IDX_SET_VUART) { + vuart_set_property(cmd+tmp); } } } diff --git a/hypervisor/debug/vuart.c b/hypervisor/debug/vuart.c index 7bf16f5c9..7c278f08d 100644 --- a/hypervisor/debug/vuart.c +++ b/hypervisor/debug/vuart.c @@ -411,3 +411,19 @@ bool hv_used_dbg_intx(uint8_t intx_pin) { return is_dbg_uart_enabled() && (intx_pin == vuart_com_irq); } + +/* vuart=ttySx@irqN, like vuart=ttyS1@irq6 head "vuart=ttyS" is parsed */ +void vuart_set_property(const char *vuart_info) +{ + const uint16_t com_map[4] = {0x3f8, 0x2F8, 0x3E8, 0x2E8}; /* map to ttyS0-ttyS3 */ + uint8_t com_idx; + + com_idx = (uint8_t)(vuart_info[0] - '0'); + if (com_idx < 4) { + vuart_com_base = com_map[com_idx]; + } + + if (strncmp(vuart_info + 1, "@irq", 4) == 0) { + vuart_com_irq = (uint8_t)strtol_deci(vuart_info + 5); + } +} diff --git a/hypervisor/include/debug/vuart.h b/hypervisor/include/debug/vuart.h index a87a00de8..ff6be6b5c 100644 --- a/hypervisor/include/debug/vuart.h +++ b/hypervisor/include/debug/vuart.h @@ -76,4 +76,5 @@ void vuart_console_tx_chars(struct acrn_vuart *vu); void vuart_console_rx_chars(struct acrn_vuart *vu); bool hv_used_dbg_intx(uint8_t intx_pin); +void vuart_set_property(const char *vuart_info); #endif /* VUART_H */ diff --git a/hypervisor/release/vuart.c b/hypervisor/release/vuart.c index 74926e615..b18638ad2 100644 --- a/hypervisor/release/vuart.c +++ b/hypervisor/release/vuart.c @@ -20,3 +20,5 @@ bool hv_used_dbg_intx(__unused uint8_t intx_pin) { return false; } + +void vuart_set_property(__unused const char *vuart_info) {}