PCI drivers - BAR addresses

Daniel Hellstrom daniel at gaisler.com
Mon Oct 28 14:50:13 UTC 2013

On 10/28/2013 03:37 PM, David Paterson wrote:
> On 28 October 2013 12:17, Daniel Hellstrom <daniel at gaisler.com <mailto:daniel at gaisler.com>> wrote:
>     Ok, thanks for letting me know.
>     You can have a look at the changelog, I think the introduced changes in the drvmgr API names, the changelog describe a way to update some of the changes:
>         sed -e 's/rtems_drvmgr_dev_info/drvmgr_dev/g' \
>             -e 's/rtems_drvmgr_bus_info/drvmgr_bus/g' \
>             -e 's/rtems_drvmgr_drv_info/drvmgr_drv/g' \
>             -e 's/rtems_drvmgr_/drvmgr_/g' -i FILE
>     The configuration (for example drvmgr_leon3_config.c) has changed too to avoid unnecessary malloc() calls during initialization.
> Thanks Daniel,
> I'm working through these changes at the moment, and making good progress.  I've run into a strange problem in using functions like "pci_read_config_dword()" however, and I'm getting them as undefined.
> I've looked for them in various header files, but can't get any combination of headers to compile successfully.  I did see that there are now functions in the style of "grpci_cfg_r32()", and wonder 
> if I should be using these instead?

Yes there are a lot PCI changes. We have implemented a PCI library located in cpukit/libpci. Now the cfg space identifier {int bus, int slot, int func} is substituted with pci_dev_t to reduce the 
footprint of all PCI functions and callers. Now there are also I/O access routines.

grpci_* is the GRPCI specific implementation, it is better to use the new PCI library definitions defined in pci/access.h:

/* Configuration Space Access Read Routines */
extern int pci_cfg_r8(pci_dev_t dev, int ofs, uint8_t *data);
extern int pci_cfg_r16(pci_dev_t dev, int ofs, uint16_t *data);
extern int pci_cfg_r32(pci_dev_t dev, int ofs, uint32_t *data);

/* Configuration Space Access Write Routines */
extern int pci_cfg_w8(pci_dev_t dev, int ofs, uint8_t data);
extern int pci_cfg_w16(pci_dev_t dev, int ofs, uint16_t data);
extern int pci_cfg_w32(pci_dev_t dev, int ofs, uint32_t data);

/* Read a register over PCI I/O Space */
extern uint8_t pci_io_r8(uint32_t adr);
extern uint16_t pci_io_r16(uint32_t adr);
extern uint32_t pci_io_r32(uint32_t adr);

/* Write a register over PCI I/O Space */
extern void pci_io_w8(uint32_t adr, uint8_t data);
extern void pci_io_w16(uint32_t adr, uint16_t data);
extern void pci_io_w32(uint32_t adr, uint32_t data);


More information about the users mailing list