diff --git a/hypervisor/arch/x86/assign.c b/hypervisor/arch/x86/assign.c index 2b285e539..649666bc2 100644 --- a/hypervisor/arch/x86/assign.c +++ b/hypervisor/arch/x86/assign.c @@ -579,7 +579,7 @@ int ptdev_msix_remap(struct acrn_vm *vm, uint16_t virt_bdf, entry->msi = *info; dev_dbg(ACRN_DBG_IRQ, "PCI %x:%x.%x MSI VR[%d] 0x%x->0x%x assigned to vm%d", - PCI_BUS(virt_bdf), PCI_SLOT(virt_bdf), PCI_FUNC(virt_bdf), entry_nr, + pci_bus(virt_bdf), pci_slot(virt_bdf), pci_func(virt_bdf), entry_nr, info->vmsi_data & 0xFFU, irq_to_vector(entry->allocated_pirq), entry->vm->vm_id); END: return 0; diff --git a/hypervisor/include/dm/pci.h b/hypervisor/include/dm/pci.h index c9304219f..cf7b326e4 100644 --- a/hypervisor/include/dm/pci.h +++ b/hypervisor/include/dm/pci.h @@ -49,10 +49,6 @@ #define PCI_BAR_COUNT 0x6U #define PCI_REGMAX 0xFFU -#define PCI_BUS(bdf) (((bdf) >> 8U) & 0xFFU) -#define PCI_SLOT(bdf) (((bdf) & 0xFFU) >> 3U) -#define PCI_FUNC(bdf) ((bdf) & 0x7U) - /* I/O ports */ #define PCI_CONFIG_ADDR 0xCF8U #define PCI_CONFIG_DATA 0xCFCU @@ -159,6 +155,21 @@ static inline bool pci_bar_access(uint32_t offset) } } +static inline uint8_t pci_bus(uint16_t bdf) +{ + return (uint8_t)((bdf >> 8U) & 0xFFU); +} + +static inline uint8_t pci_slot(uint16_t bdf) +{ + return (uint8_t)((bdf >> 3U) & 0x1FU); +} + +static inline uint8_t pci_func(uint16_t bdf) +{ + return (uint8_t)(bdf & 0x7U); +} + uint32_t pci_pdev_read_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes); void pci_pdev_write_cfg(union pci_bdf bdf, uint32_t offset, uint32_t bytes, uint32_t val); void enable_disable_pci_intx(union pci_bdf bdf, bool enable);