diff --git a/hypervisor/bsp/uefi/cmdline.c b/hypervisor/bsp/uefi/cmdline.c index 68dd3dfdc..c7df602b9 100644 --- a/hypervisor/bsp/uefi/cmdline.c +++ b/hypervisor/bsp/uefi/cmdline.c @@ -17,13 +17,13 @@ static const char * const cmd_list[] = { "uart=disabled", /* to disable uart */ "uart=port@", /* like uart=port@0x3F8 */ - "uart=mmio@", /*like: uart=mmio@0xFC000000 */ + "uart=bdf@", /*like: uart=bdf@0:18.2, it is for ttyS2 */ }; enum IDX_CMD { IDX_DISABLE_UART, IDX_PORT_UART, - IDX_MMIO_UART, + IDX_PCI_UART, IDX_MAX_CMD, }; @@ -45,19 +45,16 @@ static void handle_cmd(const char *cmd, int32_t len) if (i == IDX_DISABLE_UART) { /* set uart disabled*/ uart16550_set_property(false, false, 0UL); - } else if ((i == IDX_PORT_UART) || (i == IDX_MMIO_UART)) { + } else if (i == IDX_PORT_UART) { uint64_t addr = strtoul_hex(cmd + tmp); - - dev_dbg(ACRN_DBG_PARSE, "uart addr=0x%llx", addr); - - if (i == IDX_PORT_UART) { - if (addr > MAX_PORT) - addr = DEFAULT_UART_PORT; - - uart16550_set_property(true, true, addr); - } else { - uart16550_set_property(true, false, addr); + if (addr > MAX_PORT) { + addr = DEFAULT_UART_PORT; } + + uart16550_set_property(true, true, addr); + + } else if (i == IDX_PCI_UART) { + uart16550_set_property(true, false, (uint64_t)(cmd+tmp)); } } } diff --git a/hypervisor/debug/uart16550.c b/hypervisor/debug/uart16550.c index cda1663a9..a023f1157 100644 --- a/hypervisor/debug/uart16550.c +++ b/hypervisor/debug/uart16550.c @@ -214,7 +214,13 @@ void uart16550_set_property(bool enabled, bool port_mapped, uint64_t base_addr) { uart_enabled = enabled; serial_port_mapped = port_mapped; - uart_base_address = base_addr; + + if (port_mapped) { + uart_base_address = base_addr; + } else { + const char *bdf = (const char *)base_addr; + strncpy_s(pci_bdf_info, MAX_BDF_LEN, bdf, MAX_BDF_LEN); + } } bool is_pci_dbg_uart(union pci_bdf bdf_value)