Index: vmeDigi/Makefile =================================================================== RCS file: /afs/slac/g/lcls/cvs/epics/ioc/bpmApp/vmeDigi/Makefile,v retrieving revision 1.5 diff -u -a -w -b -B -r1.5 Makefile --- vmeDigi/Makefile 30 Aug 2010 19:46:39 -0000 1.5 +++ vmeDigi/Makefile 16 Dec 2010 04:40:40 -0000 @@ -2,7 +2,6 @@ include $(TOP)/configure/CONFIG -CROSS_COMPILER_TARGET_ARCHS=RTEMS-beatnik #---------------------------------------- # ADD MACRO DEFINITIONS AFTER THIS LINE #============================= @@ -12,45 +11,77 @@ # Comment this line to build a host-ioc; you'd need to exclude # several facilities (evr, micro, ...) for this to work. -BUILDFOR=_RTEMS - -PROD_IOC_RTEMS += vmeDigiComm -PROD_IOC_RTEMS += vmeDigiApp -PROD_IOC_RTEMS += vmeDigiDevSupMod -# create a fake library containing dependecies of vmeDigiDevSupMod -LIB_INSTALLS_RTEMS += libvmeDigiDevSupMod-symdeps.a +#BUILDFOR=_vxWorks +#PROD_IOC_vxWorks += vmeDigiComm +#PROD_IOC_vxWorks += vmeDigiApp +#===================================== +# Build the vxWorks library +# ==================================== +LIBRARY_IOC_vxWorks += vmeDigi +LIBRARY_IOC_vxWorks += vmeDigiDevSup +# ==================================== + +# ================================================================================ +# vxWorks Library Sources +# ================================================================================ +vmeDigi_SRCS_vxWorks += vme64x.c +vmeDigi_SRCS_vxWorks += vmeDigi.c +vmeDigiDevSup_SRCS_vxWorks += devVmeDigiSupport.c +vmeDigiDevSup_SRCS_vxWorks += devWfVmeDigi.c +vmeDigiDevSup_SRCS_vxWorks += devWfVmeDigiSup.c +vmeDigiDevSup_SRCS_vxWorks += devWfVmeDigiSim.c +# ================================================================================= + + +# ================================================================= +# Build RTEMS Library +# ================================================================= LIBRARY_IOC_RTEMS += vmeDigi LIBRARY_IOC_RTEMS += vmeDigiDevSup +#PROD_IOC_RTEMS += vmeDigiApp +#PROD_IOC_RTEMS += vmeDigiDevSupMod +# create a fake library containing dependecies of vmeDigiDevSupMod +#LIB_INSTALLS_RTEMS += libvmeDigiDevSupMod-symdeps.a +# =================================================================== -vmeDigi_SRCS = vme64x.c vmeDigi.c - -vmeDigiDevSup_SRCS = devVmeDigiSupport.c devWfVmeDigi.c devWfVmeDigiSup.c devWfVmeDigiSim.c - -vmeDigiComm_SRCS = vmeDigiComm.c $(vmeDigi_SRCS) - -DBD = vmeDigiApp.dbd +# ================================================================================ +# RTEMS Library Sources +# ================================================================================ +vmeDigi_SRCS_RTEMS += vme64x.c +vmeDigi_SRCS_RTEMS += vmeDigi.c +vmeDigiDevSup_SRCS_RTEMS += devVmeDigiSupport.c +vmeDigiDevSup_SRCS_RTEMS += devWfVmeDigi.c +vmeDigiDevSup_SRCS_RTEMS += devWfVmeDigiSup.c +vmeDigiDevSup_SRCS_RTEMS += devWfVmeDigiSim.c +#vmeDigiComm_SRCS_RTEMS += vmeDigiComm.c $(vmeDigi_SRCS) +# ================================================================================= + +# ================================================================================= +# Install Database Definition Files +# ================================================================================= +#DBD += vmeDigiApp.dbd DBD += vmeDigiSupport.dbd +# ================================================================================= -vmeDigiDevSupMod_SRCS = vmeDigiSupport_registerRecordDeviceDriver.cpp -vmeDigiDevSupMod_SRCS+= $(vmeDigiDevSup_SRCS) +#vmeDigiDevSupMod_SRCS = vmeDigiSupport_registerRecordDeviceDriver.cpp +#vmeDigiDevSupMod_SRCS+= $(vmeDigiDevSup_SRCS_RTEMS) -vmeDigiApp_DBD = base.dbd -vmeDigiApp_DBD += vmeDigiWf.dbd -vmeDigiApp_DBD += devBusMapped.dbd +#vmeDigiApp_DBD = base.dbd +#vmeDigiApp_DBD += vmeDigiWf.dbd +#vmeDigiApp_DBD += devBusMapped.dbd -vmeDigiApp_SRCS = vmeDigiApp_registerRecordDeviceDriver.cpp +#vmeDigiApp_SRCS = vmeDigiApp_registerRecordDeviceDriver.cpp -vmeDigiApp_LIBS += vmeDigiDevSup -vmeDigiApp_LIBS += vmeDigi -vmeDigiApp_LIBS += devBusMapped -vmeDigiApp_LIBS += $(EPICS_BASE_IOC_LIBS) +#vmeDigiApp_LIBS += vmeDigiDevSup +#vmeDigiApp_LIBS += vmeDigi +#vmeDigiApp_LIBS += devBusMapped +#vmeDigiApp_LIBS += $(EPICS_BASE_IOC_LIBS) -#USR_CFLAGS_RTEMS = -I$(TOP)/include -I$(RTEMS_BASE)/ -DB += vmeDigiApp.db -DB += vmeDigiSim.db +#DB += vmeDigiApp.db +#DB += vmeDigiSim.db #=========================== Index: vmeDigi/devVmeDigiSupport.c =================================================================== RCS file: /afs/slac/g/lcls/cvs/epics/ioc/bpmApp/vmeDigi/devVmeDigiSupport.c,v retrieving revision 1.2 diff -u -a -w -b -B -r1.2 devVmeDigiSupport.c --- vmeDigi/devVmeDigiSupport.c 25 Nov 2008 01:39:43 -0000 1.2 +++ vmeDigi/devVmeDigiSupport.c 16 Dec 2010 04:34:14 -0000 @@ -3,6 +3,11 @@ #include #include +#ifdef __rtems__ +#include +#endif + +/* EPICS Includes */ #include #include #include Index: vmeDigi/vme64x.c =================================================================== RCS file: /afs/slac/g/lcls/cvs/epics/ioc/bpmApp/vmeDigi/vme64x.c,v retrieving revision 1.2 diff -u -a -w -b -B -r1.2 vme64x.c --- vmeDigi/vme64x.c 25 Nov 2008 01:39:44 -0000 1.2 +++ vmeDigi/vme64x.c 16 Dec 2010 04:27:10 -0000 @@ -1,14 +1,29 @@ -#if 0 +#ifdef __rtems__ #include #include #include #include +#include #endif -#include + + + + +#ifdef vxWorks +/* *************** */ +/* vxWorks Headers */ +/* *************** */ +#include "vxWorks.h" +/* #include "intLib.h" */ +#include "vme.h" /* vme bus constants */ +/* ^^^^^^^^^^^^^^^^^^^^ */ +#endif + + + #include #include - #include #define DEBUG @@ -13,6 +28,7 @@ #define DEBUG +#ifdef __rtems__ /* read a 24-bit register composed of 3 bytes spaced by 4 */ uint32_t vme64CSRegRead24(VME64_Addr base, uint32_t off) { @@ -224,3 +240,4 @@ return rval; } +#endif Index: vmeDigi/vme64x.h =================================================================== RCS file: /afs/slac/g/lcls/cvs/epics/ioc/bpmApp/vmeDigi/vme64x.h,v retrieving revision 1.2 diff -u -a -w -b -B -r1.2 vme64x.h --- vmeDigi/vme64x.h 25 Nov 2008 01:39:44 -0000 1.2 +++ vmeDigi/vme64x.h 16 Dec 2010 02:10:15 -0000 @@ -5,7 +5,16 @@ extern "C" { #endif +/* +#ifdef __rtems__ #include +#endif +*/ + + +#ifdef __rtems__ +#include +#endif /* Try to be alias rule-safe */ Index: vmeDigi/vmeDigi.c =================================================================== RCS file: /afs/slac/g/lcls/cvs/epics/ioc/bpmApp/vmeDigi/vmeDigi.c,v retrieving revision 1.2 diff -u -a -w -b -B -r1.2 vmeDigi.c --- vmeDigi/vmeDigi.c 25 Nov 2008 01:39:44 -0000 1.2 +++ vmeDigi/vmeDigi.c 16 Dec 2010 04:27:28 -0000 @@ -1,9 +1,27 @@ +#ifdef __rtems__ #include #include #include #include +#endif + +#ifdef vxWorks +/* *************** */ +/* vxWorks Headers */ +/* *************** */ +#include "vxWorks.h" +#include "sysLib.h" +#include "intLib.h" +#include "vme.h" /* vme bus constants */ +/* ^^^^^^^^^^^^^^^^^^^^ */ +#endif +/* +#ifdef vxWorks6.9 #include +#endif +*/ + #include #include @@ -14,6 +32,19 @@ extern int snprintf(char *, size_t, const char *, ...); #endif +#ifdef vxWorks + #ifndef VME_AM_EXT_SUP_MBLT + #define VME_AM_EXT_SUP_MBLT 0x0c + #endif + + #ifndef ISR_Level + typedef uint32_t ISR_Level; + #endif + typedef ISR_Level rtems_interrupt_level; + +#endif + + #define VMEDIGI_OFF_IRQ_STS 0x7fa32 #define VMEDIGI_IRQ_STS_SW_IRQ (1<<7) #define VMEDIGI_IRQ_STS_BERR_IRQ (1<<6) @@ -87,20 +118,37 @@ unsigned long csr_local; uint32_t brdid; +#ifdef __rtems__ if ( BSP_vme2local_adrs(VME_AM_CSR, csrbase, &csr_local) ) { +#else + if ( sysBusToLocalAdrs(VME_AM_CSR, (char*)csrbase, (char**)&csr_local) ) { +#endif if ( ! quiet ) + #ifdef __rtems__ fprintf(stderr,"Unable to map CSR base address 0x%08"myPRIxPTR" to local/CPU address\n", csrbase); + #else + fprintf(stderr,"Unable to map CSR base address 0x%08x to local/CPU address\n", csrbase); + #endif return (unsigned long)-1; } if ( vme64CRChecksum(csr_local, quiet) ) { if ( ! quiet ) + #ifdef __rtems__ fprintf(stderr,"No valid VME64 CR Checksum at 0x%08"myPRIxPTR"\n", csrbase); + #else + fprintf(stderr,"No valid VME64 CR Checksum at 0x%08x\n", csrbase); + #endif return (unsigned long)-1; } if ( VMEDIGI_CR_ID != (brdid=vme64CSRegRead32(csr_local, VME64_CR_OFF_BRDID)) ) { if ( ! quiet ) + #ifdef __rtems__ fprintf(stderr,"Unknown board ID found: 0x%08"PRIx32"\n", brdid); + #else + fprintf(stderr,"Unknown board ID found: 0x%08x\n", brdid); + #endif + return (unsigned long)-1; } @@ -202,14 +251,25 @@ { uint16_t val; rtems_interrupt_level lvl; + +#ifdef __rtems__ rtems_interrupt_disable(lvl); +#else + lvl = intLock (); +#endif + val = vme64_in16(digi->base, VMEDIGI_OFF_ACQ_CSR); if ( val & VMEDIGI_ACQ_CSR_SW_ARM ) { /* if it was already armed flash */ vme64_out16( digi->base, VMEDIGI_OFF_ACQ_CSR, val & ~VMEDIGI_ACQ_CSR_SW_ARM ); } vme64_out16( digi->base, VMEDIGI_OFF_ACQ_CSR, val | VMEDIGI_ACQ_CSR_SW_ARM ); + +#ifdef __rtems__ rtems_interrupt_enable(lvl); +#else + intUnlock (lvl); +#endif return val & VMEDIGI_ACQ_CSR_SW_ARM; } @@ -220,10 +280,20 @@ uint16_t val; rtems_interrupt_level lvl; +#ifdef __rtems__ rtems_interrupt_disable(lvl); +#else + lvl = intLock (); +#endif + val = vme64_in16(digi->base, VMEDIGI_OFF_ACQ_CSR); vme64_out16( digi->base, VMEDIGI_OFF_ACQ_CSR, val & ~VMEDIGI_ACQ_CSR_SW_ARM ); + +#ifdef __rtems__ rtems_interrupt_enable(lvl); +#else + intUnlock (lvl); +#endif return val & VMEDIGI_ACQ_CSR_SW_ARM; } @@ -235,7 +305,11 @@ rtems_interrupt_level lvl; +#ifdef __rtems__ rtems_interrupt_disable(lvl); +#else + lvl = intLock (); +#endif val = vme64_in16( digi->base, VMEDIGI_OFF_ACQ_CSR ); if ( val & VMEDIGI_ACQ_CSR_SW_ARM ) { /* if it was already armed flash */ @@ -249,7 +323,11 @@ vme64_out16( digi->base, VMEDIGI_OFF_ACQ_CSR, nval | VMEDIGI_ACQ_CSR_SW_GATE ); /* restore original value */ vme64_out16( digi->base, VMEDIGI_OFF_ACQ_CSR, val ); +#ifdef __rtems__ rtems_interrupt_enable(lvl); +#else + intUnlock (lvl); +#endif } /* Should NOT use this routine if AUX_CSR is controlled via devBusMapped! */ @@ -259,14 +337,25 @@ uint16_t val; rtems_interrupt_level lvl; +#ifdef __rtems__ rtems_interrupt_disable(lvl); +#else + lvl = intLock (); +#endif + val = vme64_in16( digi->base, VMEDIGI_OFF_AUX_CSR ); if ( VMEDIGI_AUX_CSR_SW_INTRP & val ) vme64_out16( digi->base, VMEDIGI_OFF_AUX_CSR, val & ~VMEDIGI_AUX_CSR_SW_INTRP ); vme64_out16( digi->base, VMEDIGI_OFF_AUX_CSR, val | VMEDIGI_AUX_CSR_SW_INTRP ); if ( ! (VMEDIGI_AUX_CSR_SW_INTRP & val) ) vme64_out16( digi->base, VMEDIGI_OFF_AUX_CSR, val ); +#ifdef __rtems__ rtems_interrupt_enable(lvl); +#else + intUnlock (lvl); +#endif + + } void @@ -275,11 +364,20 @@ uint16_t val; rtems_interrupt_level lvl; +#ifdef __rtems__ rtems_interrupt_disable(lvl); +#else + lvl = intLock (); +#endif val = vme64_in16( digi->base, VMEDIGI_OFF_IRQ_CSR ); val |= VMEDIGI_IRQ_CSR_IRQ_ENBL; vme64_out16( digi->base, VMEDIGI_OFF_IRQ_CSR, val ); +#ifdef __rtems__ rtems_interrupt_enable(lvl); +#else + intUnlock (lvl); +#endif + } int @@ -288,12 +386,20 @@ uint16_t val; rtems_interrupt_level lvl; +#ifdef __rtems__ rtems_interrupt_disable(lvl); +#else + lvl = intLock (); +#endif val = vme64_in16( digi->base, VMEDIGI_OFF_IRQ_CSR ); vme64_out16( digi->base, VMEDIGI_OFF_IRQ_CSR, val & ~VMEDIGI_IRQ_CSR_IRQ_ENBL ); - rtems_interrupt_enable(lvl); +#ifdef __rtems__ rtems_interrupt_enable(lvl); +#else + intUnlock (lvl); +#endif + return val & VMEDIGI_IRQ_CSR_IRQ_ENBL; } @@ -357,7 +463,11 @@ goto bail; v = vme64CSRegRead32( digi->base, VME64_CR_OFF_MANID ); - l = dmp(buf, len, "Manufacturer: 0x%"PRIx32, v); + #ifdef __rtems__ + l = dmp(buf, len, "Manufacturer: 0x%"PRIx32"\n", v); + #else + l = dmp(buf, len, "Manufacturer: 0x%x\n", v); + #endif buf+=l; len-=l; @@ -365,7 +475,11 @@ goto bail; v = vme64CSRegRead32( digi->base, VME64_CR_OFF_BRDID ); - l = dmp(buf, len, ", Board (drawing) Rev: 0x%"PRIx32, v); + #ifdef __rtems__ + l = dmp(buf, len, ", Board (drawing) Rev: 0x%"PRIx32"\n", v); + #else + l = dmp(buf, len, ", Board (drawing) Rev: 0x%x\n", v); + #endif buf+=l; len-=l; @@ -373,7 +487,11 @@ goto bail; v = vme64CSRegRead32( digi->base, VME64_CR_OFF_REVID ); - l = dmp(buf, len, ", Firmware Rev: 0x%"PRIx32, v); + #ifdef __rtems__ + l = dmp(buf, len, ", Firmware Rev: 0x%"PRIx32"\n", v); + #else + l = dmp(buf, len, ", Firmware Rev: 0x%x\n", v); + #endif buf+=l; len-=l; @@ -381,7 +499,11 @@ goto bail; v = vme64ReadSN( digi->base ); - l = dmp(buf, len, ", S/N 0x%"PRIx32, v); + #ifdef __rtems__ + l = dmp(buf, len, ", S/N 0x%"PRIx32"\n", v); + #else + l = dmp(buf, len, ", S/N 0x%x\n", v); + #endif buf+=l; len-=l; Index: vmeDigi/vmeDigiComm.c =================================================================== RCS file: /afs/slac/g/lcls/cvs/epics/ioc/bpmApp/vmeDigi/vmeDigiComm.c,v retrieving revision 1.8 diff -u -a -w -b -B -r1.8 vmeDigiComm.c --- vmeDigi/vmeDigiComm.c 19 Apr 2010 14:07:22 -0000 1.8 +++ vmeDigi/vmeDigiComm.c 15 Dec 2010 22:57:49 -0000 @@ -2,10 +2,23 @@ #include #include +#ifdef __rtems__ #include #include #include #include +#endif + +#ifdef vxWorks +/* *************** */ +/* vxWorks Headers */ +/* *************** */ +#include "vxWorks.h" +#inculde "sysLib.h" +/* #include "intLib.h" */ +#include "vme.h" /* vme bus constants */ +/* ^^^^^^^^^^^^^^^^^^^^ */ +#endif #include #include @@ -637,7 +650,11 @@ nsmpls = vmeDigis[channel].nbytes / PADRPLY_STRM_NCHANNELS / sizeof(int16_t); if ( nsmpls > 0 ) { +#ifdef __rtems__ if ( BSP_vme2local_adrs(VME_AM_EXT_SUP_DATA, vmeDigis[channel].vmeaddr, &a) ) { +#else + if ( sysBusToLocalAdrs(VME_AM_EXT_SUP_DATA, vmeDigis[channel].vmeaddr, &a) ) { +#endif fprintf(stderr,"Unable to map VME address to PCI\n"); return -1; }