Skip to content

Commit 3c92d7b

Browse files
conghuic23acrnsi
authored andcommitted
HV: vuart: refine vuart config
Add vuart config in acrn_vm_config struct, support configuring 2 vuarts for each VM. The first vuart is used to work as VM's console. The second vuart is used to connect to other VM's vuart. When the port base for a vuart is set to 0, hypervisor will not create this vuart. Tracked-On: #2987 Signed-off-by: Victor Sun <victor.sun@intel.com> Signed-off-by: Conghui Chen <conghui.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 1234f4f commit 3c92d7b

File tree

5 files changed

+87
-4
lines changed

5 files changed

+87
-4
lines changed

hypervisor/arch/x86/Kconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ config SERIAL_PIO_BASE
150150

151151
config COM_BASE
152152
hex "Base address of the vuart port"
153-
depends on !RELEASE
154-
default 0x3f8
153+
default 0 if RELEASE
154+
default 0x3f8 if !RELEASE
155155
help
156156
Base address of the vuart port.
157157

158158
config COM_IRQ
159159
int "IRQ of the vuart port"
160-
depends on !RELEASE
161-
default 4
160+
default 0 if RELEASE
161+
default 4 if !RELEASE
162162
help
163163
IRQ of the vuart port.
164164

hypervisor/include/arch/x86/vm_config.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <vm_configurations.h>
1616

1717
#define PLUG_CPU(n) (1U << (n))
18+
#define MAX_VUART_NUM_PER_VM 2U
1819

1920
/*
2021
* PRE_LAUNCHED_VM is launched by ACRN hypervisor, with LAPIC_PT;
@@ -33,6 +34,32 @@ struct acrn_vm_mem_config {
3334
uint64_t size; /* VM memory size configuration */
3435
};
3536

37+
struct target_vuart {
38+
uint8_t vm_id; /* target VM id */
39+
uint8_t vuart_id; /* target vuart index in a VM */
40+
};
41+
42+
enum vuart_type {
43+
VUART_LEGACY_PIO = 0, /* legacy PIO vuart */
44+
VUART_PCI, /* PCI vuart, may removed */
45+
};
46+
47+
union vuart_addr {
48+
uint16_t port_base; /* addr for legacy type */
49+
struct { /* addr for pci type */
50+
uint8_t f : 3; /* BITs 0-2 */
51+
uint8_t d : 5; /* BITs 3-7 */
52+
uint8_t b; /* BITs 8-15 */
53+
} bdf;
54+
};
55+
56+
struct vuart_config {
57+
enum vuart_type type; /* legacy PIO or PCI */
58+
union vuart_addr addr; /* port addr if in legacy type, or bdf addr if in pci type */
59+
uint16_t irq;
60+
struct target_vuart t_vuart; /* target vuart */
61+
} __aligned(8);
62+
3663
struct acrn_vm_os_config {
3764
char name[MAX_VM_OS_NAME_LEN]; /* OS name, useful for debug */
3865
char bootargs[MAX_BOOTARGS_SIZE]; /* boot args/cmdline */
@@ -62,6 +89,7 @@ struct acrn_vm_config {
6289
uint16_t clos; /* if guest_flags has GUEST_FLAG_CLOS_REQUIRED, then VM use this CLOS */
6390

6491
bool vm_vuart;
92+
struct vuart_config vuart[MAX_VUART_NUM_PER_VM];/* vuart configuration for VM */
6593
struct mptable_info *mptable; /* Pointer to mptable struct if VM type is pre-launched */
6694
} __aligned(8);
6795

hypervisor/include/debug/vuart.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
#define RX_BUF_SIZE 256U
3636
#define TX_BUF_SIZE 8192U
3737

38+
#define COM1_BASE 0x3F8U
39+
#define COM2_BASE 0x2F8U
40+
#define COM3_BASE 0x3E8U
41+
#define COM4_BASE 0x2E8U
42+
#define INVALID_COM_BASE 0U
43+
44+
#define COM1_IRQ 4U
45+
#define COM2_IRQ 3U
46+
#define COM3_IRQ 6U
47+
#define COM4_IRQ 7U
48+
3849
struct fifo {
3950
char *buf;
4051
uint32_t rindex; /* index to read from */

hypervisor/scenarios/logical_partition/vm_configurations.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <vm_config.h>
88
#include <vm_configurations.h>
99
#include <acrn_common.h>
10+
#include <vuart.h>
1011

1112
extern struct acrn_vm_pci_ptdev_config vm0_pci_ptdevs[VM0_CONFIG_PCI_PTDEV_NUM];
1213
extern struct acrn_vm_pci_ptdev_config vm1_pci_ptdevs[VM1_CONFIG_PCI_PTDEV_NUM];
@@ -37,6 +38,18 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
3738
consoleblank=0 tsc=reliable xapic_phys"
3839
},
3940
.vm_vuart = true,
41+
.vuart[0] = {
42+
.type = VUART_LEGACY_PIO,
43+
.addr.port_base = COM1_BASE,
44+
.irq = COM1_IRQ,
45+
},
46+
.vuart[1] = {
47+
.type = VUART_LEGACY_PIO,
48+
.addr.port_base = COM2_BASE,
49+
.irq = COM2_IRQ,
50+
.t_vuart.vm_id = 1U,
51+
.t_vuart.vuart_id = 1U,
52+
},
4053
.pci_ptdev_num = VM0_CONFIG_PCI_PTDEV_NUM,
4154
.pci_ptdevs = vm0_pci_ptdevs,
4255
.mptable = &vm_mptables[0],
@@ -65,6 +78,18 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
6578
consoleblank=0 tsc=reliable xapic_phys"
6679
},
6780
.vm_vuart = true,
81+
.vuart[0] = {
82+
.type = VUART_LEGACY_PIO,
83+
.addr.port_base = COM1_BASE,
84+
.irq = COM1_IRQ,
85+
},
86+
.vuart[1] = {
87+
.type = VUART_LEGACY_PIO,
88+
.addr.port_base = COM2_BASE,
89+
.irq = COM2_IRQ,
90+
.t_vuart.vm_id = 0U,
91+
.t_vuart.vuart_id = 1U,
92+
},
6893
.pci_ptdev_num = VM1_CONFIG_PCI_PTDEV_NUM,
6994
.pci_ptdevs = vm1_pci_ptdevs,
7095
.mptable = &vm_mptables[1],

hypervisor/scenarios/sdc/vm_configurations.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <vm_config.h>
88
#include <vm_configurations.h>
99
#include <acrn_common.h>
10+
#include <vuart.h>
1011

1112
struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
1213
{
@@ -24,11 +25,29 @@ struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM] = {
2425
.os_config = {
2526
.name = "ACRN Service OS",
2627
},
28+
.vuart[0] = {
29+
.type = VUART_LEGACY_PIO,
30+
.addr.port_base = CONFIG_COM_BASE,
31+
.irq = CONFIG_COM_IRQ,
32+
},
33+
.vuart[1] = {
34+
.type = VUART_LEGACY_PIO,
35+
.addr.port_base = INVALID_COM_BASE,
36+
}
2737
},
2838
{
2939
.type = NORMAL_VM,
3040
.uuid = {0xd2U, 0x79U, 0x54U, 0x38U, 0x25U, 0xd6U, 0x11U, 0xe8U, \
3141
0x86U, 0x4eU, 0xcbU, 0x7aU, 0x18U, 0xb3U, 0x46U, 0x43U},
3242
/* d2795438-25d6-11e8-864e-cb7a18b34643 */
43+
.vuart[0] = {
44+
.type = VUART_LEGACY_PIO,
45+
.addr.port_base = INVALID_COM_BASE,
46+
},
47+
.vuart[1] = {
48+
.type = VUART_LEGACY_PIO,
49+
.addr.port_base = INVALID_COM_BASE,
50+
}
51+
3352
}
3453
};

0 commit comments

Comments
 (0)