mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 01:07:57 +00:00
hv: pci: check whether a PCI device is host bridge or not by class
According PCI Code and ID Assignment Specification Revision 1.11, a PCI device whose Base Class is 06h and Sub-Class is 00h is a Host bridge. Tracked-On: #4550 Signed-off-by: Li Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -223,6 +223,8 @@ struct pci_sriov_cap {
|
||||
|
||||
struct pci_pdev {
|
||||
uint8_t hdr_type;
|
||||
uint8_t base_class;
|
||||
uint8_t sub_class;
|
||||
|
||||
/* IOMMU responsible for DMA and Interrupt Remapping for this device */
|
||||
uint32_t drhd_index;
|
||||
@@ -250,6 +252,16 @@ struct pci_cfg_ops {
|
||||
void (*pci_write_cfg)(union pci_bdf bdf, uint32_t offset, uint32_t bytes, uint32_t val);
|
||||
};
|
||||
|
||||
static inline bool is_host_bridge(const struct pci_pdev *pdev)
|
||||
{
|
||||
return (pdev->base_class == PCIC_BRIDGE) && (pdev->sub_class == PCIS_BRIDGE_HOST);
|
||||
}
|
||||
|
||||
static inline bool is_bridge(const struct pci_pdev *pdev)
|
||||
{
|
||||
return pdev->hdr_type == PCIM_HDRTYPE_BRIDGE;
|
||||
}
|
||||
|
||||
static inline uint32_t pci_bar_offset(uint32_t idx)
|
||||
{
|
||||
return PCIR_BARS + (idx << 2U);
|
||||
|
Reference in New Issue
Block a user