Skip to content

Commit

Permalink
add pci api,the pci/pcie driver writer can use this to get resource o…
Browse files Browse the repository at this point in the history
…f current device with flag,there are three flag :

1. PCI_BUS_REGION_F_MEM it mean memory space
2. PCI_BUS_REGION_F_IO it mean io space
3. PCI_BUS_REGION_F_PREFETCH it mean prefetchable memory
  • Loading branch information
zhuzhuzhus committed Sep 30, 2024
1 parent bb91502 commit 96ccb89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/drivers/include/drivers/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +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,int index);
#define RT_PCI_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, pci, BUILIN)

extern struct rt_spinlock rt_pci_lock;
Expand Down
14 changes: 14 additions & 0 deletions components/drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,20 @@ 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,int index)
{
for (int i = 0; i < RT_PCI_BAR_NR_MAX; i++)
{
if (pdev->resource[i].flags == flags)
{
index--;
if (index == 0)
return &pdev->resource[i];
}
}
return RT_NULL;
}

void rt_pci_enum_device(struct rt_pci_bus *bus,
rt_bool_t (callback(struct rt_pci_device *, void *)), void *data)
{
Expand Down

0 comments on commit 96ccb89

Please sign in to comment.