HV: fix bug adapt uart mmio to bdf for HV cmdline

now PCI uart changed from MMIO configure to BDF configure,
it need change this interface too; this interface is used
to dynamically configure debug uart by HV command line.

Tracked-On: #2031
Signed-off-by: Minggui Cao <minggui.cao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Minggui Cao 2018-12-07 19:39:59 +08:00 committed by wenlingz
parent 23c2166aa9
commit b319e654c1
2 changed files with 17 additions and 14 deletions

View File

@ -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));
}
}
}

View File

@ -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)