mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-26 03:04:31 +00:00
ACRN:DM:PCI: Add the support of allocating resource for PCI ROM bar
Now the device model only supports the 0..5 PCI bar for PCI/PCIE devices. This tries to allocate the PCI_MEM32 resource for PCI ROM bar. V1->V2: Use the PCI_ROMBAR as bar index and PCIBAR_ROM bar type when calling the pci_emul_alloc_bar to allocate the guest physical addr for PCI ROM bar. And it will allocate the resource from PCIBAR_MEM32 region. V2->V3: Add more comments that describes the parameter of pci_emul_alloc_bar. Tracked-On: #8175 Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> Acked-by: Wang Yu <yu1.wang@intel.com>
This commit is contained in:
@@ -103,7 +103,9 @@ enum pcibar_type {
|
||||
PCIBAR_IO,
|
||||
PCIBAR_MEM32,
|
||||
PCIBAR_MEM64,
|
||||
PCIBAR_MEMHI64
|
||||
PCIBAR_MEMHI64,
|
||||
/* the type for ROM bar. It will be allocated from PCI_EMUL_MEM32 region */
|
||||
PCIBAR_ROM
|
||||
};
|
||||
|
||||
struct pcibar {
|
||||
@@ -135,6 +137,7 @@ enum lintr_stat {
|
||||
PENDING
|
||||
};
|
||||
|
||||
#define PCI_ROMBAR (PCIR_MAX_BAR_0 + 1) /* ROM BAR index in Type 0 Header */
|
||||
struct pci_vdev {
|
||||
struct pci_vdev_ops *dev_ops;
|
||||
struct vmctx *vmctx;
|
||||
@@ -176,7 +179,8 @@ struct pci_vdev {
|
||||
void *arg; /* devemu-private data */
|
||||
|
||||
uint8_t cfgdata[PCI_REGMAX + 1];
|
||||
struct pcibar bar[PCI_BARMAX + 1];
|
||||
/* 0..5 is used for PCI MMIO/IO bar. 6 is used for PCI ROMbar */
|
||||
struct pcibar bar[PCI_BARMAX + 2];
|
||||
};
|
||||
|
||||
struct gsi_dev {
|
||||
@@ -311,6 +315,22 @@ void msicap_cfgwrite(struct pci_vdev *pi, int capoff, int offset,
|
||||
void msixcap_cfgwrite(struct pci_vdev *pi, int capoff, int offset,
|
||||
int bytes, uint32_t val);
|
||||
void pci_callback(void);
|
||||
|
||||
/*
|
||||
* @brief allocate bar region for virtual PCI device
|
||||
*
|
||||
* @param dev Pointer to struct pci_vdev representing virtual PCI device.
|
||||
* @param idx the bar_idx for the request bar region
|
||||
* @param type the region type for the request bar region
|
||||
* @param size the region size for the request bar region
|
||||
* It can support the allocation of bar_region for bar_idx 0..5 and
|
||||
* the bar type can be PCIBAR_IO/PCIBAR_MEM32/PCIBAR_MEM64.
|
||||
* It can support the allocation of ROM bar for PCI_ROMBAR and only allow
|
||||
* that the bar type is PCIBAR_ROM.
|
||||
*
|
||||
* @Return 0 indicates that the allocation is successful.
|
||||
* error indicates that it fails in the allocation of bar region.
|
||||
*/
|
||||
int pci_emul_alloc_bar(struct pci_vdev *pdi, int idx,
|
||||
enum pcibar_type type, uint64_t size);
|
||||
int pci_emul_alloc_pbar(struct pci_vdev *pdi, int idx,
|
||||
|
Reference in New Issue
Block a user