forked from nuttx/nuttx-update
pci.h: add pci_map_bar_region support
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
This commit is contained in:
parent
e86be98d14
commit
3b09de844f
2 changed files with 59 additions and 10 deletions
|
@ -1560,6 +1560,41 @@ int pci_select_bars(FAR struct pci_device_s *dev, unsigned int flags)
|
|||
return bars;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pci_map_bar_region
|
||||
*
|
||||
* Description:
|
||||
* Create a virtual mapping for a PCI BAR REGION.
|
||||
*
|
||||
* Using this function you will get an address to your device BAR region.
|
||||
* These functions hide the details if this is a MMIO or PIO address
|
||||
* space and will just do what you expect from them in the correct way.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - PCI device that owns the BAR
|
||||
* bar - BAR number
|
||||
* offset - BAR region offset
|
||||
* length - BAR region length
|
||||
*
|
||||
* Returned Value:
|
||||
* IO address or zero if failed
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *pci_map_bar_region(FAR struct pci_device_s *dev, int bar,
|
||||
uintptr_t offset, size_t length)
|
||||
{
|
||||
FAR struct pci_bus_s *bus = dev->bus;
|
||||
uintptr_t start = pci_resource_start(dev, bar) + offset;
|
||||
uintptr_t end = start + length;
|
||||
|
||||
if (bus->ctrl->ops->map)
|
||||
{
|
||||
start = bus->ctrl->ops->map(bus, start, end);
|
||||
}
|
||||
|
||||
return (FAR void *)start;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pci_map_bar
|
||||
*
|
||||
|
@ -1581,16 +1616,7 @@ int pci_select_bars(FAR struct pci_device_s *dev, unsigned int flags)
|
|||
|
||||
FAR void *pci_map_bar(FAR struct pci_device_s *dev, int bar)
|
||||
{
|
||||
FAR struct pci_bus_s *bus = dev->bus;
|
||||
uintptr_t start = pci_resource_start(dev, bar);
|
||||
uintptr_t end = pci_resource_end(dev, bar);
|
||||
|
||||
if (bus->ctrl->ops->map)
|
||||
{
|
||||
start = bus->ctrl->ops->map(bus, start, end);
|
||||
}
|
||||
|
||||
return (FAR void *)start;
|
||||
return pci_map_bar_region(dev, bar, 0, pci_resource_len(dev, bar));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -615,6 +615,29 @@ int pci_disable_device(FAR struct pci_device_s *dev);
|
|||
|
||||
int pci_select_bars(FAR struct pci_device_s *dev, unsigned int flags);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pci_map_bar_region
|
||||
*
|
||||
* Description:
|
||||
* Create a virtual mapping for a PCI BAR REGION.
|
||||
*
|
||||
* Using this function you will get an address to your device BAR region.
|
||||
* These functions hide the details if this is a MMIO or PIO address
|
||||
* space and will just do what you expect from them in the correct way.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - PCI device that owns the BAR
|
||||
* bar - BAR number
|
||||
* offset - BAR region offset
|
||||
* length - BAR region length
|
||||
*
|
||||
* Returned Value:
|
||||
* IO address or zero if failed
|
||||
****************************************************************************/
|
||||
|
||||
FAR void *pci_map_bar_region(FAR struct pci_device_s *dev, int bar,
|
||||
uintptr_t offset, size_t length);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: pci_map_bar
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue