Skip to content

Commit a5ca305

Browse files
mgcaowenlingz
authored andcommitted
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 <minggui.cao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent f4beaf5 commit a5ca305

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

hypervisor/bsp/uefi/cmdline.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@ static const char * const cmd_list[] = {
1818
"uart=disabled", /* to disable uart */
1919
"uart=port@", /* like uart=port@0x3F8 */
2020
"uart=bdf@", /*like: uart=bdf@0:18.2, it is for ttyS2 */
21+
22+
/* format: vuart=ttySx@irqN, like vuart=ttyS1@irq6; better to unify
23+
* uart & vuart & SOS console the same one, and irq same with the native.
24+
* ttySx range (0-3), irqN (0-255)
25+
*/
26+
"vuart=ttyS",
2127
};
2228

2329
enum IDX_CMD {
2430
IDX_DISABLE_UART,
2531
IDX_PORT_UART,
2632
IDX_PCI_UART,
33+
IDX_SET_VUART,
2734

2835
IDX_MAX_CMD,
2936
};
@@ -55,6 +62,8 @@ static void handle_cmd(const char *cmd, int32_t len)
5562

5663
} else if (i == IDX_PCI_UART) {
5764
uart16550_set_property(true, false, (uint64_t)(cmd+tmp));
65+
} else if (i == IDX_SET_VUART) {
66+
vuart_set_property(cmd+tmp);
5867
}
5968
}
6069
}

hypervisor/debug/vuart.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,19 @@ bool hv_used_dbg_intx(uint8_t intx_pin)
411411
{
412412
return is_dbg_uart_enabled() && (intx_pin == vuart_com_irq);
413413
}
414+
415+
/* vuart=ttySx@irqN, like vuart=ttyS1@irq6 head "vuart=ttyS" is parsed */
416+
void vuart_set_property(const char *vuart_info)
417+
{
418+
const uint16_t com_map[4] = {0x3f8, 0x2F8, 0x3E8, 0x2E8}; /* map to ttyS0-ttyS3 */
419+
uint8_t com_idx;
420+
421+
com_idx = (uint8_t)(vuart_info[0] - '0');
422+
if (com_idx < 4) {
423+
vuart_com_base = com_map[com_idx];
424+
}
425+
426+
if (strncmp(vuart_info + 1, "@irq", 4) == 0) {
427+
vuart_com_irq = (uint8_t)strtol_deci(vuart_info + 5);
428+
}
429+
}

hypervisor/include/debug/vuart.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,5 @@ void vuart_console_tx_chars(struct acrn_vuart *vu);
7676
void vuart_console_rx_chars(struct acrn_vuart *vu);
7777

7878
bool hv_used_dbg_intx(uint8_t intx_pin);
79+
void vuart_set_property(const char *vuart_info);
7980
#endif /* VUART_H */

hypervisor/release/vuart.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ bool hv_used_dbg_intx(__unused uint8_t intx_pin)
2020
{
2121
return false;
2222
}
23+
24+
void vuart_set_property(__unused const char *vuart_info) {}

0 commit comments

Comments
 (0)