hv:Replace vpic pointer with instance in structure vm
-- update 'vpic' field in 'struct vm' from pointer to instance, and move it from 'struct vm' to 'struct arch_vm' -- replace MACRO with inline function for vm_pic, and move it to vm.h -- changed vpic_init to void type -- removed vpic_cleanup -- move struct acrn_vpic/i8259_reg_state from vpic.c to vpic.h 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
de53964c05
commit
0b54946bac
|
@ -201,7 +201,7 @@ int create_vm(struct vm_description *vm_desc, struct vm **rtn_vm)
|
|||
/* Create virtual uart */
|
||||
vm->vuart = vuart_init(vm);
|
||||
}
|
||||
vm->vpic = vpic_init(vm);
|
||||
vpic_init(vm);
|
||||
|
||||
#ifdef CONFIG_PARTITION_MODE
|
||||
/* Create virtual uart */
|
||||
|
@ -240,10 +240,6 @@ err:
|
|||
vioapic_cleanup(vm->arch_vm.virt_ioapic);
|
||||
}
|
||||
|
||||
if (vm->vpic != NULL) {
|
||||
vpic_cleanup(vm);
|
||||
}
|
||||
|
||||
if (vm->arch_vm.m2p != NULL) {
|
||||
free(vm->arch_vm.m2p);
|
||||
}
|
||||
|
@ -314,9 +310,6 @@ int shutdown_vm(struct vm *vm)
|
|||
free_vm_id(vm);
|
||||
#endif
|
||||
|
||||
if (vm->vpic != NULL) {
|
||||
vpic_cleanup(vm);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PARTITION_MODE
|
||||
vpci_cleanup(vm);
|
||||
|
|
|
@ -156,7 +156,7 @@ static int vcpu_do_pending_extint(struct vcpu *vcpu)
|
|||
/* check if there is valid interrupt from vPIC, if yes just inject it */
|
||||
/* PIC only connect with primary CPU */
|
||||
primary = get_primary_vcpu(vm);
|
||||
if ((vm->vpic != NULL) && vcpu == primary) {
|
||||
if (vcpu == primary) {
|
||||
|
||||
vpic_pending_intr(vcpu->vm, &vector);
|
||||
if (vector <= NR_MAX_VECTOR) {
|
||||
|
|
|
@ -125,14 +125,11 @@ static void vuart_toggle_intr(struct vuart *vu)
|
|||
intr_reason = vuart_intr_reason(vu);
|
||||
|
||||
if (intr_reason != IIR_NOPEND) {
|
||||
if (vu->vm->vpic != NULL) {
|
||||
vpic_assert_irq(vu->vm, COM1_IRQ);
|
||||
}
|
||||
vpic_assert_irq(vu->vm, COM1_IRQ);
|
||||
|
||||
vioapic_assert_irq(vu->vm, COM1_IRQ);
|
||||
if (vu->vm->vpic != NULL) {
|
||||
vpic_deassert_irq(vu->vm, COM1_IRQ);
|
||||
}
|
||||
|
||||
vpic_deassert_irq(vu->vm, COM1_IRQ);
|
||||
|
||||
vioapic_deassert_irq(vu->vm, COM1_IRQ);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
/* TODO: add spinlock_locked support? */
|
||||
/*#define VPIC_LOCKED(vpic) spinlock_locked(&((vpic)->lock))*/
|
||||
|
||||
#define vm_pic(vm) (vm->vpic)
|
||||
|
||||
#define ACRN_DBG_PIC 6U
|
||||
|
||||
enum irqstate {
|
||||
|
@ -45,34 +43,6 @@ enum irqstate {
|
|||
IRQSTATE_PULSE
|
||||
};
|
||||
|
||||
struct i8259_reg_state {
|
||||
bool ready;
|
||||
uint8_t icw_num;
|
||||
uint8_t rd_cmd_reg;
|
||||
|
||||
bool aeoi;
|
||||
bool poll;
|
||||
bool rotate;
|
||||
bool sfn; /* special fully-nested mode */
|
||||
|
||||
uint32_t irq_base;
|
||||
uint8_t request; /* Interrupt Request Register (IIR) */
|
||||
uint8_t service; /* Interrupt Service (ISR) */
|
||||
uint8_t mask; /* Interrupt Mask Register (IMR) */
|
||||
uint8_t smm; /* special mask mode */
|
||||
|
||||
int acnt[8]; /* sum of pin asserts and deasserts */
|
||||
uint8_t lowprio; /* lowest priority irq */
|
||||
|
||||
bool intr_raised;
|
||||
uint8_t elc;
|
||||
};
|
||||
|
||||
struct acrn_vpic {
|
||||
struct vm *vm;
|
||||
spinlock_t lock;
|
||||
struct i8259_reg_state i8259[2];
|
||||
};
|
||||
|
||||
#define NR_VPIC_PINS_PER_CHIP 8U
|
||||
#define NR_VPIC_PINS_TOTAL 16U
|
||||
|
@ -921,27 +891,13 @@ static void vpic_register_io_handler(struct vm *vm)
|
|||
&vpic_elc_io_read, &vpic_elc_io_write);
|
||||
}
|
||||
|
||||
void *vpic_init(struct vm *vm)
|
||||
void vpic_init(struct vm *vm)
|
||||
{
|
||||
struct acrn_vpic *vpic;
|
||||
|
||||
struct acrn_vpic *vpic = vm_pic(vm);
|
||||
vpic_register_io_handler(vm);
|
||||
|
||||
vpic = calloc(1U, sizeof(struct acrn_vpic));
|
||||
ASSERT(vpic != NULL, "");
|
||||
vpic->vm = vm;
|
||||
vpic->i8259[0].mask = 0xffU;
|
||||
vpic->i8259[1].mask = 0xffU;
|
||||
vm->arch_vm.vpic.vm = vm;
|
||||
vm->arch_vm.vpic.i8259[0].mask = 0xffU;
|
||||
vm->arch_vm.vpic.i8259[1].mask = 0xffU;
|
||||
|
||||
VPIC_LOCK_INIT(vpic);
|
||||
|
||||
return vpic;
|
||||
}
|
||||
|
||||
void vpic_cleanup(struct vm *vm)
|
||||
{
|
||||
if (vm->vpic != NULL) {
|
||||
free(vm->vpic);
|
||||
vm->vpic = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ struct vm_arch {
|
|||
void *iobitmap[2];/* IO bitmap page array base address for this VM */
|
||||
void *msr_bitmap; /* MSR bitmap page base address for this VM */
|
||||
void *virt_ioapic; /* Virtual IOAPIC base address */
|
||||
struct acrn_vpic vpic; /* Virtual PIC */
|
||||
/**
|
||||
* A link to the IO handler of this VM.
|
||||
* We only register io handle to this link
|
||||
|
@ -125,7 +126,6 @@ struct vcpuid_entry {
|
|||
uint32_t padding;
|
||||
};
|
||||
|
||||
struct acrn_vpic;
|
||||
struct vm {
|
||||
uint16_t vm_id; /* Virtual machine identifier */
|
||||
struct vm_hw_info hw; /* Reference to this VM's HW information */
|
||||
|
@ -134,7 +134,6 @@ struct vm {
|
|||
struct vm_arch arch_vm; /* Reference to this VM's arch information */
|
||||
enum vm_state state; /* VM state */
|
||||
void *vuart; /* Virtual UART */
|
||||
struct acrn_vpic *vpic; /* Virtual PIC */
|
||||
enum vpic_wire_mode wire_mode;
|
||||
struct iommu_domain *iommu; /* iommu domain of this VM */
|
||||
struct list_head list; /* list of VM */
|
||||
|
@ -244,6 +243,12 @@ static inline struct vcpu *get_primary_vcpu(struct vm *vm)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct acrn_vpic *
|
||||
vm_pic(struct vm *vm)
|
||||
{
|
||||
return (struct acrn_vpic *)&(vm->arch_vm.vpic);
|
||||
}
|
||||
|
||||
int shutdown_vm(struct vm *vm);
|
||||
void pause_vm(struct vm *vm);
|
||||
void resume_vm(struct vm *vm);
|
||||
|
|
|
@ -90,8 +90,36 @@ enum vpic_trigger {
|
|||
LEVEL_TRIGGER
|
||||
};
|
||||
|
||||
void *vpic_init(struct vm *vm);
|
||||
void vpic_cleanup(struct vm *vm);
|
||||
struct i8259_reg_state {
|
||||
bool ready;
|
||||
uint8_t icw_num;
|
||||
uint8_t rd_cmd_reg;
|
||||
|
||||
bool aeoi;
|
||||
bool poll;
|
||||
bool rotate;
|
||||
bool sfn; /* special fully-nested mode */
|
||||
|
||||
uint32_t irq_base;
|
||||
uint8_t request; /* Interrupt Request Register (IIR) */
|
||||
uint8_t service; /* Interrupt Service (ISR) */
|
||||
uint8_t mask; /* Interrupt Mask Register (IMR) */
|
||||
uint8_t smm; /* special mask mode */
|
||||
|
||||
int acnt[8]; /* sum of pin asserts and deasserts */
|
||||
uint8_t lowprio; /* lowest priority irq */
|
||||
|
||||
bool intr_raised;
|
||||
uint8_t elc;
|
||||
};
|
||||
|
||||
struct acrn_vpic {
|
||||
struct vm *vm;
|
||||
spinlock_t lock;
|
||||
struct i8259_reg_state i8259[2];
|
||||
};
|
||||
|
||||
void vpic_init(struct vm *vm);
|
||||
|
||||
void vpic_assert_irq(struct vm *vm, uint32_t irq);
|
||||
void vpic_deassert_irq(struct vm *vm, uint32_t irq);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <trusty.h>
|
||||
#include <guest_pm.h>
|
||||
#include <host_pm.h>
|
||||
#include <vpic.h>
|
||||
#include <vm.h>
|
||||
#include <cpuid.h>
|
||||
#include <mmu.h>
|
||||
|
@ -32,7 +33,6 @@
|
|||
#include <assign.h>
|
||||
#include <vtd.h>
|
||||
|
||||
#include <vpic.h>
|
||||
#include <vlapic.h>
|
||||
#include <vioapic.h>
|
||||
#include <guest.h>
|
||||
|
|
Loading…
Reference in New Issue