mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-13 13:56:19 +00:00
hv:Replace vuart pointer with instance in structure vm
-- update 'vuart' field in 'struct vm' from pointer to instance -- replace MACRO with inline function for vm_vuart, and move it to vm.h -- change vuart_init to void type -- rename struct vuart -->struct acrn_vuart Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Anthony Xu <anthony.xu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
0b54946bac
commit
29dbd1084d
@ -46,8 +46,7 @@ is_entry_active(struct ptdev_remapping_info *entry)
|
|||||||
static bool ptdev_hv_owned_intx(struct vm *vm, union source_id *virt_sid)
|
static bool ptdev_hv_owned_intx(struct vm *vm, union source_id *virt_sid)
|
||||||
{
|
{
|
||||||
/* vm0 pin 4 (uart) is owned by hypervisor under debug version */
|
/* vm0 pin 4 (uart) is owned by hypervisor under debug version */
|
||||||
if (is_vm0(vm) && (vm->vuart != NULL) &&
|
if (is_vm0(vm) && (virt_sid->intx_id.pin == 4U)) {
|
||||||
(virt_sid->intx_id.pin == 4U)) {
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -199,14 +199,14 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create virtual uart */
|
/* Create virtual uart */
|
||||||
vm->vuart = vuart_init(vm);
|
vuart_init(vm);
|
||||||
}
|
}
|
||||||
vpic_init(vm);
|
vpic_init(vm);
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
/* Create virtual uart */
|
/* Create virtual uart */
|
||||||
if (vm_desc->vm_vuart) {
|
if (vm_desc->vm_vuart) {
|
||||||
vm->vuart = vuart_init(vm);
|
vuart_init(vm);
|
||||||
}
|
}
|
||||||
vrtc_init(vm);
|
vrtc_init(vm);
|
||||||
vpci_init(vm);
|
vpci_init(vm);
|
||||||
|
@ -34,7 +34,7 @@ char console_getc(void)
|
|||||||
|
|
||||||
static void console_timer_callback(__unused void *data)
|
static void console_timer_callback(__unused void *data)
|
||||||
{
|
{
|
||||||
struct vuart *vu;
|
struct acrn_vuart *vu;
|
||||||
|
|
||||||
/* Kick HV-Shell and Uart-Console tasks */
|
/* Kick HV-Shell and Uart-Console tasks */
|
||||||
vu = vuart_console_active();
|
vu = vuart_console_active();
|
||||||
|
@ -722,7 +722,7 @@ static int shell_to_sos_console(__unused int argc, __unused char **argv)
|
|||||||
uint16_t guest_no = 0U;
|
uint16_t guest_no = 0U;
|
||||||
|
|
||||||
struct vm *vm;
|
struct vm *vm;
|
||||||
struct vuart *vuart;
|
struct acrn_vuart *vu;
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
if (argc == 2U) {
|
if (argc == 2U) {
|
||||||
@ -736,25 +736,17 @@ static int shell_to_sos_console(__unused int argc, __unused char **argv)
|
|||||||
if (vm == NULL) {
|
if (vm == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
vuart = vm->vuart;
|
vu = vm_vuart(vm);
|
||||||
if (vuart == NULL) {
|
/* UART is now owned by the SOS.
|
||||||
snprintf(temp_str, TEMP_STR_SIZE,
|
* Indicate by toggling the flag.
|
||||||
"\r\nError: serial console driver is not "
|
*/
|
||||||
"enabled for VM %d\r\n",
|
vu->active = true;
|
||||||
guest_no);
|
/* Output that switching to SOS shell */
|
||||||
shell_puts(temp_str);
|
snprintf(temp_str, TEMP_STR_SIZE,
|
||||||
} else {
|
"\r\n----- Entering Guest %d Shell -----\r\n",
|
||||||
/* UART is now owned by the SOS.
|
guest_no);
|
||||||
* Indicate by toggling the flag.
|
|
||||||
*/
|
|
||||||
vuart->active = true;
|
|
||||||
/* Output that switching to SOS shell */
|
|
||||||
snprintf(temp_str, TEMP_STR_SIZE,
|
|
||||||
"\r\n----- Entering Guest %d Shell -----\r\n",
|
|
||||||
guest_no);
|
|
||||||
|
|
||||||
shell_puts(temp_str);
|
shell_puts(temp_str);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,6 @@
|
|||||||
#define vuart_lock(vu) spinlock_obtain(&((vu)->lock))
|
#define vuart_lock(vu) spinlock_obtain(&((vu)->lock))
|
||||||
#define vuart_unlock(vu) spinlock_release(&((vu)->lock))
|
#define vuart_unlock(vu) spinlock_release(&((vu)->lock))
|
||||||
|
|
||||||
#define vm_vuart(vm) (vm->vuart)
|
|
||||||
|
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
int8_t vuart_vmid = - 1;
|
int8_t vuart_vmid = - 1;
|
||||||
#endif
|
#endif
|
||||||
@ -100,7 +98,7 @@ static uint32_t fifo_numchars(struct fifo *fifo)
|
|||||||
*
|
*
|
||||||
* Return an interrupt reason if one is available.
|
* Return an interrupt reason if one is available.
|
||||||
*/
|
*/
|
||||||
static uint8_t vuart_intr_reason(struct vuart *vu)
|
static uint8_t vuart_intr_reason(struct acrn_vuart *vu)
|
||||||
{
|
{
|
||||||
if (((vu->lsr & LSR_OE) != 0U) && ((vu->ier & IER_ELSI) != 0U)) {
|
if (((vu->lsr & LSR_OE) != 0U) && ((vu->ier & IER_ELSI) != 0U)) {
|
||||||
return IIR_RLS;
|
return IIR_RLS;
|
||||||
@ -118,7 +116,7 @@ static uint8_t vuart_intr_reason(struct vuart *vu)
|
|||||||
* Toggle the COM port's intr pin depending on whether or not we have an
|
* Toggle the COM port's intr pin depending on whether or not we have an
|
||||||
* interrupt condition to report to the processor.
|
* interrupt condition to report to the processor.
|
||||||
*/
|
*/
|
||||||
static void vuart_toggle_intr(struct vuart *vu)
|
static void vuart_toggle_intr(struct acrn_vuart *vu)
|
||||||
{
|
{
|
||||||
uint8_t intr_reason;
|
uint8_t intr_reason;
|
||||||
|
|
||||||
@ -139,7 +137,7 @@ static void vuart_write(__unused struct vm_io_handler *hdlr, struct vm *vm,
|
|||||||
uint16_t offset_arg, __unused size_t width, uint32_t value)
|
uint16_t offset_arg, __unused size_t width, uint32_t value)
|
||||||
{
|
{
|
||||||
uint16_t offset = offset_arg;
|
uint16_t offset = offset_arg;
|
||||||
struct vuart *vu = vm_vuart(vm);
|
struct acrn_vuart *vu = vm_vuart(vm);
|
||||||
uint8_t value_u8 = (uint8_t)value;
|
uint8_t value_u8 = (uint8_t)value;
|
||||||
|
|
||||||
offset -= vu->base;
|
offset -= vu->base;
|
||||||
@ -226,7 +224,7 @@ static uint32_t vuart_read(__unused struct vm_io_handler *hdlr, struct vm *vm,
|
|||||||
{
|
{
|
||||||
uint16_t offset = offset_arg;
|
uint16_t offset = offset_arg;
|
||||||
uint8_t iir, reg, intr_reason;
|
uint8_t iir, reg, intr_reason;
|
||||||
struct vuart *vu = vm_vuart(vm);
|
struct acrn_vuart *vu = vm_vuart(vm);
|
||||||
|
|
||||||
offset -= vu->base;
|
offset -= vu->base;
|
||||||
vuart_lock(vu);
|
vuart_lock(vu);
|
||||||
@ -314,7 +312,7 @@ static void vuart_register_io_handler(struct vm *vm)
|
|||||||
/**
|
/**
|
||||||
* @pre vu != NULL
|
* @pre vu != NULL
|
||||||
*/
|
*/
|
||||||
void vuart_console_tx_chars(struct vuart *vu)
|
void vuart_console_tx_chars(struct acrn_vuart *vu)
|
||||||
{
|
{
|
||||||
vuart_lock(vu);
|
vuart_lock(vu);
|
||||||
while (fifo_numchars(&vu->txfifo) > 0U) {
|
while (fifo_numchars(&vu->txfifo) > 0U) {
|
||||||
@ -327,7 +325,7 @@ void vuart_console_tx_chars(struct vuart *vu)
|
|||||||
* @pre vu != NULL
|
* @pre vu != NULL
|
||||||
* @pre vu->active == true
|
* @pre vu->active == true
|
||||||
*/
|
*/
|
||||||
void vuart_console_rx_chars(struct vuart *vu)
|
void vuart_console_rx_chars(struct acrn_vuart *vu)
|
||||||
{
|
{
|
||||||
char ch = -1;
|
char ch = -1;
|
||||||
|
|
||||||
@ -348,7 +346,7 @@ void vuart_console_rx_chars(struct vuart *vu)
|
|||||||
vuart_unlock(vu);
|
vuart_unlock(vu);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vuart *vuart_console_active(void)
|
struct acrn_vuart *vuart_console_active(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_PARTITION_MODE
|
#ifdef CONFIG_PARTITION_MODE
|
||||||
struct vm *vm;
|
struct vm *vm;
|
||||||
@ -362,36 +360,31 @@ struct vuart *vuart_console_active(void)
|
|||||||
struct vm *vm = get_vm_from_vmid(0U);
|
struct vm *vm = get_vm_from_vmid(0U);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((vm != NULL) && (vm->vuart != NULL)) {
|
if (vm != NULL) {
|
||||||
struct vuart *vu = vm->vuart;
|
struct acrn_vuart *vu = vm_vuart(vm);
|
||||||
|
|
||||||
if (vu->active) {
|
if (vu->active) {
|
||||||
return vm->vuart;
|
return vu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *vuart_init(struct vm *vm)
|
void vuart_init(struct vm *vm)
|
||||||
{
|
{
|
||||||
struct vuart *vu;
|
|
||||||
uint32_t divisor;
|
uint32_t divisor;
|
||||||
|
struct acrn_vuart *vu = vm_vuart(vm);
|
||||||
vu = calloc(1U, sizeof(struct vuart));
|
|
||||||
ASSERT(vu != NULL, "");
|
|
||||||
|
|
||||||
/* Set baud rate*/
|
/* Set baud rate*/
|
||||||
divisor = (UART_CLOCK_RATE / BAUD_9600) >> 4U;
|
divisor = (UART_CLOCK_RATE / BAUD_9600) >> 4U;
|
||||||
vu->dll = (uint8_t)divisor;
|
vm->vuart.dll = (uint8_t)divisor;
|
||||||
vu->dlh = (uint8_t)(divisor >> 8U);
|
vm->vuart.dlh = (uint8_t)(divisor >> 8U);
|
||||||
|
|
||||||
vu->active = false;
|
vm->vuart.active = false;
|
||||||
vu->base = COM1_BASE;
|
vm->vuart.base = COM1_BASE;
|
||||||
vu->vm = vm;
|
vm->vuart.vm = vm;
|
||||||
fifo_init(&vu->rxfifo, RX_FIFO_SIZE);
|
fifo_init(&vm->vuart.rxfifo, RX_FIFO_SIZE);
|
||||||
fifo_init(&vu->txfifo, TX_FIFO_SIZE);
|
fifo_init(&vm->vuart.txfifo, TX_FIFO_SIZE);
|
||||||
vuart_lock_init(vu);
|
vuart_lock_init(vu);
|
||||||
vuart_register_io_handler(vm);
|
vuart_register_io_handler(vm);
|
||||||
|
|
||||||
return vu;
|
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ struct vm {
|
|||||||
struct vm_pm_info pm; /* Reference to this VM's arch information */
|
struct vm_pm_info pm; /* Reference to this VM's arch information */
|
||||||
struct vm_arch arch_vm; /* Reference to this VM's arch information */
|
struct vm_arch arch_vm; /* Reference to this VM's arch information */
|
||||||
enum vm_state state; /* VM state */
|
enum vm_state state; /* VM state */
|
||||||
void *vuart; /* Virtual UART */
|
struct acrn_vuart vuart; /* Virtual UART */
|
||||||
enum vpic_wire_mode wire_mode;
|
enum vpic_wire_mode wire_mode;
|
||||||
struct iommu_domain *iommu; /* iommu domain of this VM */
|
struct iommu_domain *iommu; /* iommu domain of this VM */
|
||||||
struct list_head list; /* list of VM */
|
struct list_head list; /* list of VM */
|
||||||
@ -243,6 +243,12 @@ static inline struct vcpu *get_primary_vcpu(struct vm *vm)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct acrn_vuart*
|
||||||
|
vm_vuart(struct vm *vm)
|
||||||
|
{
|
||||||
|
return (struct acrn_vuart *)&(vm->vuart);
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct acrn_vpic *
|
static inline struct acrn_vpic *
|
||||||
vm_pic(struct vm *vm)
|
vm_pic(struct vm *vm)
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <guest_pm.h>
|
#include <guest_pm.h>
|
||||||
#include <host_pm.h>
|
#include <host_pm.h>
|
||||||
#include <vpic.h>
|
#include <vpic.h>
|
||||||
|
#include <vuart.h>
|
||||||
#include <vm.h>
|
#include <vm.h>
|
||||||
#include <cpuid.h>
|
#include <cpuid.h>
|
||||||
#include <mmu.h>
|
#include <mmu.h>
|
||||||
|
@ -38,7 +38,7 @@ struct fifo {
|
|||||||
uint32_t size; /* size of the fifo */
|
uint32_t size; /* size of the fifo */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vuart {
|
struct acrn_vuart {
|
||||||
uint8_t data; /* Data register (R/W) */
|
uint8_t data; /* Data register (R/W) */
|
||||||
uint8_t ier; /* Interrupt enable register (R/W) */
|
uint8_t ier; /* Interrupt enable register (R/W) */
|
||||||
uint8_t lcr; /* Line control register (R/W) */
|
uint8_t lcr; /* Line control register (R/W) */
|
||||||
@ -63,21 +63,20 @@ struct vuart {
|
|||||||
extern int8_t vuart_vmid;
|
extern int8_t vuart_vmid;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HV_DEBUG
|
#ifdef HV_DEBUG
|
||||||
void *vuart_init(struct vm *vm);
|
void vuart_init(struct vm *vm);
|
||||||
struct vuart *vuart_console_active(void);
|
struct acrn_vuart *vuart_console_active(void);
|
||||||
void vuart_console_tx_chars(struct vuart *vu);
|
void vuart_console_tx_chars(struct acrn_vuart *vu);
|
||||||
void vuart_console_rx_chars(struct vuart *vu);
|
void vuart_console_rx_chars(struct acrn_vuart *vu);
|
||||||
#else
|
#else
|
||||||
static inline void *vuart_init(__unused struct vm *vm)
|
static inline void vuart_init(__unused struct vm *vm)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
static inline struct acrn_vuart *vuart_console_active(void)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static inline struct vuart *vuart_console_active(void)
|
static inline void vuart_console_tx_chars(__unused struct acrn_vuart *vu) {}
|
||||||
{
|
static inline void vuart_console_rx_chars(__unused struct acrn_vuart *vu) {}
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
static inline void vuart_console_tx_chars(__unused struct vuart *vu) {}
|
|
||||||
static inline void vuart_console_rx_chars(__unused struct vuart *vu) {}
|
|
||||||
#endif /*HV_DEBUG*/
|
#endif /*HV_DEBUG*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#define HV_DEBUG_H
|
#define HV_DEBUG_H
|
||||||
|
|
||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include <vuart.h>
|
|
||||||
#include <console.h>
|
#include <console.h>
|
||||||
#include <dump.h>
|
#include <dump.h>
|
||||||
#include <trace.h>
|
#include <trace.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user