devLib2  2.12
Data Structures | Macros | Functions
VME CSR

Data Structures

struct  VMECSRID
 ID info for a VME64(x) device This structure is used to hold identifying information for a VME64 compatible device. When used for searching each field can hold a specific value of the 'VMECSRANY' wildcard. More...
 

Macros

#define DEVLIBVME_MAJOR   1
 API major version. More...
 
#define DEVLIBVME_MINOR   0
 API minor version. More...
 
#define VMECSR_END   {0,0,0}
 Must be the last entry in a device list. More...
 
#define VMECSRANY   0xFfffFfff
 Match any value. May be used in any field of VMECSRID. More...
 
#define VMECSRSLOTMAX   ((1<<5)-1)
 The highest slot number. More...
 
#define CSRSlotBase(slot)   ( (slot)<<19 )
 Derives the CSR space base address for a slot. More...
 
#define CSRADER(addr, mod)   ( ((addr)&0xFfffFf00) | ( ((mod)&0x3f)<<2 ) )
 Computes values for the VME64x address decode registers (ADER). More...
 
#define CSRRead8(addr)   ioread8(addr)
 
#define CSRRead16(addr)   ( CSRRead8(addr)<<8 | CSRRead8(addr+4) )
 
#define CSRRead24(addr)   ( CSRRead16(addr)<<8 | CSRRead8(addr+8) )
 
#define CSRRead32(addr)   ( CSRRead24(addr)<<8 | CSRRead8(addr+12) )
 
#define CSRWrite8(addr, val)   iowrite8(addr, val)
 
#define CSRWrite16(addr, val)   do{ CSRWrite8(addr,(val&0xff00)>>8); CSRWrite8(addr+4,val&0xff); }while(0)
 
#define CSRWrite24(addr, val)   do{ CSRWrite16(addr,(val&0xffff00)>>8); CSRWrite8(addr+8,val&0xff); }while(0)
 
#define CSRWrite32(addr, val)   do{ CSRWrite24(addr,(val&0xffffff00)>>8); CSRWrite8(addr+12,val&0xff); }while(0)
 

Functions

epicsShareFunc volatile unsigned char * devCSRProbeSlot (int slot)
 Get the CSR base address for a slot. More...
 
epicsShareFunc volatile unsigned char * devCSRTestSlot (const struct VMECSRID *devs, int slot, struct VMECSRID *info)
 Probe a VME slot then check its ID. More...
 
epicsShareExtern void vmecsrprint (int N, int verb)
 Decode contents of CSR/CR and print to screen. More...
 
epicsShareExtern void vmecsrdump (int verb)
 Decode contents of CSR/CR for all cards and print to screen. More...
 
INLINE void CSRSetBase (volatile void *base, epicsUInt8 N, epicsUInt32 addr, epicsUInt8 amod)
 Set base address for VME64x function N. More...
 

Detailed Description

Extensions to EPICS devLib to deal with the CSR address space defined by the VME64 standard and extended by the VME64x standard.

Macro Definition Documentation

◆ CSRADER

#define CSRADER (   addr,
  mod 
)    ( ((addr)&0xFfffFf00) | ( ((mod)&0x3f)<<2 ) )

Computes values for the VME64x address decode registers (ADER).

The ADER register encodes the address modifier and base address on one address range.

Definition at line 137 of file devcsr.h.

◆ CSRRead16

#define CSRRead16 (   addr)    ( CSRRead8(addr)<<8 | CSRRead8(addr+4) )

Definition at line 144 of file devcsr.h.

◆ CSRRead24

#define CSRRead24 (   addr)    ( CSRRead16(addr)<<8 | CSRRead8(addr+8) )

Definition at line 146 of file devcsr.h.

◆ CSRRead32

#define CSRRead32 (   addr)    ( CSRRead24(addr)<<8 | CSRRead8(addr+12) )

Definition at line 148 of file devcsr.h.

◆ CSRRead8

#define CSRRead8 (   addr)    ioread8(addr)

Definition at line 142 of file devcsr.h.

◆ CSRSlotBase

#define CSRSlotBase (   slot)    ( (slot)<<19 )

Derives the CSR space base address for a slot.

The top 5 bits of the 24 bit CSR address are the slot number.

This macro gives the VME CSR base address for a slot. Give this address to devBusToLocalAddr() with type atVMECSR

Definition at line 130 of file devcsr.h.

◆ CSRWrite16

#define CSRWrite16 (   addr,
  val 
)    do{ CSRWrite8(addr,(val&0xff00)>>8); CSRWrite8(addr+4,val&0xff); }while(0)

Definition at line 152 of file devcsr.h.

◆ CSRWrite24

#define CSRWrite24 (   addr,
  val 
)    do{ CSRWrite16(addr,(val&0xffff00)>>8); CSRWrite8(addr+8,val&0xff); }while(0)

Definition at line 155 of file devcsr.h.

◆ CSRWrite32

#define CSRWrite32 (   addr,
  val 
)    do{ CSRWrite24(addr,(val&0xffffff00)>>8); CSRWrite8(addr+12,val&0xff); }while(0)

Definition at line 158 of file devcsr.h.

◆ CSRWrite8

#define CSRWrite8 (   addr,
  val 
)    iowrite8(addr, val)

Definition at line 150 of file devcsr.h.

◆ DEVLIBVME_MAJOR

#define DEVLIBVME_MAJOR   1

API major version.

Definition at line 50 of file devcsr.h.

◆ DEVLIBVME_MINOR

#define DEVLIBVME_MINOR   0

API minor version.

Definition at line 51 of file devcsr.h.

◆ VMECSR_END

#define VMECSR_END   {0,0,0}

Must be the last entry in a device list.

Definition at line 63 of file devcsr.h.

◆ VMECSRANY

#define VMECSRANY   0xFfffFfff

Match any value. May be used in any field of VMECSRID.

Definition at line 66 of file devcsr.h.

◆ VMECSRSLOTMAX

#define VMECSRSLOTMAX   ((1<<5)-1)

The highest slot number.

Definition at line 69 of file devcsr.h.

Function Documentation

◆ CSRSetBase()

INLINE void CSRSetBase ( volatile void *  base,
epicsUInt8  N,
epicsUInt32  addr,
epicsUInt8  amod 
)

Set base address for VME64x function N.

Parameters
baseThe CSR base address of a slot
NA ADER number (0-7)
addrBase address to set for given ADER
amodVME address modifier to use for the given ADER

Definition at line 335 of file devcsr.h.

◆ devCSRProbeSlot()

epicsShareFunc volatile unsigned char* devCSRProbeSlot ( int  slot)

Get the CSR base address for a slot.

Test a single slot for the presense of VME64 complient module. Succeeds if a card is present and provides the standard registers.

Warning
Cards which do not provide the CR_ASCII_C and CR_ASCII_R registers with the correct values ('C' and 'R') will be ignored. This rejects cards which use the CSR address space for some other purpose and don't provide the standard registers.
Parameters
slotThe VME slot number (0-31)
Return values
NULLOn all failures
!NULLA pointer to slot's CSR base address

Definition at line 18 of file devcsr.c.

◆ devCSRTestSlot()

epicsShareFunc volatile unsigned char* devCSRTestSlot ( const struct VMECSRID devs,
int  slot,
struct VMECSRID info 
)

Probe a VME slot then check its ID.

Calls devCSRProbeSlot(). If a card is found the PCI ID fields are compared against the given VMECSRID list. The base address is returned if the card matches and NULL otherwise.

If info is non-NULL then the structure it points to will be filled with the ID information of the matching card.

An identifier list should be defined like:

static const struct VMECSRID vmedevices[] = {
{0x123456, 0x87654321, 0x15}
,{0x123456, 0x87654321, 0x16}
,{0x123456, 0x87655678, VMECSRANY}
,{0x214365, VMECSRANY, VMECSRANY}
};
Parameters
devsA list of PCI device IDs (wildcards optional).
slotVME slot number (0-31)
infoIf not NULL the exact ID of the matching device is copied here.
Return values
NULLIt no card is present, or the card does not match.
!NULLIf a card matching an entry in the device list is found.

Definition at line 83 of file devcsr.c.

◆ vmecsrdump()

epicsShareExtern void vmecsrdump ( int  verb)

Decode contents of CSR/CR for all cards and print to screen.

Calls vmecsrprint() on all slots (0-21)

Parameters
verbLevel of detail (0-2)

Definition at line 233 of file devcsr.c.

◆ vmecsrprint()

epicsShareExtern void vmecsrprint ( int  N,
int  verb 
)

Decode contents of CSR/CR and print to screen.

  • v=0 - basic identification info (vendor/board id)
  • v=1 - config/capability info
  • v=2 - hex dump of start of CR
Parameters
NVME slot number (0-31)
verbLevel of detail (0-2)

Definition at line 119 of file devcsr.c.