Skip to content

Commit

Permalink
pci
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuzhuzhus committed Sep 14, 2024
1 parent 488065b commit 1788597
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions components/drivers/include/drivers/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,7 @@ const struct rt_pci_device_id *rt_pci_match_ids(struct rt_pci_device *pdev,

rt_err_t rt_pci_driver_register(struct rt_pci_driver *pdrv);
rt_err_t rt_pci_device_register(struct rt_pci_device *pdev);
struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags);

struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags,int index);
#define RT_PCI_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, pci, BUILIN)

extern struct rt_spinlock rt_pci_lock;
Expand Down
8 changes: 6 additions & 2 deletions components/drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,16 @@ rt_err_t rt_pci_device_alloc_resource(struct rt_pci_host_bridge *host_bridge,
return err;
}

struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags)
struct rt_pci_bus_resource *rt_pci_find_bar(struct rt_pci_device* pdev,rt_ubase_t flags,int index)
{
for (int i = 0; i < RT_PCI_BAR_NR_MAX; i++)
{
if (pdev->resource[i].flags == flags)
return &pdev->resource[i];
{
index--;
if (index == 0)
return &pdev->resource[i];
}
}
return RT_NULL;
}
Expand Down

0 comments on commit 1788597

Please sign in to comment.