[feat] add pci api,the pci/pcie driver
add pci api,the pci/pcie driver writer can use this to get resource of 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
This commit is contained in:
parent
b9c3bdf7eb
commit
ef426851ea
|
@ -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_driver_register(struct rt_pci_driver *pdrv);
|
||||||
rt_err_t rt_pci_device_register(struct rt_pci_device *pdev);
|
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)
|
#define RT_PCI_DRIVER_EXPORT(driver) RT_DRIVER_EXPORT(driver, pci, BUILIN)
|
||||||
|
|
||||||
extern struct rt_spinlock rt_pci_lock;
|
extern struct rt_spinlock rt_pci_lock;
|
||||||
|
|
|
@ -712,6 +712,20 @@ rt_err_t rt_pci_device_alloc_resource(struct rt_pci_host_bridge *host_bridge,
|
||||||
return err;
|
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,
|
void rt_pci_enum_device(struct rt_pci_bus *bus,
|
||||||
rt_bool_t (callback(struct rt_pci_device *, void *)), void *data)
|
rt_bool_t (callback(struct rt_pci_device *, void *)), void *data)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue