dm: add new ioctl to create and destroy a device

Add IC_CREATE_DEVICE and IC_DESTROY_DEVICE ioctls to create and
destroy an emulated device in hypervisor

v3: change IC_CREATE_DEVICE and IC_DESTROY_DEVICE to IC_CREATE_HV_VDEV
    and IC_DESTROY_HV_VDEV

Tracked-On: #4853

Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Yuan Liu
2020-08-24 10:08:08 +08:00
committed by wenlingz
parent 1b711ed629
commit a977d35e0c
3 changed files with 59 additions and 0 deletions

View File

@@ -109,6 +109,8 @@
#define IC_DEASSIGN_PCIDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x06)
#define IC_ASSIGN_MMIODEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x07)
#define IC_DEASSIGN_MMIODEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x08)
#define IC_CREATE_HV_VDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x09)
#define IC_DESTROY_HV_VDEV _IC_ID(IC_ID, IC_ID_PCI_BASE + 0x0A)
/* Power management */
#define IC_ID_PM_BASE 0x60UL
@@ -202,6 +204,49 @@ struct acrn_mmiodev {
} __attribute__((aligned(8)));
/**
* @brief Info to create or destroy a virtual PCI or legacy device for a VM
*
* the parameter for HC_CREATE_VDEV or HC_DESTROY_VDEV hypercall
*/
struct acrn_emul_dev {
/*
* the identifier of the device, the low 32 bits represent the vendor
* id and device id of PCI device and the high 32 bits represent the
* device number of the legacy device
*/
union dev_id_info {
uint64_t value;
struct fields_info {
uint16_t vendor_id;
uint16_t device_id;
uint32_t legacy_device_number;
} fields;
} dev_id;
/*
* the slot of the device, if the device is a PCI device, the slot
* represents BDF, otherwise it represents legacy device slot number
*/
uint32_t slot;
/** reserved for extension */
uint32_t reserved0;
/** the IO resource address of the device, initialized by ACRN-DM. */
uint32_t io_addr[6];
/** the IO resource size of the device, initialized by ACRN-DM. */
uint32_t io_size[6];
/** the options for the virtual device, initialized by ACRN-DM. */
uint8_t args[128];
/** reserved for extension */
uint64_t reserved1[8];
} __attribute__((aligned(8)));
/**
* @brief pass thru device irq data structure
*/