HV: use is_prelaunched_vm/is_hostbridge to check if the code is only for pre-launched VMs

Currently host bridge emulation and bar emulation are only for pre-launched vms,
use is_prelaunched_vm to check if it is for pre-launched vms when calling
init/deinit/cfgread/cfgwrite, also use is_hostbridge() to check if the access if
for host bridge, so that these functions can be unified for sos and pre-launched
vm in subsequent commits.

Move is_hostbridge function to vpci_priv.h so that it can be used by multiple
files.

vhostbridge_cfgread/vhostbridge_cfgwrite: return -ENODEV if the pci cfg access is not
targeted for vhostbridge so that cfgread/cfgwrite functions can be unified for sos and
pre-launched vm in subsequent commits

Fix @pre for functions

Tracked-On: #3056
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
dongshen
2019-05-13 18:26:13 -07:00
committed by ACRN System Integration
parent a97e6e6465
commit cf48b9c38f
4 changed files with 85 additions and 53 deletions

View File

@@ -75,6 +75,14 @@ static inline bool has_msix_cap(const struct pci_vdev *vdev)
return (vdev->msix.capoff != 0U);
}
/**
* @pre vdev != NULL
*/
static inline bool is_hostbridge(const struct pci_vdev *vdev)
{
return (vdev->vbdf.value == 0U);
}
void vhostbridge_init(struct pci_vdev *vdev);
int32_t vhostbridge_cfgread(const struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t *val);
int32_t vhostbridge_cfgwrite(struct pci_vdev *vdev, uint32_t offset, uint32_t bytes, uint32_t val);