HV: vuart: enable vuart console for VM

In previous code, only for pre-launched VM, hypervisor would create
vuart console for each VM. But for post-launched VM, no vuart is
created.
In this patch, create vuart according to configuration in structure
acrn_vm_config. As the new configuration is set for pre-launched VM and
post-launched VM, and the vuart initialize process is common for each
VM, so, remove CONFIG_PARTITION_MODE from vuart related code.

Tracked-On: #2987
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Conghui Chen
2019-04-20 06:30:15 +08:00
committed by ACRN System Integration
parent 3c92d7bbc7
commit 235d886103
12 changed files with 141 additions and 104 deletions

View File

@@ -120,7 +120,7 @@ struct acrn_vm {
struct e820_entry *e820_entries;
uint16_t vm_id; /* Virtual machine identifier */
enum vm_state state; /* VM state */
struct acrn_vuart vuart; /* Virtual UART */
struct acrn_vuart vuart[MAX_VUART_NUM_PER_VM]; /* Virtual UART */
enum vpic_wire_mode wire_mode;
struct iommu_domain *iommu; /* iommu domain of this VM */
spinlock_t spinlock; /* Spin-lock used to protect VM modifications */

View File

@@ -15,8 +15,10 @@
#define PIC_ELC_PIO_IDX (PIC_SLAVE_PIO_IDX + 1U)
#define PCI_CFGADDR_PIO_IDX (PIC_ELC_PIO_IDX + 1U)
#define PCI_CFGDATA_PIO_IDX (PCI_CFGADDR_PIO_IDX + 1U)
#define UART_PIO_IDX (PCI_CFGDATA_PIO_IDX + 1U)
#define PM1A_EVT_PIO_IDX (UART_PIO_IDX + 1U)
/* When MAX_VUART_NUM_PER_VM is larger than 2, UART_PIO_IDXn should also be added here */
#define UART_PIO_IDX0 (PCI_CFGDATA_PIO_IDX + 1U)
#define UART_PIO_IDX1 (UART_PIO_IDX0 + 1U)
#define PM1A_EVT_PIO_IDX (UART_PIO_IDX1 + 1U)
#define PM1A_CNT_PIO_IDX (PM1A_EVT_PIO_IDX + 1U)
#define PM1B_EVT_PIO_IDX (PM1A_CNT_PIO_IDX + 1U)
#define PM1B_CNT_PIO_IDX (PM1B_EVT_PIO_IDX + 1U)

View File

@@ -88,7 +88,6 @@ struct acrn_vm_config {
struct acrn_vm_os_config os_config; /* OS information the VM */
uint16_t clos; /* if guest_flags has GUEST_FLAG_CLOS_REQUIRED, then VM use this CLOS */
bool vm_vuart;
struct vuart_config vuart[MAX_VUART_NUM_PER_VM];/* vuart configuration for VM */
struct mptable_info *mptable; /* Pointer to mptable struct if VM type is pre-launched */
} __aligned(8);

View File

@@ -31,9 +31,11 @@
#define VUART_H
#include <types.h>
#include <spinlock.h>
#include <vm_config.h>
#define RX_BUF_SIZE 256U
#define TX_BUF_SIZE 8192U
#define INVAILD_VUART_IDX 0xFFU
#define COM1_BASE 0x3F8U
#define COM2_BASE 0x2F8U
@@ -68,27 +70,23 @@ struct acrn_vuart {
struct fifo rxfifo;
struct fifo txfifo;
uint16_t base;
#ifdef CONFIG_PARTITION_MODE
uint16_t port_base;
uint32_t irq;
char vuart_rx_buf[RX_BUF_SIZE];
char vuart_tx_buf[TX_BUF_SIZE];
#endif
bool thre_int_pending; /* THRE interrupt pending */
bool active;
struct acrn_vm *vm;
spinlock_t lock; /* protects all softc elements */
};
#ifdef CONFIG_PARTITION_MODE
extern uint16_t vuart_vmid;
#endif /* CONFIG_PARTITION_MODE */
struct acrn_vuart *vm_vuart(struct acrn_vm *vm);
void vuart_init(struct acrn_vm *vm);
struct acrn_vuart *vm_console_vuart(struct acrn_vm *vm);
void vuart_init(struct acrn_vm *vm, struct vuart_config *vu_config);
void vuart_deinit(struct acrn_vm *vm);
struct acrn_vuart *vuart_console_active(void);
void vuart_console_tx_chars(struct acrn_vuart *vu);
void vuart_console_rx_chars(struct acrn_vuart *vu);
bool hv_used_dbg_intx(uint32_t intx_pin);
bool is_vuart_intx(struct acrn_vm *vm, uint32_t intx_pin);
void vuart_set_property(const char *vuart_info);
#endif /* VUART_H */