devLib2  2.11
Data Structures | Macros | Typedefs | Functions | Variables
PCI Bus Access

Data Structures

struct  epicsPCIID
 PCI device identifier. More...
 
struct  PCIBar
 
struct  epicsPCIDevice
 Device token. More...
 

Macros

#define DEVLIBPCI_MAJOR   1
 API major version. More...
 
#define DEVLIBPCI_MINOR   3
 API minor version. More...
 
#define DEVPCI_ANY_DEVICE   0x10000
 
#define DEVPCI_ANY_VENDOR   0x10000
 
#define DEVPCI_ANY_SUBDEVICE   0x10000
 
#define DEVPCI_ANY_SUBVENDOR   0x10000
 
#define DEVPCI_ANY_CLASS   0x1000000
 
#define DEVPCI_ANY_REVISION   0x100
 
#define DEVPCI_LAST_DEVICE   0xffff0000
 
#define DEVPCI_END   {DEVPCI_LAST_DEVICE,0,0,0,0,0}
 The last item in a list of PCI IDS. More...
 
#define DEVPCI_DEVICE_ANY()
 
#define DEVPCI_DEVICE_VENDOR(dev, vend)
 
#define DEVPCI_DEVICE_VENDOR_CLASS(dev, vend, pclass)
 
#define DEVPCI_SUBDEVICE_SUBVENDOR(dev, vend, sdev, svend)
 
#define DEVPCI_SUBDEVICE_SUBVENDOR_CLASS(dev, vend, sdev, svend, revision, pclass)
 
#define DEVPCI_NO_SLOT   NULL
 
#define PCIBARCOUNT   NELEMENTS( ((epicsPCIDevice*)0)->bar )
 The maximum number of base address registers (BARs). More...
 
#define DEVLIB_MAP_UIO1TO1   0
 
#define DEVLIB_MAP_UIOCOMPACT   0
 

Typedefs

typedef int(* devPCISearchFn) (void *ptr, const epicsPCIDevice *dev)
 PCI search callback prototype. More...
 

Functions

epicsShareFunc int devPCIFindCB (const epicsPCIID *idlist, devPCISearchFn searchfn, void *arg, unsigned int opt)
 PCI bus search w/ callback. More...
 
epicsShareFunc int devPCIFindSpec (const epicsPCIID *idlist, const char *spec, const epicsPCIDevice **found, unsigned int opt)
 PCI bus search by specification string. More...
 
epicsShareFunc int devPCIFindDBDF (const epicsPCIID *idlist, unsigned int domain, unsigned int b, unsigned int d, unsigned int f, const epicsPCIDevice **found, unsigned int opt)
 PCI bus probe. More...
 
epicsShareFunc int devPCIFindBDF (const epicsPCIID *idlist, unsigned int b, unsigned int d, unsigned int f, const epicsPCIDevice **found, unsigned int opt)
 
epicsShareFunc int devPCIToLocalAddr (const epicsPCIDevice *id, unsigned int bar, volatile void **ppLocalAddr, unsigned int opt)
 Get pointer to PCI BAR. More...
 
epicsShareFunc int devPCIBarLen (const epicsPCIDevice *id, unsigned int bar, epicsUInt32 *len)
 Find the size of a BAR. More...
 
epicsShareFunc int devPCIConnectInterrupt (const epicsPCIDevice *id, void(*pFunction)(void *), void *parameter, unsigned int opt)
 Request interrupts for device. More...
 
epicsShareFunc int devPCIDisconnectInterrupt (const epicsPCIDevice *id, void(*pFunction)(void *), void *parameter)
 Stop receiving interrupts. More...
 
epicsShareFunc void devPCIShow (int lvl, int vendor, int device, int exact)
 
epicsShareFunc void devPCIShowMatch (int lvl, const char *spec, int vendor, int device)
 
epicsShareFunc void devPCIShowDevice (int lvl, const epicsPCIDevice *dev)
 
epicsShareFunc int devLibPCIUse (const char *name)
 Select driver implementation. Pick driver implementation by name, or NULL to use default. If no selection is made then the default will be used if available. More...
 
epicsShareFunc const char * devLibPCIDriverName ()
 
epicsShareFunc int devPCIConfigRead8 (const epicsPCIDevice *dev, unsigned offset, epicsUInt8 *pResult)
 Read byte from configuration space. More...
 
epicsShareFunc int devPCIConfigRead16 (const epicsPCIDevice *dev, unsigned offset, epicsUInt16 *pResult)
 Read (16-bit) word from configuration space. More...
 
epicsShareFunc int devPCIConfigRead32 (const epicsPCIDevice *dev, unsigned offset, epicsUInt32 *pResult)
 Read (32-bit) dword from configuration space. More...
 
epicsShareFunc int devPCIConfigWrite8 (const epicsPCIDevice *dev, unsigned offset, epicsUInt8 value)
 Write byte to configuration space. More...
 
epicsShareFunc int devPCIConfigWrite16 (const epicsPCIDevice *dev, unsigned offset, epicsUInt16 value)
 Write (16-bit) word from configuration space. More...
 
epicsShareFunc int devPCIConfigWrite32 (const epicsPCIDevice *dev, unsigned offset, epicsUInt32 value)
 Write (32-bit) dword from configuration space. More...
 
epicsShareFunc int devPCIEnableInterrupt (const epicsPCIDevice *dev)
 Enable interrupts at the device. More...
 
epicsShareFunc int devPCIDisableInterrupt (const epicsPCIDevice *dev)
 Enable interrupts at the device. More...
 
epicsShareFunc const char * devPCIDeviceClassToString (int classId)
 Translate class id to string. More...
 

Variables

epicsShareExtern int devPCIDebug
 

Detailed Description

Library to support PCI bus access

Macro Definition Documentation

◆ DEVLIB_MAP_UIO1TO1

#define DEVLIB_MAP_UIO1TO1   0

Definition at line 232 of file devLibPCI.h.

◆ DEVLIB_MAP_UIOCOMPACT

#define DEVLIB_MAP_UIOCOMPACT   0

Definition at line 233 of file devLibPCI.h.

◆ DEVLIBPCI_MAJOR

#define DEVLIBPCI_MAJOR   1

API major version.

Definition at line 30 of file devLibPCI.h.

◆ DEVLIBPCI_MINOR

#define DEVLIBPCI_MINOR   3

API minor version.

Definition at line 31 of file devLibPCI.h.

◆ DEVPCI_ANY_CLASS

#define DEVPCI_ANY_CLASS   0x1000000

Definition at line 66 of file devLibPCI.h.

◆ DEVPCI_ANY_DEVICE

#define DEVPCI_ANY_DEVICE   0x10000

Definition at line 62 of file devLibPCI.h.

◆ DEVPCI_ANY_REVISION

#define DEVPCI_ANY_REVISION   0x100

Definition at line 67 of file devLibPCI.h.

◆ DEVPCI_ANY_SUBDEVICE

#define DEVPCI_ANY_SUBDEVICE   0x10000

Definition at line 64 of file devLibPCI.h.

◆ DEVPCI_ANY_SUBVENDOR

#define DEVPCI_ANY_SUBVENDOR   0x10000

Definition at line 65 of file devLibPCI.h.

◆ DEVPCI_ANY_VENDOR

#define DEVPCI_ANY_VENDOR   0x10000

Definition at line 63 of file devLibPCI.h.

◆ DEVPCI_DEVICE_ANY

#define DEVPCI_DEVICE_ANY ( )
Value:
DEVPCI_ANY_SUBDEVICE, DEVPCI_ANY_SUBVENDOR, \
DEVPCI_ANY_CLASS, DEVPCI_ANY_REVISION }
#define DEVPCI_ANY_REVISION
Definition: devLibPCI.h:67
#define DEVPCI_ANY_SUBVENDOR
Definition: devLibPCI.h:65
#define DEVPCI_ANY_VENDOR
Definition: devLibPCI.h:63
#define DEVPCI_ANY_DEVICE
Definition: devLibPCI.h:62

Definition at line 74 of file devLibPCI.h.

◆ DEVPCI_DEVICE_VENDOR

#define DEVPCI_DEVICE_VENDOR (   dev,
  vend 
)
Value:
DEVPCI_ANY_CLASS, DEVPCI_ANY_REVISION }
#define DEVPCI_ANY_REVISION
Definition: devLibPCI.h:67
#define DEVPCI_ANY_SUBVENDOR
Definition: devLibPCI.h:65
#define DEVPCI_ANY_SUBDEVICE
Definition: devLibPCI.h:64

Definition at line 79 of file devLibPCI.h.

◆ DEVPCI_DEVICE_VENDOR_CLASS

#define DEVPCI_DEVICE_VENDOR_CLASS (   dev,
  vend,
  pclass 
)
Value:
#define DEVPCI_ANY_REVISION
Definition: devLibPCI.h:67
#define DEVPCI_ANY_SUBVENDOR
Definition: devLibPCI.h:65
#define DEVPCI_ANY_SUBDEVICE
Definition: devLibPCI.h:64

Definition at line 83 of file devLibPCI.h.

◆ DEVPCI_END

#define DEVPCI_END   {DEVPCI_LAST_DEVICE,0,0,0,0,0}

The last item in a list of PCI IDS.

Definition at line 72 of file devLibPCI.h.

◆ DEVPCI_LAST_DEVICE

#define DEVPCI_LAST_DEVICE   0xffff0000

Definition at line 69 of file devLibPCI.h.

◆ DEVPCI_NO_SLOT

#define DEVPCI_NO_SLOT   NULL

Definition at line 95 of file devLibPCI.h.

◆ DEVPCI_SUBDEVICE_SUBVENDOR

#define DEVPCI_SUBDEVICE_SUBVENDOR (   dev,
  vend,
  sdev,
  svend 
)
Value:
{ dev, vend, sdev, svend, \
DEVPCI_ANY_CLASS, DEVPCI_ANY_REVISION }
#define DEVPCI_ANY_REVISION
Definition: devLibPCI.h:67

Definition at line 87 of file devLibPCI.h.

◆ DEVPCI_SUBDEVICE_SUBVENDOR_CLASS

#define DEVPCI_SUBDEVICE_SUBVENDOR_CLASS (   dev,
  vend,
  sdev,
  svend,
  revision,
  pclass 
)
Value:
{ dev, vend, sdev, svend, \
pclass, revision }
epicsUInt32 revision
Definition: devcsr.h:59

Definition at line 91 of file devLibPCI.h.

◆ PCIBARCOUNT

#define PCIBARCOUNT   NELEMENTS( ((epicsPCIDevice*)0)->bar )

The maximum number of base address registers (BARs).

Definition at line 126 of file devLibPCI.h.

Typedef Documentation

◆ devPCISearchFn

typedef int(* devPCISearchFn) (void *ptr, const epicsPCIDevice *dev)

PCI search callback prototype.

Parameters
ptrUser pointer
devPCI device pointer
Returns
0 Continue search
1 Abort search Ok (devPCIFindCB() returns 0)
other Abort search failed (devPCIFindCB() returns this code)

Definition at line 136 of file devLibPCI.h.

Function Documentation

◆ devLibPCIDriverName()

epicsShareFunc const char* devLibPCIDriverName ( )

Definition at line 138 of file devLibPCI.c.

◆ devLibPCIUse()

epicsShareFunc int devLibPCIUse ( const char *  name)

Select driver implementation. Pick driver implementation by name, or NULL to use default. If no selection is made then the default will be used if available.

Parameters
nameAn implementation name
Returns
0 on success or an EPICS error code on failure.

Definition at line 107 of file devLibPCI.c.

◆ devPCIBarLen()

epicsShareFunc int devPCIBarLen ( const epicsPCIDevice id,
unsigned int  bar,
epicsUInt32 *  len 
)

Find the size of a BAR.

Returns the size (in bytes) of the region visible through the given BAR.

Warning
On RTEMS and vxWorks this is a invasive operation. When calling it ensure that nothing is accessing the device. Don't call this on a device used by another driver.
Parameters
idPCI device pointer
barBAR number
[out]lenBAR size in bytes
Returns
0 on success or an EPICS error code on failure.

Definition at line 449 of file devLibPCI.c.

◆ devPCIConfigRead16()

epicsShareFunc int devPCIConfigRead16 ( const epicsPCIDevice dev,
unsigned  offset,
epicsUInt16 *  pResult 
)

Read (16-bit) word from configuration space.

Parameters
devA PCI device handle
offsetOffset into configuration space (must be 16-bit aligned)
pResultPointer to where result is to be written
Returns
0 on success or an EPICS error code on failure

Definition at line 609 of file devLibPCI.c.

◆ devPCIConfigRead32()

epicsShareFunc int devPCIConfigRead32 ( const epicsPCIDevice dev,
unsigned  offset,
epicsUInt32 *  pResult 
)

Read (32-bit) dword from configuration space.

Parameters
devA PCI device handle
offsetOffset into configuration space (must be 32-bit aligned)
pResultPointer to where result is to be written
Returns
0 on success or an EPICS error code on failure

Definition at line 615 of file devLibPCI.c.

◆ devPCIConfigRead8()

epicsShareFunc int devPCIConfigRead8 ( const epicsPCIDevice dev,
unsigned  offset,
epicsUInt8 *  pResult 
)

Read byte from configuration space.

Parameters
devA PCI device handle
offsetOffset into configuration space
pResultPointer to where result is to be written
Returns
0 on success or an EPICS error code on failure

Definition at line 603 of file devLibPCI.c.

◆ devPCIConfigWrite16()

epicsShareFunc int devPCIConfigWrite16 ( const epicsPCIDevice dev,
unsigned  offset,
epicsUInt16  value 
)

Write (16-bit) word from configuration space.

Parameters
devA PCI device handle
offsetOffset into configuration space (must be 16-bit aligned)
valueValue to be written
Returns
0 on success or an EPICS error code on failure

Definition at line 627 of file devLibPCI.c.

◆ devPCIConfigWrite32()

epicsShareFunc int devPCIConfigWrite32 ( const epicsPCIDevice dev,
unsigned  offset,
epicsUInt32  value 
)

Write (32-bit) dword from configuration space.

Parameters
devA PCI device handle
offsetOffset into configuration space (must be 32-bit aligned)
valueValue to be written
Returns
0 on success or an EPICS error code on failure

Definition at line 633 of file devLibPCI.c.

◆ devPCIConfigWrite8()

epicsShareFunc int devPCIConfigWrite8 ( const epicsPCIDevice dev,
unsigned  offset,
epicsUInt8  value 
)

Write byte to configuration space.

Parameters
devA PCI device handle
offsetOffset into configuration space
valueValue to be written
Returns
0 on success or an EPICS error code on failure

Definition at line 621 of file devLibPCI.c.

◆ devPCIConnectInterrupt()

epicsShareFunc int devPCIConnectInterrupt ( const epicsPCIDevice id,
void(*)(void *)  pFunction,
void *  parameter,
unsigned int  opt 
)

Request interrupts for device.

Request that the provided callback be invoked whenever the device asserts an interrupt.

Note
Always connect the interrupt handler before enabling the device to send interrupts.
All drivers should be prepared for their device to share an interrupt with other devices.
Parameters
idPCI device pointer
pFunctionUser ISR
parameterUser pointer
optModifiers. Currently unused
Returns
0 on success or an EPICS error code on failure.

Definition at line 463 of file devLibPCI.c.

◆ devPCIDeviceClassToString()

epicsShareFunc const char* devPCIDeviceClassToString ( int  classId)

Translate class id to string.

Parameters
classIdPCI class Id
Returns
constant class name string

Definition at line 7 of file devLibPCIStrings.c.

◆ devPCIDisableInterrupt()

epicsShareFunc int devPCIDisableInterrupt ( const epicsPCIDevice dev)

Enable interrupts at the device.

Parameters
devA PCI device handle
Returns
0 on success or an EPICS error code on failure
Note
Implementation of this call for any OS is optional

Definition at line 649 of file devLibPCI.c.

◆ devPCIDisconnectInterrupt()

epicsShareFunc int devPCIDisconnectInterrupt ( const epicsPCIDevice id,
void(*)(void *)  pFunction,
void *  parameter 
)

Stop receiving interrupts.

Use the same arguments passed to devPCIConnectInterrupt()

Parameters
idPCI device pointer
pFunctionUser ISR
parameterUser pointer
Returns
0 on success or an EPICS error code on failure.

Definition at line 476 of file devLibPCI.c.

◆ devPCIEnableInterrupt()

epicsShareFunc int devPCIEnableInterrupt ( const epicsPCIDevice dev)

Enable interrupts at the device.

Parameters
devA PCI device handle
Returns
0 on success or an EPICS error code on failure
Note
Implementation of this call for any OS is optional

Definition at line 640 of file devLibPCI.c.

◆ devPCIFindBDF()

epicsShareFunc int devPCIFindBDF ( const epicsPCIID idlist,
unsigned int  b,
unsigned int  d,
unsigned int  f,
const epicsPCIDevice **  found,
unsigned int  opt 
)

Definition at line 418 of file devLibPCI.c.

◆ devPCIFindCB()

epicsShareFunc int devPCIFindCB ( const epicsPCIID idlist,
devPCISearchFn  searchfn,
void *  arg,
unsigned int  opt 
)

PCI bus search w/ callback.

Iterate through all devices in the system and invoke the provided callback for those matching an entry in the provided ID list.

Iteration will stop when the callback returns a non-zero value. If the callback returns 1 this call will return 0. Any other value will be returned without modification.

Parameters
idlistList of PCI identifiers
searchfnUser callback
argUser pointer
optModifiers. Currently unused
Returns
0 on success or the error code returned by the callback.

Definition at line 214 of file devLibPCI.c.

◆ devPCIFindDBDF()

epicsShareFunc int devPCIFindDBDF ( const epicsPCIID idlist,
unsigned int  domain,
unsigned int  b,
unsigned int  d,
unsigned int  f,
const epicsPCIDevice **  found,
unsigned int  opt 
)

PCI bus probe.

Probe and test a single address. If it matches, the corresponding epicsPCIDevice instance is stored in 'found'.

If no compatible device is present the call returns S_dev_noDevice.

Parameters
idlistList of PCI identifiers
domaindomain
bbus
ddevice
ffunction
[out]foundOn success the result is stored here
optModifiers. Currently unused
Returns
0 on success or an EPICS error code on failure.

Definition at line 376 of file devLibPCI.c.

◆ devPCIFindSpec()

epicsShareFunc int devPCIFindSpec ( const epicsPCIID idlist,
const char *  spec,
const epicsPCIDevice **  found,
unsigned int  opt 
)

PCI bus search by specification string.

Search for a device on the bus matching the given specification string, which is a space seperated list of the following:

"<bus#>:<device#>[.<function#>]"

"<domain#>:<bus#>:<device#>[.<function#>]"

"slot=<slot#>"

"inst[ance]=<instance#>"

Some targets do not support some match types (eg. only Linux matches slot numbers).

Parameters
idlistList of PCI identifiers
specspecification string
[out]foundOn success the result is stored here
optModifiers. Currently unused
Returns
0 on success or an EPICS error code on failure.

Definition at line 267 of file devLibPCI.c.

◆ devPCIShow()

epicsShareFunc void devPCIShow ( int  lvl,
int  vendor,
int  device,
int  exact 
)

Definition at line 504 of file devLibPCI.c.

◆ devPCIShowDevice()

epicsShareFunc void devPCIShowDevice ( int  lvl,
const epicsPCIDevice dev 
)

Definition at line 541 of file devLibPCI.c.

◆ devPCIShowMatch()

epicsShareFunc void devPCIShowMatch ( int  lvl,
const char *  spec,
int  vendor,
int  device 
)

Definition at line 522 of file devLibPCI.c.

◆ devPCIToLocalAddr()

epicsShareFunc int devPCIToLocalAddr ( const epicsPCIDevice id,
unsigned int  bar,
volatile void **  ppLocalAddr,
unsigned int  opt 
)

Get pointer to PCI BAR.

Map a PCI BAR into the local process address space.

The opt argument is used to modify the mapping process. Currently only two (mutually exclusive) flags are supported which are only used by the Linux UIO bus implementation to control how requested BAR #s are mapped to UIO region numbers.

  • DEVLIB_MAP_UIO1TO1 (the only choice in devLib2 versions < 2.4) passes BAR #s without modification.
  • DEVLIB_MAP_UIOCOMPACT Maps the requested BAR # to the index of the appropriate IOMEM region. This index skips I/O Port BARs and any other non-IOMEM regions.
Parameters
idPCI device pointer
barBAR number
[out]ppLocalAddrPointer to start of BAR
optModifiers. 0 or bitwise OR of one or more DEVLIB_MAP_* macros
Returns
0 on success or an EPICS error code on failure.

Definition at line 431 of file devLibPCI.c.

Variable Documentation

◆ devPCIDebug

epicsShareExtern int devPCIDebug

Definition at line 354 of file devLibPCI.h.