This is Unofficial EPICS BASE Doxygen Site
devLibVME.h File Reference

API for accessing hardware devices, mosty over VMEbus. More...

#include "dbDefs.h"
#include "osdVME.h"
#include "errMdef.h"
#include "libComAPI.h"
#include "devLib.h"
#include "devLibVMEImpl.h"
+ Include dependency graph for devLibVME.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  epicsAddressType {
  atVMEA16, atVMEA24, atVMEA32, atISA,
  atVMECSR, atLast
}
 The available bus address types. More...
 

Functions

LIBCOM_API long devAddressMap (void)
 Print a map of registered bus addresses. More...
 
LIBCOM_API long devBusToLocalAddr (epicsAddressType addrType, size_t busAddr, volatile void **ppLocalAddr)
 Translate a bus address to a pointer the CPU can use. More...
 
LIBCOM_API long devReadProbe (unsigned wordSize, volatile const void *ptr, void *pValueRead)
 Probe the bus for reading from a specific address. More...
 
LIBCOM_API long devNoResponseProbe (epicsAddressType addrType, size_t base, size_t size)
 Read-probe a range of bus addresses, looking for empty space. More...
 
LIBCOM_API long devWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValueWritten)
 Probe the bus for writing to a specific address. More...
 
LIBCOM_API long devRegisterAddress (const char *pOwnerName, epicsAddressType addrType, size_t logicalBaseAddress, size_t size, volatile void **pPhysicalAddress)
 Register a bus address range with a name. More...
 
LIBCOM_API long devUnregisterAddress (epicsAddressType addrType, size_t logicalBaseAddress, const char *pOwnerName)
 Release a bus address range previously registered. More...
 
LIBCOM_API long devAllocAddress (const char *pOwnerName, epicsAddressType addrType, size_t size, unsigned alignment, volatile void **pLocalAddress)
 Allocate and register an unoccupied address block. More...
 
VME Interrupt Management

Routines to manage VME interrupts.

LIBCOM_API long devConnectInterruptVME (unsigned vectorNumber, void(*pFunction)(void *), void *parameter)
 Connect an ISR up to a VME interrupt vector. More...
 
LIBCOM_API long devDisconnectInterruptVME (unsigned vectorNumber, void(*pFunction)(void *))
 Disconnect an ISR from its VME interrupt vector. More...
 
LIBCOM_API int devInterruptInUseVME (unsigned vectorNumber)
 Determine if a VME interrupt vector is in use. More...
 
LIBCOM_API long devEnableInterruptLevelVME (unsigned level)
 Enable a VME interrupt level onto the CPU. More...
 
LIBCOM_API long devDisableInterruptLevelVME (unsigned level)
 Disable a VME interrupt level. More...
 
Memory for VME DMA Operations

These routines manage memory that can be directly accessed from the VMEbus in the A24 address space by another bus master such as a DMA controller.

LIBCOM_API void * devLibA24Malloc (size_t size)
 malloc() for VME drivers that support DMA. More...
 
LIBCOM_API void * devLibA24Calloc (size_t size)
 calloc() for VME drivers that support DMA. More...
 
LIBCOM_API void devLibA24Free (void *pBlock)
 free() for VME drivers that support DMA. More...
 
ISA Interrupt Management

Routines to manage ISAbus interrupts.

Note
These routines may not have been used for a very long time; some appear to have never been implemented at all. They may vanish with no notice from future versions of EPICS Base. Nobody is using the PC's ISA-bus any more are they?
LIBCOM_API long devConnectInterruptISA (unsigned interruptLevel, void(*pFunction)(void *), void *parameter)
 
LIBCOM_API long devDisconnectInterruptISA (unsigned interruptLevel, void(*pFunction)(void *))
 
LIBCOM_API int devInterruptLevelInUseISA (unsigned interruptLevel)
 
LIBCOM_API long devEnableInterruptLevelISA (unsigned level)
 
LIBCOM_API long devDisableInterruptLevelISA (unsigned level)
 

Variables

LIBCOM_API const char * epicsAddressTypeName []
 A string representation of each of the bus address types. More...
 

Deprecated Interfaces

enum  epicsInterruptType { intVME, intVXI, intISA }
 
LIBCOM_API long devConnectInterrupt (epicsInterruptType intType, unsigned vectorNumber, void(*pFunction)(void *), void *parameter)
 
LIBCOM_API long devDisconnectInterrupt (epicsInterruptType intType, unsigned vectorNumber, void(*pFunction)(void *))
 
LIBCOM_API long devEnableInterruptLevel (epicsInterruptType intType, unsigned level)
 
LIBCOM_API long devDisableInterruptLevel (epicsInterruptType intType, unsigned level)
 
LIBCOM_API long locationProbe (epicsAddressType addrType, char *pLocation)
 

Detailed Description

API for accessing hardware devices, mosty over VMEbus.

Author
Marty Kraimer, Jeff Hill API for accessing hardware devices. The original APIs here were for written for use with VMEbus but additional routines were added for ISA-bus (but not fully implemented inside EPICS Base and may never have been actually used).

If all VMEbus drivers register with these routines then addressing conflicts caused by multiple device/drivers trying to use the same VME addresses will be detected. This API also makes it easy for a single driver to be written that works on both VxWorks and RTEMS.

Definition in file devLibVME.h.

Enumeration Type Documentation

The available bus address types.

Enumerator
atVMEA16 

VME short I/O.

atVMEA24 

VME standard I/O.

atVMEA32 

VME extended I/O.

atISA 

Memory mapped ISA access.

atVMECSR 

VME-64 CR/CSR address space.

atLast 

Invalid, must be the last entry.

Definition at line 40 of file devLibVME.h.

40  {
41  atVMEA16,
42  atVMEA24,
43  atVMEA32,
44  atISA,
45  atVMECSR,
46  atLast
VME short I/O.
Definition: devLibVME.h:41
Memory mapped ISA access.
Definition: devLibVME.h:44
VME extended I/O.
Definition: devLibVME.h:43
epicsAddressType
The available bus address types.
Definition: devLibVME.h:40
VME-64 CR/CSR address space.
Definition: devLibVME.h:45
Invalid, must be the last entry.
Definition: devLibVME.h:46
VME standard I/O.
Definition: devLibVME.h:42
Enumerator
intVME 
intVXI 
intISA 

Definition at line 367 of file devLibVME.h.

Function Documentation

LIBCOM_API long devAddressMap ( void  )

Print a map of registered bus addresses.

Display a table of registsred bus address ranges, including the owner of each registered address.

Returns
0, or an error status value

Definition at line 737 of file devLibVME.c.

738 {
739  return devListAddressMap(addrAlloc);
740 }
LIBCOM_API long devAllocAddress ( const char *  pOwnerName,
epicsAddressType  addrType,
size_t  size,
unsigned  alignment,
volatile void **  pLocalAddress 
)

Allocate and register an unoccupied address block.

Asks devLib to allocate an address block of a particular address type. This is useful for devices that appear in more than one address space and can program the base address of one window using registers found in another window. As with devRegisterAddress() this call also converts the new base address into a pointer in the CPU address space for the driver to use (see devBusToLocalAddr()).

Note
This routine calls devNoResponseProbe() to find an unoccupied block in the bus address space, so using it may have a bad effect on a busy VMEbus at allocation time; see the warning above.
Parameters
pOwnerNameName of a driver that will own this range.
addrTypeThe bus address type.
sizeNumber of bytes to be allocated.
alignmentHow many low bits in the address must all be zero.
pLocalAddressWhere to put the CPU pointer.
Returns
0, or an error status value.

Definition at line 604 of file devLibVME.c.

610 {
611  int s;
612  rangeItem *pRange;
613  size_t base = 0;
614 
615  if (!devLibInitFlag) {
616  s = devLibInit();
617  if(s){
618  return s;
619  }
620  }
621 
622  s = addrVerify (addrType, 0, size);
623  if(s){
624  return s;
625  }
626 
627  if (size == 0) {
628  return S_dev_lowValue;
629  }
630 
631  epicsMutexMustLock(addrListLock);
632  pRange = (rangeItem *) ellFirst (&addrFree[addrType]);
633  while (pRange) {
634  if ((pRange->end - pRange->begin) + 1 >= size){
635  s = blockFind (
636  addrType,
637  pRange,
638  size,
639  alignment,
640  &base);
641  if (s==SUCCESS) {
642  break;
643  }
644  }
645  pRange = (rangeItem *) pRange->node.next;
646  }
647  epicsMutexUnlock(addrListLock);
648 
649  if(!pRange){
651  errMessage(s, epicsAddressTypeName[addrType]);
652  return s;
653  }
654 
655  s = devInstallAddr (pRange, pOwnerName, addrType, base,
656  size, pLocalAddress);
657 
658  return s;
659 }
size_t end
Definition: devLibVME.c:84
#define S_dev_deviceDoesNotFit
Unable to locate address space for device.
Definition: devLib.h:114
#define S_dev_lowValue
Parameter too low.
Definition: devLib.h:104
#define errMessage(S, PM)
Definition: errlog.h:48
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
Definition: epicsMutex.cpp:140
#define SUCCESS
Definition: devLibVME.c:137
ELLNODE node
Definition: devLibVME.c:75
const char * epicsAddressTypeName[]
A string representation of each of the bus address types.
Definition: devLibVME.c:66
size_t begin
Definition: devLibVME.c:83
struct ELLNODE * next
Pointer to next node in list.
Definition: ellLib.h:46
int * base
Definition: flex.c:92
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
Definition: epicsMutex.h:214
#define ellFirst(PLIST)
Find the first node in list.
Definition: ellLib.h:89
LIBCOM_API long devBusToLocalAddr ( epicsAddressType  addrType,
size_t  busAddr,
volatile void **  ppLocalAddr 
)

Translate a bus address to a pointer the CPU can use.

Given a bus address, returns a pointer to that location in the CPU's memory map, or an error if direct access isn't currently possible.

Parameters
addrTypeThe bus address type.
busAddrBus address to be translated.
*ppLocalAddrWhere to put the CPU pointer.
Returns
0, or an error status value.

Definition at line 142 of file devLibVME.c.

146 {
147  long status;
148  volatile void *localAddress;
149 
150  /*
151  * Make sure that devLib has been intialized
152  */
153  if (!devLibInitFlag) {
154  status = devLibInit();
155  if(status){
156  return status;
157  }
158  }
159 
160  /*
161  * Make sure we have a valid bus address
162  */
163  status = addrVerify (addrType, busAddr, 4);
164  if (status) {
165  return status;
166  }
167 
168  /*
169  * Call the virtual os routine to map the bus address to a CPU address
170  */
171  status = (*pdevLibVME->pDevMapAddr) (addrType, 0, busAddr, 4, &localAddress);
172  if (status) {
173  errPrintf (status, __FILE__, __LINE__, "%s bus address =0X%X\n",
174  epicsAddressTypeName[addrType], (unsigned int)busAddr);
175  return status;
176  }
177 
178  /*
179  * Return the local CPU address if the pointer is supplied
180  */
181  if (ppLocalAddress) {
182  *ppLocalAddress = localAddress;
183  }
184 
185  return SUCCESS;
186 
187 }/*end devBusToLocalAddr()*/
pvd::Status status
long(* pDevMapAddr)(epicsAddressType addrType, unsigned options, size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress)
Map a bus address to the CPU's address space.
Definition: devLibVMEImpl.h:39
#define SUCCESS
Definition: devLibVME.c:137
void errPrintf(long status, const char *pFileName, int lineno, const char *pformat,...)
Definition: errlog.c:383
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
const char * epicsAddressTypeName[]
A string representation of each of the bus address types.
Definition: devLibVME.c:66
LIBCOM_API long devConnectInterrupt ( epicsInterruptType  intType,
unsigned  vectorNumber,
void(*)(void *)  pFunction,
void *  parameter 
)
Note
This routine has been deprecated. It exists for backwards compatibility purposes only. Please use one of devConnectInterruptVME(), devConnectInterruptPCI(), devConnectInterruptISA() instead. devConnectInterrupt() will be removed in a future release.

Definition at line 992 of file devLibVME.c.

997 {
998  long status;
999 
1000  if (!devLibInitFlag) {
1001  status = devLibInit();
1002  if (status) {
1003  return status;
1004  }
1005  }
1006 
1007  switch(intType){
1008  case intVME:
1009  case intVXI:
1010  return (*pdevLibVME->pDevConnectInterruptVME) (vectorNumber,
1011  pFunction, parameter);
1012  default:
1013  return S_dev_uknIntType;
1014  }
1015 }
pvd::Status status
long(* pDevConnectInterruptVME)(unsigned vectorNumber, void(*pFunction)(void *), void *parameter)
Connect ISR to a VME interrupt vector.
Definition: devLibVMEImpl.h:50
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
#define S_dev_uknIntType
Unrecognized interrupt type.
Definition: devLib.h:62
LIBCOM_API long devConnectInterruptISA ( unsigned  interruptLevel,
void(*)(void *)  pFunction,
void *  parameter 
)

Connect ISR to a ISA interrupt.

Warning
Not implemented!
Parameters
interruptLevelBus interrupt level to connect to.
pFunctionC function pointer to connect to.
parameterParameter to the called function.
Returns
Returns success or error.
LIBCOM_API long devConnectInterruptVME ( unsigned  vectorNumber,
void(*)(void *)  pFunction,
void *  parameter 
)

Connect an ISR up to a VME interrupt vector.

Interrupt Service Routines (ISRs) are normally written in C, and get passed a context parameter given with them to this connection routine.

There are many restrictions on the routines that an ISR may call; see epicsEvent.h, epicsInterrupt.h, epicsMessageQueue.h, epicsRingBytes.h, epicsRingPointer.h and epicsTime.h for some APIs known to be suitable. It is safest just to trigger a high-priority task to handle any complex work that must happen as a result of the interrupt.

Parameters
vectorNumberVME interrupt vector number.
pFunctionThe ISR to be called.
parameterContext parameter for the ISR.
Returns
0, or an error status value.

Definition at line 911 of file devLibVME.c.

915 {
916  long status;
917 
918  if (!devLibInitFlag) {
919  status = devLibInit();
920  if (status) {
921  return status;
922  }
923  }
924 
925  return (*pdevLibVME->pDevConnectInterruptVME) (vectorNumber,
926  pFunction, parameter);
927 }
pvd::Status status
long(* pDevConnectInterruptVME)(unsigned vectorNumber, void(*pFunction)(void *), void *parameter)
Connect ISR to a VME interrupt vector.
Definition: devLibVMEImpl.h:50
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
LIBCOM_API long devDisableInterruptLevel ( epicsInterruptType  intType,
unsigned  level 
)
Note
This routine has been deprecated. It exists for backwards compatibility purposes only. Please use one of devDisableInterruptLevelVME(), devDisableInterruptLevelISA(), devDisableInterruptLevelPCI() instead. devDisableInterruptLevel() will be removed in a future release.

Definition at line 1080 of file devLibVME.c.

1083 {
1084  long status;
1085 
1086  if (!devLibInitFlag) {
1087  status = devLibInit();
1088  if (status) {
1089  return status;
1090  }
1091  }
1092 
1093  switch(intType){
1094  case intVME:
1095  case intVXI:
1096  return (*pdevLibVME->pDevDisableInterruptLevelVME) (level);
1097  default:
1098  return S_dev_uknIntType;
1099  }
1100 }
pvd::Status status
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
long(* pDevDisableInterruptLevelVME)(unsigned level)
Disable VME interrupt level to CPU.
Definition: devLibVMEImpl.h:59
#define S_dev_uknIntType
Unrecognized interrupt type.
Definition: devLib.h:62
LIBCOM_API long devDisableInterruptLevelISA ( unsigned  level)

Disable ISA interrupt level

Parameters
levelInterrupt level.
Returns
Returns True/False.

Definition at line 263 of file devLibVMEOSD.c.

264 {
265  if (sysIntDisablePICFunc) {
266  int s;
267  s = sysIntDisablePICFunc (level);
268  if (s!=OK) {
269  return S_dev_intEnFail;
270  }
271  } else {
272  return S_dev_intEnFail;
273  }
274 
275  return 0;
276 }
#define S_dev_intEnFail
Unable to enable interrupt level.
Definition: devLib.h:84
LIBCOM_API long devDisableInterruptLevelVME ( unsigned  level)

Disable a VME interrupt level.

This routine is the reverse of devEnableInterruptLevelVME().

Note
This routine should not normally be used, even by a driver that enabled the interrupt level. Disabling a VME interrupt level should only be done by software that knows for certain that no other interrupting device is also using that VME interrupt level.
Parameters
levelVMEbus interrupt level to disable, 1-7.
Returns
0, or an error status value.

Definition at line 973 of file devLibVME.c.

974 {
975  long status;
976 
977  if (!devLibInitFlag) {
978  status = devLibInit();
979  if (status) {
980  return status;
981  }
982  }
983 
984  return (*pdevLibVME->pDevDisableInterruptLevelVME) (level);
985 }
pvd::Status status
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
long(* pDevDisableInterruptLevelVME)(unsigned level)
Disable VME interrupt level to CPU.
Definition: devLibVMEImpl.h:59
LIBCOM_API long devDisconnectInterrupt ( epicsInterruptType  intType,
unsigned  vectorNumber,
void(*)(void *)  pFunction 
)
Note
This routine has been deprecated. It exists for backwards compatibility purposes only. Please use one of devDisconnectInterruptVME(), devDisconnectInterruptPCI(), devDisconnectInterruptISA() instead. devDisconnectInterrupt() will be removed in a future release.

Definition at line 1023 of file devLibVME.c.

1028 {
1029  long status;
1030 
1031  if (!devLibInitFlag) {
1032  status = devLibInit();
1033  if (status) {
1034  return status;
1035  }
1036  }
1037 
1038  switch(intType){
1039  case intVME:
1040  case intVXI:
1041  return (*pdevLibVME->pDevDisconnectInterruptVME) (vectorNumber,
1042  pFunction);
1043  default:
1044  return S_dev_uknIntType;
1045  }
1046 }
pvd::Status status
long(* pDevDisconnectInterruptVME)(unsigned vectorNumber, void(*pFunction)(void *))
Disconnect ISR from a VME interrupt vector.
Definition: devLibVMEImpl.h:53
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
#define S_dev_uknIntType
Unrecognized interrupt type.
Definition: devLib.h:62
LIBCOM_API long devDisconnectInterruptISA ( unsigned  interruptLevel,
void(*)(void *)  pFunction 
)

Disconnect ISR from a ISA interrupt level.

Warning
Not implemented!
Parameters
interruptLevelInterrupt level.
pFunctionC function pointer that was connected.
Returns
returns success or error.
LIBCOM_API long devDisconnectInterruptVME ( unsigned  vectorNumber,
void(*)(void *)  pFunction 
)

Disconnect an ISR from its VME interrupt vector.

Device drivers may disconnect an ISR they connected earlier using this routine. In addition to taking the vectorNumber the ISR itself is required and used as a check to prevent a driver from inadvertently removing an interrupt handler that it didn't install.

On a PowerPC target running VxWorks, this routine will always return with an error status.

Parameters
vectorNumberVME interrupt vector number.
pFunctionThe ISR to be disconnected.
Returns
0, or an error status value.

Definition at line 929 of file devLibVME.c.

932 {
933  long status;
934 
935  if (!devLibInitFlag) {
936  status = devLibInit();
937  if (status) {
938  return status;
939  }
940  }
941 
942  return (*pdevLibVME->pDevDisconnectInterruptVME) (vectorNumber, pFunction);
943 }
pvd::Status status
long(* pDevDisconnectInterruptVME)(unsigned vectorNumber, void(*pFunction)(void *))
Disconnect ISR from a VME interrupt vector.
Definition: devLibVMEImpl.h:53
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
LIBCOM_API long devEnableInterruptLevel ( epicsInterruptType  intType,
unsigned  level 
)
Note
This routine has been deprecated. It exists for backwards compatibility purposes only. Please use one of devEnableInterruptLevelVME(), devEnableInterruptLevelPCI(), devEnableInterruptLevelISA() instead. devEnableInterruptLevel() will be removed in a future release.

Definition at line 1053 of file devLibVME.c.

1056 {
1057  long status;
1058 
1059  if (!devLibInitFlag) {
1060  status = devLibInit();
1061  if (status) {
1062  return status;
1063  }
1064  }
1065 
1066  switch(intType){
1067  case intVME:
1068  case intVXI:
1069  return (*pdevLibVME->pDevEnableInterruptLevelVME) (level);
1070  default:
1071  return S_dev_uknIntType;
1072  }
1073 }
long(* pDevEnableInterruptLevelVME)(unsigned level)
Enable VME interrupt level to CPU.
Definition: devLibVMEImpl.h:57
pvd::Status status
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
#define S_dev_uknIntType
Unrecognized interrupt type.
Definition: devLib.h:62
LIBCOM_API long devEnableInterruptLevelISA ( unsigned  level)

Enable ISA interrupt level

Parameters
levelInterrupt level.
Returns
Returns True/False.

Definition at line 246 of file devLibVMEOSD.c.

247 {
248  if (sysIntEnablePICFunc) {
249  int s;
250  s = sysIntEnablePICFunc (level);
251  if (s!=OK) {
252  return S_dev_intEnFail;
253  }
254  return 0;
255  } else {
256  return S_dev_intEnFail;
257  }
258 }
#define S_dev_intEnFail
Unable to enable interrupt level.
Definition: devLib.h:84
LIBCOM_API long devEnableInterruptLevelVME ( unsigned  level)

Enable a VME interrupt level onto the CPU.

The VMEbus allows multiple CPU boards to be installed in the same backplane. When this is done, the differente VME interrupt levels must be assigned to the CPUs since they cannot be shared. This routine tells the VME interface that it should connect interrupts from the indicated interrupt level to a CPU interrupt line.

Parameters
levelVMEbus interrupt level to enable, 1-7.
Returns
0, or an error status value.

Definition at line 959 of file devLibVME.c.

960 {
961  long status;
962 
963  if (!devLibInitFlag) {
964  status = devLibInit();
965  if (status) {
966  return status;
967  }
968  }
969 
970  return (*pdevLibVME->pDevEnableInterruptLevelVME) (level);
971 }
long(* pDevEnableInterruptLevelVME)(unsigned level)
Enable VME interrupt level to CPU.
Definition: devLibVMEImpl.h:57
pvd::Status status
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
LIBCOM_API int devInterruptInUseVME ( unsigned  vectorNumber)

Determine if a VME interrupt vector is in use.

On a PowerPC target running VxWorks this routine will always return false, indicating that a vector is unused.

Parameters
vectorNumberInterrupt vector number.
Returns
True if vector has an ISR attached, otherwise false.

Definition at line 945 of file devLibVME.c.

946 {
947  long status;
948 
949  if (!devLibInitFlag) {
950  status = devLibInit();
951  if (status) {
952  return status;
953  }
954  }
955 
956  return (*pdevLibVME->pDevInterruptInUseVME) (level);
957 }
pvd::Status status
int(* pDevInterruptInUseVME)(unsigned vectorNumber)
Check if interrupt vector has an ISR connected.
Definition: devLibVMEImpl.h:70
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
LIBCOM_API int devInterruptLevelInUseISA ( unsigned  interruptLevel)

Determine if an ISA interrupt level is in use

Warning
Not implemented!
Parameters
interruptLevelInterrupt level.
Returns
Returns True/False.
LIBCOM_API void* devLibA24Calloc ( size_t  size)

calloc() for VME drivers that support DMA.

Allocate and zero-fill a block of memory of a given size from a region that can be accessed from the VMEbus in the A24 address space.

Parameters
sizeHow many bytes to allocate and zero.
Returns
A pointer to the memory allocated, or NULL.

Definition at line 1125 of file devLibVME.c.

1126 {
1127  void *ret;
1128 
1129  ret = devLibA24Malloc(size);
1130 
1131  if (ret == NULL)
1132  return (NULL);
1133 
1134  memset(ret, 0x00, size);
1135  return(ret);
1136 }
#define NULL
Definition: catime.c:38
void * devLibA24Malloc(size_t size)
malloc() for VME drivers that support DMA.
Definition: devLibVME.c:1138
LIBCOM_API void devLibA24Free ( void *  pBlock)

free() for VME drivers that support DMA.

Free a block of memory that was allocated using either devLibA24Malloc() or devLibA24Calloc().

Parameters
pBlockBlock to be released.

Definition at line 1149 of file devLibVME.c.

1150 {
1151  if (devLibA24Debug)
1152  epicsPrintf("devLibA24Free(%p) entered\n", pBlock);
1153 
1154  pdevLibVME->pDevA24Free(pBlock);
1155 }
int devLibA24Debug
Definition: devLibVME.c:1123
#define epicsPrintf
Definition: errlog.h:51
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
void(* pDevA24Free)(void *pBlock)
Free a block allocated for the VME A24 address space.
Definition: devLibVMEImpl.h:64
LIBCOM_API void* devLibA24Malloc ( size_t  size)

malloc() for VME drivers that support DMA.

Allocate memory of a given size from a region that can be accessed from the VMEbus in the A24 address space.

Parameters
sizeHow many bytes to allocate
Returns
A pointer to the memory allocated, or NULL.

Definition at line 1138 of file devLibVME.c.

1139 {
1140  void *ret;
1141 
1142  if (devLibA24Debug)
1143  epicsPrintf ("devLibA24Malloc(%u) entered\n", (unsigned int)size);
1144 
1145  ret = pdevLibVME->pDevA24Malloc(size);
1146  return(ret);
1147 }
int devLibA24Debug
Definition: devLibVME.c:1123
#define epicsPrintf
Definition: errlog.h:51
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
void *(* pDevA24Malloc)(size_t nbytes)
Malloc a block accessible from the VME A24 address space.
Definition: devLibVMEImpl.h:62
LIBCOM_API long devNoResponseProbe ( epicsAddressType  addrType,
size_t  base,
size_t  size 
)

Read-probe a range of bus addresses, looking for empty space.

Verifies that no device responds at any naturally aligned addresses within the given range. Tries to read every aligned address at every word size between char and long over the entire range, returning success only if none of the reads succeed.

Warning
This routine may be slow and have a very bad effect on a busy VMEbus. Every read probe of an unused address will hold onto the VMEbus for the global bus timeout period.
Parameters
addrTypeThe bus address type.
baseFirst address base to probe.
sizeRange of bus addresses to test, in bytes.
Returns
0 if no devices respond, or an error status value.

Definition at line 847 of file devLibVME.c.

849 {
850  volatile void *pPhysical;
851  size_t probe;
852  size_t byteNo;
853  unsigned wordSize;
854  union {
855  char charWord;
856  short shortWord;
857  int intWord;
858  long longWord;
859  }allWordSizes;
860  long s;
861 
862  if (!devLibInitFlag) {
863  s = devLibInit();
864  if (s) {
865  return s;
866  }
867  }
868 
869  byteNo = 0;
870  while (byteNo < size) {
871 
872  probe = base + byteNo;
873 
874  /*
875  * for all word sizes
876  */
877  for (wordSize=1; wordSize<=sizeof(allWordSizes); wordSize <<= 1) {
878  /*
879  * only check naturally aligned words
880  */
881  if ( (probe&(wordSize-1)) != 0 ) {
882  break;
883  }
884 
885  if (byteNo+wordSize>size) {
886  break;
887  }
888 
889  /*
890  * every byte in the block must
891  * map to a physical address
892  */
893  s = (*pdevLibVME->pDevMapAddr) (addrType, 0, probe, wordSize, &pPhysical);
894  if (s!=SUCCESS) {
895  return s;
896  }
897 
898  /*
899  * verify that no device is present
900  */
901  s = (*pdevLibVME->pDevReadProbe)(wordSize, pPhysical, &allWordSizes);
902  if (s==SUCCESS) {
903  return S_dev_addressOverlap;
904  }
905  }
906  byteNo++;
907  }
908  return SUCCESS;
909 }
#define S_dev_addressOverlap
Specified device address overlaps another device.
Definition: devLib.h:74
long(* pDevMapAddr)(epicsAddressType addrType, unsigned options, size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress)
Map a bus address to the CPU&#39;s address space.
Definition: devLibVMEImpl.h:39
#define SUCCESS
Definition: devLibVME.c:137
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
long(* pDevReadProbe)(unsigned wordSize, volatile const void *ptr, void *pValueRead)
Read a word, detect and protect against bus errors.
Definition: devLibVMEImpl.h:43
int * base
Definition: flex.c:92
LIBCOM_API long devReadProbe ( unsigned  wordSize,
volatile const void *  ptr,
void *  pValueRead 
)

Probe the bus for reading from a specific address.

Performs a bus-error-safe wordSize atomic read from a specific address and returns an error if this caused a bus error.

Parameters
wordSizeThe word size to read: 1, 2, 4 or 8 bytes.
ptrPointer to the location in the CPU's memory map to read.
pValueReadWhere to put the value read.
Returns
0, or an error status value if the location could not be accessed or the read caused a bus error.

Definition at line 268 of file devLibVME.c.

269 {
270  long status;
271 
272  if (!devLibInitFlag) {
273  status = devLibInit();
274  if (status) {
275  return status;
276  }
277  }
278 
279  return (*pdevLibVME->pDevReadProbe) (wordSize, ptr, pValue);
280 }
pvd::Status status
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
long(* pDevReadProbe)(unsigned wordSize, volatile const void *ptr, void *pValueRead)
Read a word, detect and protect against bus errors.
Definition: devLibVMEImpl.h:43
LIBCOM_API long devRegisterAddress ( const char *  pOwnerName,
epicsAddressType  addrType,
size_t  logicalBaseAddress,
size_t  size,
volatile void **  pPhysicalAddress 
)

Register a bus address range with a name.

The devLib code keeps a list of all bus address ranges registered with this routine and returns an error if a later call attempts to register any addresses that overlap with a range already registered. The call to registering a range also converts the given base address into a pointer in the CPU address space for the driver to use (see devBusToLocalAddr()).

Parameters
pOwnerNameName of a driver that will own this range.
addrTypeThe bus address type.
logicalBaseAddressThe bus start address.
sizeNumber of bytes to reserve.
pPhysicalAddressWhere to put the converted CPU pointer.
Returns
0, or an error status.

Definition at line 193 of file devLibVME.c.

199 {
200  rangeItem *pRange;
201  long s;
202 
203  if (!devLibInitFlag) {
204  s = devLibInit();
205  if(s){
206  return s;
207  }
208  }
209 
210  s = addrVerify (addrType, base, size);
211  if (s) {
212  return s;
213  }
214 
215  if (size == 0) {
216  return S_dev_lowValue;
217  }
218 
219 #ifdef DEBUG
220  printf ("Req Addr 0X%X Size 0X%X\n", base, size);
221 #endif
222 
223  epicsMutexMustLock(addrListLock);
224  pRange = (rangeItem *) ellFirst(&addrFree[addrType]);
225  while (TRUE) {
226  if (pRange->begin > base) {
227  pRange = NULL;
228 # ifdef DEBUG
229  printf ("Unable to locate a free block\n");
230  devListAddressMap (&addrFree[addrType]);
231 # endif
232  break;
233  }
234  else if (base + (size - 1) <= pRange->end) {
235 # ifdef DEBUG
236  printf ("Found free block Begin 0X%X End 0X%X\n",
237  pRange->begin, pRange->end);
238 # endif
239  break;
240  }
241 
242  pRange = (rangeItem *) ellNext (&pRange->node);
243  }
244  epicsMutexUnlock(addrListLock);
245 
246  if (pRange==NULL) {
247  report_conflict (addrType, base, size, pOwnerName);
248  return S_dev_addressOverlap;
249  }
250 
251  s = devInstallAddr(
252  pRange, /* item on the free list to be split */
253  pOwnerName,
254  addrType,
255  base,
256  size,
257  ppPhysicalAddress);
258 
259  return s;
260 }
size_t end
Definition: devLibVME.c:84
#define S_dev_addressOverlap
Specified device address overlaps another device.
Definition: devLib.h:74
#define printf
Definition: epicsStdio.h:41
#define S_dev_lowValue
Parameter too low.
Definition: devLib.h:104
#define NULL
Definition: catime.c:38
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
Definition: epicsMutex.cpp:140
#define ellNext(PNODE)
Find the next node in list.
Definition: ellLib.h:99
ELLNODE node
Definition: devLibVME.c:75
size_t begin
Definition: devLibVME.c:83
#define TRUE
Definition: dbDefs.h:27
int * base
Definition: flex.c:92
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
Definition: epicsMutex.h:214
#define ellFirst(PLIST)
Find the first node in list.
Definition: ellLib.h:89
LIBCOM_API long devUnregisterAddress ( epicsAddressType  addrType,
size_t  logicalBaseAddress,
const char *  pOwnerName 
)

Release a bus address range previously registered.

Release an address range that was previously registered by a call to devRegisterAddress() or devAllocAddress().

Parameters
addrTypeThe bus address type.
logicalBaseAddressThe bus start address.
pOwnerNameThe name of the driver that owns this range.
Returns
0, or an error status.

Definition at line 467 of file devLibVME.c.

471 {
472  rangeItem *pRange;
473  int s;
474 
475  if (!devLibInitFlag) {
476  s = devLibInit();
477  if(s) {
478  return s;
479  }
480  }
481 
482  s = addrVerify (addrType, baseAddress, 1);
483  if (s != SUCCESS) {
484  return s;
485  }
486 
487  epicsMutexMustLock(addrListLock);
488  pRange = (rangeItem *) ellFirst(&addrAlloc[addrType]);
489  while (pRange) {
490  if (pRange->begin == baseAddress) {
491  break;
492  }
493  if (pRange->begin > baseAddress) {
494  pRange = NULL;
495  break;
496  }
497  pRange = (rangeItem *) ellNext(&pRange->node);
498  }
499  epicsMutexUnlock(addrListLock);
500 
501  if (!pRange) {
502  return S_dev_addressNotFound;
503  }
504 
505  if (strcmp(pOwnerName,pRange->pOwnerName)) {
507  errPrintf (
508  s,
509  __FILE__,
510  __LINE__,
511  "unregister address for %s at 0X%X failed because %s owns it",
512  pOwnerName,
513  (unsigned int)baseAddress,
514  pRange->pOwnerName);
515  return s;
516  }
517 
518  epicsMutexMustLock(addrListLock);
519  ellDelete (&addrAlloc[addrType], &pRange->node);
520  epicsMutexUnlock(addrListLock);
521 
522  pRange->pOwnerName = "<released fragment>";
523  devInsertAddress (&addrFree[addrType], pRange);
524  s = devCombineAdjacentBlocks (&addrFree[addrType], pRange);
525  if(s){
526  errMessage (s, "devCombineAdjacentBlocks error");
527  return s;
528  }
529 
530  return SUCCESS;
531 }
#define S_dev_addressNotFound
Specified device address unregistered.
Definition: devLib.h:90
#define S_dev_addressOverlap
Specified device address overlaps another device.
Definition: devLib.h:74
#define NULL
Definition: catime.c:38
#define errMessage(S, PM)
Definition: errlog.h:48
void epicsStdCall epicsMutexUnlock(epicsMutexId pmutexNode)
Release the semaphore.
Definition: epicsMutex.cpp:140
#define SUCCESS
Definition: devLibVME.c:137
#define ellNext(PNODE)
Find the next node in list.
Definition: ellLib.h:99
void errPrintf(long status, const char *pFileName, int lineno, const char *pformat,...)
Definition: errlog.c:383
ELLNODE node
Definition: devLibVME.c:75
const char * pOwnerName
Definition: devLibVME.c:76
size_t begin
Definition: devLibVME.c:83
#define epicsMutexMustLock(ID)
Claim a semaphore (see epicsMutexLock()).
Definition: epicsMutex.h:214
void ellDelete(ELLLIST *pList, ELLNODE *pNode)
Deletes a node from a list.
Definition: ellLib.c:75
#define ellFirst(PLIST)
Find the first node in list.
Definition: ellLib.h:89
LIBCOM_API long devWriteProbe ( unsigned  wordSize,
volatile void *  ptr,
const void *  pValueWritten 
)

Probe the bus for writing to a specific address.

Performs a bus-error-safe wordSize atomic write to a specific address and returns an error if this caused a bus error.

Parameters
wordSizeThe word size to write: 1, 2, 4 or 8 bytes.
ptrPointer to the location in the CPU's memory map to write to.
pValueWrittenThe value to write.
Returns
0, or an error status value if the location could not be accessed or the write caused a bus error.

Definition at line 288 of file devLibVME.c.

289 {
290  long status;
291 
292  if (!devLibInitFlag) {
293  status = devLibInit();
294  if (status) {
295  return status;
296  }
297  }
298 
299  return (*pdevLibVME->pDevWriteProbe) (wordSize, ptr, pValue);
300 }
pvd::Status status
LIBCOM_API devLibVME * pdevLibVME
Pointer to the entry table used by devLibVME routines.
Definition: devLibVMEOSD.c:12
long(* pDevWriteProbe)(unsigned wordSize, volatile void *ptr, const void *pValueWritten)
Write a word, detect and protect against bus errors.
Definition: devLibVMEImpl.h:46
LIBCOM_API long locationProbe ( epicsAddressType  addrType,
char *  pLocation 
)
Note
This routine has been deprecated. It exists for backwards compatibility purposes only. Please use devNoResponseProbe() instead. locationProbe() will be removed in a future release.

Definition at line 1107 of file devLibVME.c.

1108 {
1109  return devNoResponseProbe (addrType, (size_t) pLocation, sizeof(long));
1110 }
long devNoResponseProbe(epicsAddressType addrType, size_t base, size_t size)
Read-probe a range of bus addresses, looking for empty space.
Definition: devLibVME.c:847

Variable Documentation

LIBCOM_API const char* epicsAddressTypeName[]

A string representation of each of the bus address types.

Definition at line 66 of file devLibVME.c.