Added CR/CSR support to devLib.

This commit is contained in:
Andrew Johnson
2008-07-23 16:37:21 +00:00
parent 9c106ce023
commit 94f71e16f6
4 changed files with 137 additions and 54 deletions

View File

@@ -1,14 +1,13 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* 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 Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* devLib.c - support for allocation of common device resources */
/* @(#)$Id$*/
/* $Id$ */
/*
* Original Author: Marty Kraimer
@@ -38,13 +37,15 @@ LOCAL size_t addrLast[atLast] = {
0xffff,
0xffffff,
0xffffffff,
0xffffff
0xffffff,
0xffffff,
};
LOCAL unsigned addrHexDig[atLast] = {
4,
6,
8,
6,
6
};
@@ -52,7 +53,8 @@ LOCAL long addrFail[atLast] = {
S_dev_badA16,
S_dev_badA24,
S_dev_badA32,
S_dev_badA24
S_dev_badISA,
S_dev_badCRCSR
};
LOCAL epicsMutexId addrListLock;
@@ -63,7 +65,8 @@ const char *epicsAddressTypeName[]
"VME A16",
"VME A24",
"VME A32",
"ISA"
"ISA",
"VME CR/CSR"
};
typedef struct{
@@ -131,6 +134,57 @@ LOCAL long devInstallAddr(
#define SUCCESS 0
/*
* devBusToLocalAddr()
*/
long devBusToLocalAddr(
epicsAddressType addrType,
size_t busAddr,
volatile void **ppLocalAddress)
{
long status;
volatile void *localAddress;
/*
* Make sure that devLib has been intialized
*/
if (!devLibInitFlag) {
status = devLibInit();
if(status){
return status;
}
}
/*
* Make sure we have a valid bus address
*/
status = addrVerify (addrType, busAddr, 4);
if (status) {
return status;
}
/*
* Call the virtual os routine to map the bus address to a CPU address
*/
status = (*pdevLibVirtualOS->pDevMapAddr) (addrType, 0, busAddr, 4, &localAddress);
if (status) {
errPrintf (status, __FILE__, __LINE__, "%s bus address =0X%X\n",
epicsAddressTypeName[addrType], (unsigned int)busAddr);
return status;
}
/*
* Return the local CPU address if the pointer is supplied
*/
if (ppLocalAddress) {
*ppLocalAddress = localAddress;
}
return SUCCESS;
}/*end devBusToLocalAddr()*/
/*
* devRegisterAddress()
*/

View File

@@ -1,19 +1,18 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* 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 Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* devLib.h */
/* $Id$ */
/*
* Original Author: Marty Kraimer
* Author: Jeff Hill
* Date: 03-10-93
* Original Author: Marty Kraimer
* Author: Jeff Hill
* Date: 03-10-93
*/
#ifndef INCdevLibh
@@ -35,6 +34,7 @@ typedef enum {
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;
@@ -46,6 +46,15 @@ extern const char *epicsAddressTypeName[];
long devAddressMap(void); /* print an address map */
/*
* devBusToLocalAddr()
*
* OSI routine to translate bus addresses their local CPU address mapping
*/
long devBusToLocalAddr (
epicsAddressType addrType,
size_t busAddr,
volatile void **ppLocalAddr);
/*
* devReadProbe()
*
@@ -357,6 +366,8 @@ extern devLibVirtualOS *pdevLibVirtualOS;
#define S_dev_badFunction (M_devLib| 31) /*bad function pointer*/
#define S_dev_badVector (M_devLib| 32) /*bad interrupt vector*/
#define S_dev_badArgument (M_devLib| 33) /*bad function argument*/
#define S_dev_badISA (M_devLib| 34) /*Invalid ISA address*/
#define S_dev_badCRCSR (M_devLib| 35) /*Invalid VME CR/CSR address*/
#define S_dev_vxWorksIntEnFail S_dev_intEnFail
/*

View File

@@ -1,13 +1,12 @@
/* devLibRTEMS.c */
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* 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 Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* $Id$ */
/* RTEMS port by Till Straumann, <strauman@slac.stanford.edu>
* 3/2002
@@ -40,9 +39,17 @@ LOCAL myISR *isrFetch(unsigned vectorNumber, void **parg);
void unsolicitedHandlerEPICS(int vectorNumber);
LOCAL myISR *defaultHandlerAddr[]={
(myISR*)unsolicitedHandlerEPICS,
(myISR*)unsolicitedHandlerEPICS,
};
/*
* Make sure that the CR/CSR addressing mode is defined.
* (it may not be in some BSPs).
*/
#ifndef VME_AM_CSR
# define VME_AM_CSR (0x2f)
#endif
/*
* we use a translation between an EPICS encoding
* and a vxWorks encoding here
@@ -57,7 +64,8 @@ int EPICStovxWorksAddrType[]
VME_AM_SUP_SHORT_IO,
VME_AM_STD_SUP_DATA,
VME_AM_EXT_SUP_DATA,
EPICSAddrTypeNoConvert
EPICSAddrTypeNoConvert,
VME_AM_CSR
};
/*
@@ -89,20 +97,21 @@ LOCAL long rtmsDevInit(void);
/*
* used by bind in devLib.c
*/
const struct devLibVirtualOS devLibRTEMSOS =
{rtmsDevMapAddr, rtmsDevReadProbe, rtmsDevWriteProbe,
static devLibVirtualOS rtemsVirtualOS = {
rtmsDevMapAddr, rtmsDevReadProbe, rtmsDevWriteProbe,
devConnectInterruptVME, devDisconnectInterruptVME,
devEnableInterruptLevelVME, devDisableInterruptLevelVME,
devA24Malloc,devA24Free,rtmsDevInit};
devLibVirtualOS *pdevLibVirtualOS = &devLibRTEMSOS;
devA24Malloc,devA24Free,rtmsDevInit
};
devLibVirtualOS *pdevLibVirtualOS = &rtemsVirtualOS;
/* RTEMS specific initialization */
LOCAL long
rtmsDevInit(void)
{
/* assume the vme bridge has been initialized by bsp */
/* init BSP extensions [memProbe etc.] */
return bspExtInit();
/* assume the vme bridge has been initialized by bsp */
/* init BSP extensions [memProbe etc.] */
return bspExtInit();
}
/*
@@ -149,7 +158,7 @@ long devDisconnectInterruptVME (
)
{
void (*psub)();
void *arg;
void *arg;
int status;
/*
@@ -162,13 +171,13 @@ long devDisconnectInterruptVME (
}
status = BSP_removeVME_isr(
vectorNumber,
psub,
arg) ||
BSP_installVME_isr(
vectorNumber,
(BSP_VME_ISR_t)unsolicitedHandlerEPICS,
(void*)vectorNumber);
vectorNumber,
psub,
arg) ||
BSP_installVME_isr(
vectorNumber,
(BSP_VME_ISR_t)unsolicitedHandlerEPICS,
(void*)vectorNumber);
if(status){
return S_dev_vecInstlFail;
}
@@ -181,7 +190,7 @@ long devDisconnectInterruptVME (
*/
long devEnableInterruptLevelVME (unsigned level)
{
return BSP_enableVME_int_lvl(level);
return BSP_enableVME_int_lvl(level);
}
/*
@@ -189,7 +198,7 @@ long devEnableInterruptLevelVME (unsigned level)
*/
long devDisableInterruptLevelVME (unsigned level)
{
return BSP_disableVME_int_lvl(level);
return BSP_disableVME_int_lvl(level);
}
/*
@@ -276,12 +285,12 @@ int devInterruptInUseVME (unsigned vectorNumber)
{
int i;
myISR *psub;
void *arg;
void *arg;
psub = isrFetch (vectorNumber,&arg);
if (!psub)
return FALSE;
if (!psub)
return FALSE;
/*
* its a C routine. Does it match a default handler?
@@ -313,16 +322,16 @@ void unsolicitedHandlerEPICS(int vectorNumber)
{
/*
* call epicInterruptContextMessage()
* and not errMessage()
* and not errMessage()
* so we are certain that printf()
* does not get called at interrupt level
*
* NOTE: current RTEMS implementation only
* allows a static string to be passed
*
* NOTE: current RTEMS implementation only
* allows a static string to be passed
*/
epicsInterruptContextMessage(
"Interrupt to EPICS disconnected vector"
);
);
}
#endif /* defined(__PPC__) && defined(mpc750) */

View File

@@ -1,15 +1,13 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* 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 Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* devLibVxWorks.c
* @(#)$Id$
* $Id$
*
* Archictecture dependent support for common device driver resources
*
@@ -60,6 +58,14 @@ void unsolicitedHandlerEPICS(int vectorNumber);
*/
int cISRTest(void (*)(), void (**)(), void **);
/*
* Make sure that the CR/CSR addressing mode is defined.
* (it may not be in older versions of vxWorks)
*/
#ifndef VME_AM_CSR
# define VME_AM_CSR (0x2f)
#endif
/*
* we use a translation between an EPICS encoding
* and a vxWorks encoding here
@@ -68,13 +74,16 @@ int cISRTest(void (*)(), void (**)(), void **);
* we assume that the BSP are configured to use these
* address modes by default
*/
#define EPICSAddrTypeNoConvert -1
int EPICStovxWorksAddrType[]
= {
VME_AM_SUP_SHORT_IO,
VME_AM_STD_SUP_DATA,
VME_AM_EXT_SUP_DATA,
EPICSAddrTypeNoConvert
EPICSAddrTypeNoConvert,
VME_AM_CSR
};
#if CPU_FAMILY != PPC
@@ -107,13 +116,13 @@ static long devInit(void) { return 0;}
/*
* used by dynamic bind in devLib.c
*/
static devLibVirtualOS virtualOS = {
static devLibVirtualOS vxVirtualOS = {
vxDevMapAddr, vxDevReadProbe, vxDevWriteProbe,
devConnectInterruptVME, devDisconnectInterruptVME,
devEnableInterruptLevelVME, devDisableInterruptLevelVME,
devA24Malloc,devA24Free,devInit
};
devLibVirtualOS *pdevLibVirtualOS = &virtualOS;
devLibVirtualOS *pdevLibVirtualOS = &vxVirtualOS;
/*
* devConnectInterruptVME
@@ -284,7 +293,7 @@ LOCAL long vxDevMapAddr (epicsAddressType addrType, unsigned options,
/*
* a bus error safe "wordSize" read at the specified address which returns
* unsuccessful status if the device isnt present
* unsuccessful status if the device isn't present
*/
static long vxDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue)
{
@@ -300,7 +309,7 @@ static long vxDevReadProbe (unsigned wordSize, volatile const void *ptr, void *p
/*
* a bus error safe "wordSize" write at the specified address which returns
* unsuccessful status if the device isnt present
* unsuccessful status if the device isn't present
*/
static long vxDevWriteProbe (unsigned wordSize, volatile void *ptr, const void *pValue)
{