mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 04:02:05 +00:00
For a pdev which allocated to prelaunched VM or owned by HV, we need to check whether it is a multifuction dev at function 0. If yes we have to emulate a dummy function dev in Service VM, otherwise the sub-function devices will be lost in guest OS pci probe process. Tracked-On: #8492 Reviewed-by: Junjie Mao <junjie.mao@intel.com> Signed-off-by: Qiang Zhang <qiang4.zhang@intel.com> Signed-off-by: Victor Sun <victor.sun@intel.com>
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
/*
|
|
* Copyright (C) 2018-2022 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <asm/guest/vm.h>
|
|
#include <errno.h>
|
|
#include <logmsg.h>
|
|
#include <pci.h>
|
|
#include "vpci_priv.h"
|
|
|
|
/* config space of dummy multifunction device */
|
|
#define PCI_DUMMY_DEVICE_VENDOR 0x1D94U
|
|
#define PCI_DUMMY_DEVICE_ID 0x145AU
|
|
#define DUMMY_MF_REV 0x1U
|
|
#define DUMMY_MF_CLASS 0x0U
|
|
|
|
static void init_vpci_mf_dev(struct pci_vdev *vdev)
|
|
{
|
|
pci_vdev_write_vcfg(vdev, PCIR_VENDOR, 2U, PCI_DUMMY_DEVICE_VENDOR);
|
|
pci_vdev_write_vcfg(vdev, PCIR_DEVICE, 2U, PCI_DUMMY_DEVICE_ID);
|
|
pci_vdev_write_vcfg(vdev, PCIR_REVID, 1U, DUMMY_MF_REV);
|
|
pci_vdev_write_vcfg(vdev, PCIR_CLASS, 1U, DUMMY_MF_CLASS);
|
|
pci_vdev_write_vcfg(vdev, PCIR_HDRTYPE, 1U, PCIM_HDRTYPE_NORMAL | PCIM_MFDEV);
|
|
|
|
vdev->parent_user = NULL;
|
|
vdev->user = vdev;
|
|
}
|
|
|
|
static void deinit_vpci_mf_dev(struct pci_vdev *vdev)
|
|
{
|
|
vdev->parent_user = NULL;
|
|
vdev->user = NULL;
|
|
}
|
|
|
|
static int32_t read_vpci_mf_dev(struct pci_vdev *vdev, uint32_t offset,
|
|
uint32_t bytes, uint32_t *val)
|
|
{
|
|
*val = pci_vdev_read_vcfg(vdev, offset, bytes);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int32_t write_vpci_mf_dev(__unused struct pci_vdev *vdev, __unused uint32_t offset,
|
|
__unused uint32_t bytes, __unused uint32_t val)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
const struct pci_vdev_ops vpci_mf_dev_ops = {
|
|
.init_vdev = init_vpci_mf_dev,
|
|
.deinit_vdev = deinit_vpci_mf_dev,
|
|
.write_vdev_cfg = write_vpci_mf_dev,
|
|
.read_vdev_cfg = read_vpci_mf_dev,
|
|
};
|