hv: implement PCI bus scan function

- It starts from scaning bus 0 and scan other buses only if it is referred
  as a Secondary Bus by a PCI-to-PCI bridge.
- Skip to next device if function 0 is not implemented.
- Don't enumerate function 1-7 if a device is not a multi-function device.

Tracked-On: #1568
Signed-off-by: dongshen <dongsheng.x.zhang@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Zide Chen
2018-10-24 12:11:01 -07:00
committed by lijinxia
parent 9cc1f57f63
commit ec5b90f11e
2 changed files with 67 additions and 0 deletions

View File

@@ -142,6 +142,8 @@ enum pci_bar_type {
PCIBAR_MEM64,
};
typedef void (*pci_enumeration_cb)(uint16_t pbdf, void *data);
static inline uint32_t pci_bar_offset(uint32_t idx)
{
return PCIR_BARS + (idx << 2U);
@@ -160,4 +162,6 @@ static inline bool pci_bar_access(uint32_t offset)
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 pci_scan_bus(pci_enumeration_cb cb, void *data);
#endif /* PCI_H_ */