Merged Michael's devlib-cleanup branch

This commit is contained in:
Andrew Johnson
2010-07-01 11:59:22 -05:00
10 changed files with 621 additions and 408 deletions

View File

@@ -12,6 +12,25 @@
<h2 align="center">Changes between 3.14.11 and 3.14.12</h2>
<!-- Insert new items immediately below here ... -->
<h4>devLib cleanup</h4>
<ul>
<li>Add VME connect/disconnect IRQ calls to the "virtual os" table</li>
<li>It is now possible to compile all devLib code on targets without runtime
support</li>
<li>All internal functions are made static. Some were not before.</li>
<li>Move VME calls to <tt>devLibVME.h</tt>. <tt>devLib.h</tt> contains general
defintions and error codes.</li>
<li>For compatibility <tt>devLib.h</tt> includes <tt>devLibVME.h</tt> unless the
macro <tt>NO_DEVLIB_COMPAT</tt> is defined.</li>
<li>The "virtual os" table was renamed from <tt>pdevLibVirtualOS</tt> to
<tt>pdevLibVME</tt> reflecting the fact that other bus types will need seperate
tables.</li>
<li>The "virtual os" table API has been moved to a seperate header file,
<tt>devLibVMEImpl.h</tt>.</li>
</ul>
<h4>DTYP and INP/OUT order</h4>
<p>The fields DTYP and INP/OUT can now be specified in any order.</p>

View File

@@ -192,6 +192,8 @@ INC += epicsStdioRedirect.h
INC += epicsGetopt.h
INC += devLib.h
INC += devLibVME.h
INC += devLibVMEImpl.h
INC += osdVME.h
SRCS += epicsThread.cpp
@@ -230,8 +232,8 @@ SRCS += osdProcess.c
SRCS += osdNetIntf.c
SRCS += osdMessageQueue.c
SRCS += devLib.c
SRCS += devLibOSD.c
SRCS += devLibVME.c
SRCS += devLibVMEOSD.c
SRC_DIRS += $(LIBCOM)/taskwd
INC += taskwd.h

View File

@@ -1,252 +1,27 @@
/*************************************************************************\
* Copyright (c) 2010 Brookhaven Science Associates, as Operator of
* Brookhaven National Laboratory.
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* devLib.h */
/* $Id$ */
/*
* Original Author: Marty Kraimer
* Original Author: Marty Kraimer
* Author: Jeff Hill
* Date: 03-10-93
*/
#ifndef INCdevLibh
#define INCdevLibh 1
#include "dbDefs.h"
#include "osdVME.h"
#include "errMdef.h"
#include "shareLib.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef EPICSDEVLIB_H
#define EPICSDEVLIB_H
/*
* epdevAddressType & EPICStovxWorksAddrType
* devLib.c must change in unison
* Support macros
*/
typedef enum {
atVMEA16,
atVMEA24,
atVMEA32,
atISA, /* memory mapped ISA access (until now only on PC) */
atVMECSR, /* VME-64 CR/CSR address space */
atLast /* atLast must be the last enum in this list */
} epicsAddressType;
/*
* pointer to an array of strings for each of
* the above address types
*/
extern const char *epicsAddressTypeName[];
epicsShareFunc long devAddressMap(void); /* print an address map */
/*
* devBusToLocalAddr()
*
* OSI routine to translate bus addresses their local CPU address mapping
*/
epicsShareFunc long devBusToLocalAddr (
epicsAddressType addrType,
size_t busAddr,
volatile void **ppLocalAddr);
/*
* devReadProbe()
*
* a bus error safe "wordSize" read at the specified address which returns
* unsuccessful status if the device isnt present
*/
epicsShareFunc long devReadProbe (
unsigned wordSize, volatile const void *ptr, void *pValueRead);
/*
* devNoResponseProbe()
*
* Verifies that no devices respond at naturally aligned words
* within the specified address range. Return success if no devices
* respond. Returns an error if a device does respond or if
* a physical address for a naturally aligned word cant be mapped.
* Checks all naturally aligned word sizes between char and long for
* the entire specified range of bytes.
*/
epicsShareFunc long devNoResponseProbe(
epicsAddressType addrType,
size_t base,
size_t size
);
/*
* devWriteProbe
*
* a bus error safe "wordSize" write at the specified address which returns
* unsuccessful status if the device isnt present
*/
epicsShareFunc long devWriteProbe (
unsigned wordSize, volatile void *ptr, const void *pValueWritten);
epicsShareFunc long devRegisterAddress(
const char *pOwnerName,
epicsAddressType addrType,
size_t logicalBaseAddress,
size_t size, /* bytes */
volatile void **pPhysicalAddress);
epicsShareFunc long devUnregisterAddress(
epicsAddressType addrType,
size_t logicalBaseAddress,
const char *pOwnerName);
/*
* allocate and register an unoccupied address block
*/
epicsShareFunc long devAllocAddress(
const char *pOwnerName,
epicsAddressType addrType,
size_t size,
unsigned alignment, /*n ls bits zero in addr*/
volatile void **pLocalAddress);
/*
* connect ISR to a VME interrupt vector
*/
epicsShareFunc long devConnectInterruptVME(
unsigned vectorNumber,
void (*pFunction)(void *),
void *parameter);
/*
* connect ISR to an ISA interrupt level
* (not implemented)
* (API should be reviewed)
*/
epicsShareFunc long devConnectInterruptISA(
unsigned interruptLevel,
void (*pFunction)(void *),
void *parameter);
/*
* connect ISR to a PCI interrupt
* (not implemented)
* (API should be reviewed)
*/
epicsShareFunc long devConnectInterruptPCI(
unsigned bus,
unsigned device,
unsigned function,
void (*pFunction)(void *),
void *parameter);
/*
* disconnect ISR from a VME interrupt vector
*
* The parameter pFunction should be set to the C function pointer that
* was connected. It is used as a key to prevent a driver from inadvertently
* removing an interrupt handler that it didn't install
*/
epicsShareFunc long devDisconnectInterruptVME(
unsigned vectorNumber,
void (*pFunction)(void *));
/*
* disconnect ISR from an ISA interrupt level
* (not implemented)
* (API should be reviewed)
*
* The parameter pFunction should be set to the C function pointer that
* was connected. It is used as a key to prevent a driver from inadvertently
* removing an interrupt handler that it didn't install
*/
epicsShareFunc long devDisconnectInterruptISA(
unsigned interruptLevel,
void (*pFunction)(void *));
/*
* disconnect ISR from a PCI interrupt
* (not implemented)
* (API should be reviewed)
*
* The parameter pFunction should be set to the C function pointer that
* was connected. It is used as a key to prevent a driver from inadvertently
* removing an interrupt handler that it didn't install
*/
epicsShareFunc long devDisconnectInterruptPCI(
unsigned bus,
unsigned device,
unsigned function,
void (*pFunction)(void *));
/*
* determine if a VME interrupt vector is in use
*
* returns boolean
*/
epicsShareFunc int devInterruptInUseVME (unsigned vectorNumber);
/*
* determine if an ISA interrupt level is in use
* (not implemented)
*
* returns boolean
*/
epicsShareFunc int devInterruptLevelInUseISA (unsigned interruptLevel);
/*
* determine if a PCI interrupt is in use
* (not implemented)
*
* returns boolean
*/
epicsShareFunc int devInterruptInUsePCI (unsigned bus, unsigned device,
unsigned function);
typedef enum {intVME, intVXI, intISA} epicsInterruptType;
/*
* enable VME interrupt level
*/
epicsShareFunc long devEnableInterruptLevelVME (unsigned level);
/*
* enable ISA interrupt level
*/
epicsShareFunc long devEnableInterruptLevelISA (unsigned level);
/*
* not implemented - API needs to be reviewed
*/
epicsShareFunc long devEnableInterruptLevelPCI (unsigned level,
unsigned bus, unsigned device, unsigned function);
/*
* disable VME interrupt level
*/
epicsShareFunc long devDisableInterruptLevelVME (unsigned level);
/*
* disable ISA interrupt level
*/
epicsShareFunc long devDisableInterruptLevelISA (unsigned level);
/*
* not implemented - API needs to be reviewed
*/
epicsShareFunc long devDisableInterruptLevelPCI (unsigned level,
unsigned bus, unsigned device, unsigned function);
/*
* Routines to allocate and free memory in the A24 memory region.
*
*/
epicsShareFunc void *devLibA24Malloc(size_t);
epicsShareFunc void *devLibA24Calloc(size_t);
epicsShareFunc void devLibA24Free(void *pBlock);
/*
* Normalize a digital value and convert it to type TYPE
@@ -280,59 +55,6 @@ epicsShareFunc void devLibA24Free(void *pBlock);
*/
#define devPtrAlignTest(PTR) (!(devCreateAlignmentMask(*PTR)&(long)(PTR)))
/*
* virtual OS layer for devLib.c
*/
typedef struct devLibVirtualOS {
/*
* maps logical address to physical address, but does not detect
* two device drivers that are using the same address range
*/
long (*pDevMapAddr) (epicsAddressType addrType, unsigned options,
size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress);
/*
* a bus error safe "wordSize" read at the specified address which returns
* unsuccessful status if the device isnt present
*/
long (*pDevReadProbe) (unsigned wordSize, volatile const void *ptr, void *pValueRead);
/*
* a bus error safe "wordSize" write at the specified address which returns
* unsuccessful status if the device isnt present
*/
long (*pDevWriteProbe) (unsigned wordSize, volatile void *ptr, const void *pValueWritten);
/*
* connect ISR to a VME interrupt vector
* (required for backwards compatibility)
*/
long (*pDevConnectInterruptVME) (unsigned vectorNumber,
void (*pFunction)(void *), void *parameter);
/*
* disconnect ISR from a VME interrupt vector
* (required for backwards compatibility)
*/
long (*pDevDisconnectInterruptVME) (unsigned vectorNumber,
void (*pFunction)(void *));
/*
* enable VME interrupt level
*/
long (*pDevEnableInterruptLevelVME) (unsigned level);
/*
* disable VME interrupt level
*/
long (*pDevDisableInterruptLevelVME) (unsigned level);
/* malloc/free A24 address space */
void *(*pDevA24Malloc)(size_t nbytes);
void (*pDevA24Free)(void *pBlock);
long (*pDevInit)(void);
}devLibVirtualOS;
epicsShareExtern devLibVirtualOS *pdevLibVirtualOS;
/*
* error codes (and messages) associated with devLib.c
*/
@@ -374,71 +96,12 @@ epicsShareExtern devLibVirtualOS *pdevLibVirtualOS;
#define S_dev_badCRCSR (M_devLib| 35) /*Invalid VME CR/CSR address*/
#define S_dev_vxWorksIntEnFail S_dev_intEnFail
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devConnectInterruptVME, devConnectInterruptPCI,
* devConnectInterruptISA etc. devConnectInterrupt will be removed
* in a future release.
*/
epicsShareFunc long devConnectInterrupt(
epicsInterruptType intType,
unsigned vectorNumber,
void (*pFunction)(void *),
void *parameter);
#endif /* EPICSDEVLIB_H */
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devDisconnectInterruptVME, devDisconnectInterruptPCI,
* devDisconnectInterruptISA etc. devDisconnectInterrupt will be removed
* in a future release.
* Retain compatibility by including VME by default
*/
epicsShareFunc long devDisconnectInterrupt(
epicsInterruptType intType,
unsigned vectorNumber,
void (*pFunction)(void *));
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devEnableInterruptLevelVME, devEnableInterruptLevelPCI,
* devEnableInterruptLevelISA etc. devEnableInterruptLevel will be removed
* in a future release.
*/
epicsShareFunc long devEnableInterruptLevel(
epicsInterruptType intType, unsigned level);
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devDisableInterruptLevelVME, devDisableInterruptLevelISA,
* devDisableInterruptLevelPCI etc. devDisableInterruptLevel will be removed
* in a future release.
*/
epicsShareFunc long devDisableInterruptLevel (
epicsInterruptType intType, unsigned level);
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use devNoResponseProbe(). locationProbe() will be removed
* in a future release.
*/
epicsShareFunc long locationProbe (epicsAddressType addrType, char *pLocation);
/*
* Some vxWorks convenience routines
*/
void bcopyLongs(char *source, char *destination, int nlongs);
#ifdef __cplusplus
}
#ifndef NO_DEVLIB_COMPAT
# include "devLibVME.h"
#endif
#endif /* INCdevLibh.h*/

View File

@@ -1,4 +1,6 @@
/*************************************************************************\
* Copyright (c) 2010 Brookhaven Science Associates, as Operator of
* Brookhaven National Laboratory.
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
@@ -29,7 +31,10 @@ static const char sccsID[] = "@(#) $Id$";
#include "epicsMutex.h"
#include "errlog.h"
#include "ellLib.h"
#include "devLib.h"
#define NO_DEVLIB_COMPAT
#include "devLibVME.h"
#include "devLibVMEImpl.h"
static ELLLIST addrAlloc[atLast];
static ELLLIST addrFree[atLast];
@@ -167,7 +172,7 @@ long devBusToLocalAddr(
/*
* Call the virtual os routine to map the bus address to a CPU address
*/
status = (*pdevLibVirtualOS->pDevMapAddr) (addrType, 0, busAddr, 4, &localAddress);
status = (*pdevLibVME->pDevMapAddr) (addrType, 0, busAddr, 4, &localAddress);
if (status) {
errPrintf (status, __FILE__, __LINE__, "%s bus address =0X%X\n",
epicsAddressTypeName[addrType], (unsigned int)busAddr);
@@ -275,7 +280,7 @@ long devReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue)
}
}
return (*pdevLibVirtualOS->pDevReadProbe) (wordSize, ptr, pValue);
return (*pdevLibVME->pDevReadProbe) (wordSize, ptr, pValue);
}
/*
@@ -295,7 +300,7 @@ long devWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue)
}
}
return (*pdevLibVirtualOS->pDevWriteProbe) (wordSize, ptr, pValue);
return (*pdevLibVME->pDevWriteProbe) (wordSize, ptr, pValue);
}
/*
@@ -332,7 +337,7 @@ static long devInstallAddr (
* always map through the virtual os in case the memory
* management is set up there
*/
status = (*pdevLibVirtualOS->pDevMapAddr) (addrType, 0, base,
status = (*pdevLibVME->pDevMapAddr) (addrType, 0, base,
size, &pPhysicalAddress);
if (status) {
errPrintf (status, __FILE__, __LINE__, "%s base=0X%X size = 0X%X",
@@ -697,8 +702,8 @@ static long devLibInit (void)
if(devLibInitFlag) return(SUCCESS);
if(!pdevLibVirtualOS) {
epicsPrintf ("pdevLibVirtualOS is NULL\n");
if(!pdevLibVME) {
epicsPrintf ("pdevLibVME is NULL\n");
return S_dev_internal;
}
@@ -727,7 +732,7 @@ static long devLibInit (void)
}
epicsMutexUnlock(addrListLock);
devLibInitFlag = TRUE;
return pdevLibVirtualOS->pDevInit();
return pdevLibVME->pDevInit();
}
/*
@@ -889,7 +894,7 @@ long devNoResponseProbe (epicsAddressType addrType,
* every byte in the block must
* map to a physical address
*/
s = (*pdevLibVirtualOS->pDevMapAddr) (addrType, 0, probe, wordSize, &pPhysical);
s = (*pdevLibVME->pDevMapAddr) (addrType, 0, probe, wordSize, &pPhysical);
if (s!=SUCCESS) {
return s;
}
@@ -897,7 +902,7 @@ long devNoResponseProbe (epicsAddressType addrType,
/*
* verify that no device is present
*/
s = (*pdevLibVirtualOS->pDevReadProbe)(wordSize, pPhysical, &allWordSizes);
s = (*pdevLibVME->pDevReadProbe)(wordSize, pPhysical, &allWordSizes);
if (s==SUCCESS) {
return S_dev_addressOverlap;
}
@@ -907,6 +912,82 @@ long devNoResponseProbe (epicsAddressType addrType,
return SUCCESS;
}
long devConnectInterruptVME(
unsigned vectorNumber,
void (*pFunction)(void *),
void *parameter )
{
long status;
if (!devLibInitFlag) {
status = devLibInit();
if (status) {
return status;
}
}
return (*pdevLibVME->pDevConnectInterruptVME) (vectorNumber,
pFunction, parameter);
}
long devDisconnectInterruptVME(
unsigned vectorNumber,
void (*pFunction)(void *) )
{
long status;
if (!devLibInitFlag) {
status = devLibInit();
if (status) {
return status;
}
}
return (*pdevLibVME->pDevDisconnectInterruptVME) (vectorNumber, pFunction);
}
int devInterruptInUseVME (unsigned level)
{
long status;
if (!devLibInitFlag) {
status = devLibInit();
if (status) {
return status;
}
}
return (*pdevLibVME->pDevInterruptInUseVME) (level);
}
long devEnableInterruptLevelVME (unsigned level)
{
long status;
if (!devLibInitFlag) {
status = devLibInit();
if (status) {
return status;
}
}
return (*pdevLibVME->pDevEnableInterruptLevelVME) (level);
}
long devDisableInterruptLevelVME (unsigned level)
{
long status;
if (!devLibInitFlag) {
status = devLibInit();
if (status) {
return status;
}
}
return (*pdevLibVME->pDevDisableInterruptLevelVME) (level);
}
/*
* devConnectInterrupt ()
*
@@ -930,7 +1011,7 @@ void *parameter)
switch(intType){
case intVME:
case intVXI:
return (*pdevLibVirtualOS->pDevConnectInterruptVME) (vectorNumber,
return (*pdevLibVME->pDevConnectInterruptVME) (vectorNumber,
pFunction, parameter);
default:
return S_dev_uknIntType;
@@ -961,7 +1042,7 @@ void (*pFunction)(void *)
switch(intType){
case intVME:
case intVXI:
return (*pdevLibVirtualOS->pDevDisconnectInterruptVME) (vectorNumber,
return (*pdevLibVME->pDevDisconnectInterruptVME) (vectorNumber,
pFunction);
default:
return S_dev_uknIntType;
@@ -989,7 +1070,7 @@ unsigned level)
switch(intType){
case intVME:
case intVXI:
return (*pdevLibVirtualOS->pDevEnableInterruptLevelVME) (level);
return (*pdevLibVME->pDevEnableInterruptLevelVME) (level);
default:
return S_dev_uknIntType;
}
@@ -1016,7 +1097,7 @@ unsigned level)
switch(intType){
case intVME:
case intVXI:
return (*pdevLibVirtualOS->pDevDisableInterruptLevelVME) (level);
return (*pdevLibVME->pDevDisableInterruptLevelVME) (level);
default:
return S_dev_uknIntType;
}
@@ -1065,7 +1146,7 @@ void *devLibA24Malloc(size_t size)
if (devLibA24Debug)
epicsPrintf ("devLibA24Malloc(%u) entered\n", (unsigned int)size);
ret = pdevLibVirtualOS->pDevA24Malloc(size);
ret = pdevLibVME->pDevA24Malloc(size);
return(ret);
}
@@ -1074,5 +1155,5 @@ void devLibA24Free(void *pBlock)
if (devLibA24Debug)
epicsPrintf("devLibA24Free(%p) entered\n", pBlock);
pdevLibVirtualOS->pDevA24Free(pBlock);
pdevLibVME->pDevA24Free(pBlock);
}

312
src/libCom/osi/devLibVME.h Normal file
View File

@@ -0,0 +1,312 @@
/*************************************************************************\
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* devLib.h */
/* devLib.h,v 1.1.2.8 2009/07/09 15:27:43 anj Exp */
/*
* Original Author: Marty Kraimer
* Author: Jeff Hill
* Date: 03-10-93
*/
#ifndef INCdevLibh
#define INCdevLibh 1
#include "dbDefs.h"
#include "osdVME.h"
#include "errMdef.h"
#include "shareLib.h"
#include "devLib.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* epdevAddressType & EPICStovxWorksAddrType
* devLib.c must change in unison
*/
typedef enum {
atVMEA16,
atVMEA24,
atVMEA32,
atISA, /* memory mapped ISA access (until now only on PC) */
atVMECSR, /* VME-64 CR/CSR address space */
atLast /* atLast must be the last enum in this list */
} epicsAddressType;
/*
* pointer to an array of strings for each of
* the above address types
*/
epicsShareExtern const char *epicsAddressTypeName[];
#ifdef __cplusplus
}
#endif
/*
* To retain compatibility include everything by default
*/
#ifndef NO_DEVLIB_COMPAT
# include "devLibVMEImpl.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* General API
*
* This section applies to all bus types
*/
epicsShareFunc long devAddressMap(void); /* print an address map */
/*
* devBusToLocalAddr()
*
* OSI routine to translate bus addresses their local CPU address mapping
*/
epicsShareFunc long devBusToLocalAddr (
epicsAddressType addrType,
size_t busAddr,
volatile void **ppLocalAddr);
/*
* devReadProbe()
*
* a bus error safe "wordSize" read at the specified address which returns
* unsuccessful status if the device isnt present
*/
epicsShareFunc long devReadProbe (
unsigned wordSize, volatile const void *ptr, void *pValueRead);
/*
* devNoResponseProbe()
*
* Verifies that no devices respond at naturally aligned words
* within the specified address range. Return success if no devices
* respond. Returns an error if a device does respond or if
* a physical address for a naturally aligned word cant be mapped.
* Checks all naturally aligned word sizes between char and long for
* the entire specified range of bytes.
*/
epicsShareFunc long devNoResponseProbe(
epicsAddressType addrType,
size_t base,
size_t size
);
/*
* devWriteProbe
*
* a bus error safe "wordSize" write at the specified address which returns
* unsuccessful status if the device isnt present
*/
epicsShareFunc long devWriteProbe (
unsigned wordSize, volatile void *ptr, const void *pValueWritten);
epicsShareFunc long devRegisterAddress(
const char *pOwnerName,
epicsAddressType addrType,
size_t logicalBaseAddress,
size_t size, /* bytes */
volatile void **pPhysicalAddress);
epicsShareFunc long devUnregisterAddress(
epicsAddressType addrType,
size_t logicalBaseAddress,
const char *pOwnerName);
/*
* allocate and register an unoccupied address block
*/
epicsShareFunc long devAllocAddress(
const char *pOwnerName,
epicsAddressType addrType,
size_t size,
unsigned alignment, /*n ls bits zero in addr*/
volatile void **pLocalAddress);
/*
* VME API
*
* Functions in this section apply only to the VME bus type
*/
/*
* connect ISR to a VME interrupt vector
*/
epicsShareFunc long devConnectInterruptVME(
unsigned vectorNumber,
void (*pFunction)(void *),
void *parameter);
/*
* disconnect ISR from a VME interrupt vector
*
* The parameter pFunction should be set to the C function pointer that
* was connected. It is used as a key to prevent a driver from inadvertently
* removing an interrupt handler that it didn't install
*/
epicsShareFunc long devDisconnectInterruptVME(
unsigned vectorNumber,
void (*pFunction)(void *));
/*
* determine if a VME interrupt vector is in use
*
* returns boolean
*/
epicsShareFunc int devInterruptInUseVME (unsigned vectorNumber);
/*
* enable VME interrupt level
*/
epicsShareFunc long devEnableInterruptLevelVME (unsigned level);
/*
* disable VME interrupt level
*/
epicsShareFunc long devDisableInterruptLevelVME (unsigned level);
/*
* Routines to allocate and free memory in the A24 memory region.
*
*/
epicsShareFunc void *devLibA24Malloc(size_t);
epicsShareFunc void *devLibA24Calloc(size_t);
epicsShareFunc void devLibA24Free(void *pBlock);
/*
* ISA API
*
* Functions in this section apply only to the ISA bus type
*/
/*
* connect ISR to an ISA interrupt level
* (not implemented)
* (API should be reviewed)
*/
epicsShareFunc long devConnectInterruptISA(
unsigned interruptLevel,
void (*pFunction)(void *),
void *parameter);
/*
* disconnect ISR from an ISA interrupt level
* (not implemented)
* (API should be reviewed)
*
* The parameter pFunction should be set to the C function pointer that
* was connected. It is used as a key to prevent a driver from inadvertently
* removing an interrupt handler that it didn't install
*/
epicsShareFunc long devDisconnectInterruptISA(
unsigned interruptLevel,
void (*pFunction)(void *));
/*
* determine if an ISA interrupt level is in use
* (not implemented)
*
* returns boolean
*/
epicsShareFunc int devInterruptLevelInUseISA (unsigned interruptLevel);
/*
* enable ISA interrupt level
*/
epicsShareFunc long devEnableInterruptLevelISA (unsigned level);
/*
* disable ISA interrupt level
*/
epicsShareFunc long devDisableInterruptLevelISA (unsigned level);
/*
* Deprecated interface
*/
#ifndef NO_DEVLIB_OLD_INTERFACE
typedef enum {intVME, intVXI, intISA} epicsInterruptType;
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devConnectInterruptVME, devConnectInterruptPCI,
* devConnectInterruptISA etc. devConnectInterrupt will be removed
* in a future release.
*/
epicsShareFunc long devConnectInterrupt(
epicsInterruptType intType,
unsigned vectorNumber,
void (*pFunction)(void *),
void *parameter);
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devDisconnectInterruptVME, devDisconnectInterruptPCI,
* devDisconnectInterruptISA etc. devDisconnectInterrupt will be removed
* in a future release.
*/
epicsShareFunc long devDisconnectInterrupt(
epicsInterruptType intType,
unsigned vectorNumber,
void (*pFunction)(void *));
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devEnableInterruptLevelVME, devEnableInterruptLevelPCI,
* devEnableInterruptLevelISA etc. devEnableInterruptLevel will be removed
* in a future release.
*/
epicsShareFunc long devEnableInterruptLevel(
epicsInterruptType intType, unsigned level);
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use one of devDisableInterruptLevelVME, devDisableInterruptLevelISA,
* devDisableInterruptLevelPCI etc. devDisableInterruptLevel will be removed
* in a future release.
*/
epicsShareFunc long devDisableInterruptLevel (
epicsInterruptType intType, unsigned level);
/*
* NOTE: this routine has been deprecated. It exists
* for backwards compatibility purposes only.
*
* Please use devNoResponseProbe(). locationProbe() will be removed
* in a future release.
*/
epicsShareFunc long locationProbe (epicsAddressType addrType, char *pLocation);
#endif /* NO_DEVLIB_OLD_INTERFACE */
/*
* Some vxWorks convenience routines
*/
void bcopyLongs(char *source, char *destination, int nlongs);
#ifdef __cplusplus
}
#endif
#endif /* INCdevLibh.h*/

View File

@@ -0,0 +1,104 @@
/*************************************************************************\
* Copyright (c) 2010 Brookhaven Science Associates, as Operator of
* Brookhaven National Laboratory.
* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* devLibImpl.h */
/* */
/*
* Original Author: Marty Kraimer
* Author: Jeff Hill
* Date: 03-10-93
*/
#ifndef INCdevLibImplh
#define INCdevLibImplh 1
#include "dbDefs.h"
#include "shareLib.h"
#include "devLib.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* virtual OS layer for devLib.c
*
* The global virtual OS table pdevLibVME controls
* the behaviour of the functions defined in devLib.h.
* All of which call into the functions found in this table
* to perform system specific tasks.
*/
typedef struct devLibVME {
/*
* maps logical address to physical address, but does not detect
* two device drivers that are using the same address range
*/
long (*pDevMapAddr) (epicsAddressType addrType, unsigned options,
size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress);
/*
* a bus error safe "wordSize" read at the specified address which returns
* unsuccessful status if the device isnt present
*/
long (*pDevReadProbe) (unsigned wordSize, volatile const void *ptr, void *pValueRead);
/*
* a bus error safe "wordSize" write at the specified address which returns
* unsuccessful status if the device isnt present
*/
long (*pDevWriteProbe) (unsigned wordSize, volatile void *ptr, const void *pValueWritten);
/*
* connect ISR to a VME interrupt vector
* (required for backwards compatibility)
*/
long (*pDevConnectInterruptVME) (unsigned vectorNumber,
void (*pFunction)(void *), void *parameter);
/*
* disconnect ISR from a VME interrupt vector
* (required for backwards compatibility)
*/
long (*pDevDisconnectInterruptVME) (unsigned vectorNumber,
void (*pFunction)(void *));
/*
* enable VME interrupt level
*/
long (*pDevEnableInterruptLevelVME) (unsigned level);
/*
* disable VME interrupt level
*/
long (*pDevDisableInterruptLevelVME) (unsigned level);
/* malloc/free A24 address space */
void *(*pDevA24Malloc)(size_t nbytes);
void (*pDevA24Free)(void *pBlock);
long (*pDevInit)(void);
/*
* test if VME interrupt has an ISR connected
*/
int (*pDevInterruptInUseVME) (unsigned vectorNumber);
}devLibVME;
epicsShareExtern devLibVME *pdevLibVME;
#ifndef NO_DEVLIB_COMPAT
# define pdevLibVirtualOS pdevLibVME
#endif
#ifdef __cplusplus
}
#endif
#endif /* INCdevLibImplh */

View File

@@ -17,7 +17,7 @@
#include <epicsExit.h>
#include <rtems.h>
#include <bsp.h>
#include "devLib.h"
#include "devLibVME.h"
#include <epicsInterrupt.h>
#if defined(__PPC__) || defined(__mcf528x__)
@@ -36,7 +36,7 @@ static myISR *isrFetch(unsigned vectorNumber, void **parg);
* this routine needs to be in the symbol table
* for this code to work correctly
*/
void unsolicitedHandlerEPICS(int vectorNumber);
static void unsolicitedHandlerEPICS(int vectorNumber);
static myISR *defaultHandlerAddr[]={
(myISR*)unsolicitedHandlerEPICS,
@@ -72,42 +72,58 @@ int EPICStovxWorksAddrType[]
* maps logical address to physical address, but does not detect
* two device drivers that are using the same address range
*/
static long rtmsDevMapAddr (epicsAddressType addrType, unsigned options,
static long rtemsDevMapAddr (epicsAddressType addrType, unsigned options,
size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress);
/*
* a bus error safe "wordSize" read at the specified address which returns
* unsuccessful status if the device isnt present
*/
long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue);
static long rtemsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue);
/*
* a bus error safe "wordSize" write at the specified address which returns
* unsuccessful status if the device isnt present
*/
long rtmsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue);
static long rtemsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue);
static long rtemsDevConnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)(),
void *parameter);
static long rtemsDevDisconnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)()
);
static long rtemsDevEnableInterruptLevelVME (unsigned level);
static long rtemsDevDisableInterruptLevelVME (unsigned level);
static int rtemsDevInterruptInUseVME (unsigned vectorNumber);
/* RTEMS specific init */
/*devA24Malloc and devA24Free are not implemented*/
static void *devA24Malloc(size_t size) { return 0;}
static void devA24Free(void *pBlock) {};
static long rtmsDevInit(void);
static long rtemsDevInit(void);
/*
* used by bind in devLib.c
*/
static devLibVirtualOS rtemsVirtualOS = {
rtmsDevMapAddr, rtmsDevReadProbe, rtmsDevWriteProbe,
devConnectInterruptVME, devDisconnectInterruptVME,
devEnableInterruptLevelVME, devDisableInterruptLevelVME,
devA24Malloc,devA24Free,rtmsDevInit
static devLibVME rtemsVirtualOS = {
rtemsDevMapAddr, rtemsDevReadProbe, rtemsDevWriteProbe,
rtemsDevConnectInterruptVME, rtemsDevDisconnectInterruptVME,
rtemsDevEnableInterruptLevelVME, rtemsDevDisableInterruptLevelVME,
devA24Malloc,devA24Free,rtemsDevInit,rtemsDevInterruptInUseVME
};
devLibVirtualOS *pdevLibVirtualOS = &rtemsVirtualOS;
devLibVME *pdevLibVME = &rtemsVirtualOS;
/* RTEMS specific initialization */
static long
rtmsDevInit(void)
rtemsDevInit(void)
{
/* assume the vme bridge has been initialized by bsp */
/* init BSP extensions [memProbe etc.] */
@@ -119,7 +135,7 @@ rtmsDevInit(void)
*
* wrapper to minimize driver dependency on OS
*/
long devConnectInterruptVME (
static long rtemsDevConnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)(),
void *parameter)
@@ -152,7 +168,7 @@ long devConnectInterruptVME (
* an interrupt handler that was installed by another driver
*
*/
long devDisconnectInterruptVME (
static long rtemsDevDisconnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)()
)
@@ -188,7 +204,7 @@ long devDisconnectInterruptVME (
/*
* enable VME interrupt level
*/
long devEnableInterruptLevelVME (unsigned level)
static long rtemsDevEnableInterruptLevelVME (unsigned level)
{
return BSP_enableVME_int_lvl(level);
}
@@ -196,15 +212,15 @@ long devEnableInterruptLevelVME (unsigned level)
/*
* disable VME interrupt level
*/
long devDisableInterruptLevelVME (unsigned level)
static long rtemsDevDisableInterruptLevelVME (unsigned level)
{
return BSP_disableVME_int_lvl(level);
}
/*
* rtmsDevMapAddr ()
* rtemsDevMapAddr ()
*/
static long rtmsDevMapAddr (epicsAddressType addrType, unsigned options,
static long rtemsDevMapAddr (epicsAddressType addrType, unsigned options,
size_t logicalAddress, size_t size, volatile void **ppPhysicalAddress)
{
long status;
@@ -234,7 +250,7 @@ static long rtmsDevMapAddr (epicsAddressType addrType, unsigned options,
* unsuccessful status if the device isnt present
*/
rtems_status_code bspExtMemProbe(void *addr, int write, int size, void *pval);
long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue)
static long rtemsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue)
{
long status;
@@ -253,7 +269,7 @@ long rtmsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue
* a bus error safe "wordSize" write at the specified address which returns
* unsuccessful status if the device isnt present
*/
long rtmsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue)
static long rtemsDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue)
{
long status;
@@ -282,7 +298,7 @@ static myISR *isrFetch(unsigned vectorNumber, void **parg)
/*
* determine if a VME interrupt vector is in use
*/
int devInterruptInUseVME (unsigned vectorNumber)
static int rtemsDevInterruptInUseVME (unsigned vectorNumber)
{
int i;
myISR *psub;
@@ -319,7 +335,7 @@ int devInterruptInUseVME (unsigned vectorNumber)
* macro to declare handler prototypes...
*
*/
void unsolicitedHandlerEPICS(int vectorNumber)
static void unsolicitedHandlerEPICS(int vectorNumber)
{
/*
* call epicInterruptContextMessage()

View File

@@ -10,6 +10,6 @@
#include <stdlib.h>
#define epicsExportSharedSymbols
#include "devLib.h"
#include "devLibVME.h"
epicsShareDef devLibVirtualOS *pdevLibVirtualOS = NULL;
epicsShareDef devLibVME *pdevLibVME = NULL;

View File

@@ -10,8 +10,8 @@
#include <stdlib.h>
#include "devLib.h"
#include "devLibVME.h"
/* This file must contain no definitions other than the following: */
devLibVirtualOS *pdevLibVirtualOS;
devLibVME *pdevLibVME;

View File

@@ -28,7 +28,7 @@
#include <vxLib.h>
#include "epicsFindSymbol.h"
#include "devLib.h"
#include "devLibVME.h"
#include "errlog.h"
typedef void myISR (void *pParam);
@@ -52,7 +52,7 @@ static myISR *isrFetch(unsigned vectorNumber);
* this routine needs to be in the symbol table
* for this code to work correctly
*/
void unsolicitedHandlerEPICS(int vectorNumber);
static void unsolicitedHandlerEPICS(int vectorNumber);
/*
* this is in veclist.c
@@ -114,23 +114,39 @@ static void *devA24Malloc(size_t size);
static void devA24Free(void *pBlock);
static long devInit(void) { return 0;}
static long vxDevConnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)(),
void *parameter);
static long vxDevDisconnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)()
);
static long vxDevEnableInterruptLevelVME (unsigned level);
static long vxDevDisableInterruptLevelVME (unsigned level);
static int vxDevInterruptInUseVME (unsigned vectorNumber);
/*
* used by dynamic bind in devLib.c
*/
static devLibVirtualOS vxVirtualOS = {
static devLibVME vxVirtualOS = {
vxDevMapAddr, vxDevReadProbe, vxDevWriteProbe,
devConnectInterruptVME, devDisconnectInterruptVME,
devEnableInterruptLevelVME, devDisableInterruptLevelVME,
devA24Malloc,devA24Free,devInit
vxDevConnectInterruptVME, vxDevDisconnectInterruptVME,
vxDevEnableInterruptLevelVME, vxDevDisableInterruptLevelVME,
devA24Malloc,devA24Free,devInit,vxDevInterruptInUseVME
};
devLibVirtualOS *pdevLibVirtualOS = &vxVirtualOS;
devLibVME *pdevLibVME = &vxVirtualOS;
/*
* devConnectInterruptVME
*
* wrapper to minimize driver dependency on vxWorks
*/
long devConnectInterruptVME (
static long vxDevConnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)(),
void *parameter)
@@ -154,7 +170,7 @@ long devConnectInterruptVME (
/*
*
* devDisconnectInterruptVME()
* vxDevDisconnectInterruptVME()
*
* wrapper to minimize driver dependency on vxWorks
*
@@ -163,7 +179,7 @@ long devConnectInterruptVME (
* an interrupt handler that was installed by another driver
*
*/
long devDisconnectInterruptVME (
static long vxDevDisconnectInterruptVME (
unsigned vectorNumber,
void (*pFunction)()
)
@@ -198,7 +214,7 @@ long devDisconnectInterruptVME (
/*
* enable VME interrupt level
*/
long devEnableInterruptLevelVME (unsigned level)
static long vxDevEnableInterruptLevelVME (unsigned level)
{
# if CPU_FAMILY != I80X86
int s;
@@ -250,7 +266,7 @@ long devDisableInterruptLevelISA (unsigned level)
/*
* disable VME interrupt level
*/
long devDisableInterruptLevelVME (unsigned level)
static long vxDevDisableInterruptLevelVME (unsigned level)
{
# if CPU_FAMILY != I80X86
int s;
@@ -359,7 +375,7 @@ static myISR *isrFetch(unsigned vectorNumber)
/*
* determine if a VME interrupt vector is in use
*/
int devInterruptInUseVME (unsigned vectorNumber)
static int vxDevInterruptInUseVME (unsigned vectorNumber)
{
#if CPU_FAMILY == PPC
return FALSE;
@@ -397,7 +413,7 @@ int devInterruptInUseVME (unsigned vectorNumber)
* disconnected vector
*
*/
void unsolicitedHandlerEPICS(int vectorNumber)
static void unsolicitedHandlerEPICS(int vectorNumber)
{
/*
* call logMsg() and not errMessage()