forked from Imagelibrary/rtems
2007-12-08 Till Straumann <strauman@slac.stanford.edu>
* Makefile.am: merged shared/vme/vme_universe.c and shared/vme/vme_universe_dma.c into one file. Added support for Tsi148 driver (DMA).
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2007-12-08 Till Straumann <strauman@slac.stanford.edu>
|
||||
|
||||
* Makefile.am: merged shared/vme/vme_universe.c and
|
||||
shared/vme/vme_universe_dma.c into one file.
|
||||
Added support for Tsi148 driver (DMA).
|
||||
|
||||
2007-12-08 Till Straumann <strauman@slac.stanford.edu>
|
||||
|
||||
* shared/vme/VMEConfig.h, shared/vme/vme_universe.c:
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
/*$Id$*/
|
||||
|
||||
/* Implementation of the VME.h and VMEDMA.h APIs for the BSP using the
|
||||
* vmeUniverse/vmeTsi148 drivers
|
||||
*
|
||||
* This file is named vme_universe.c for historic reasons.
|
||||
*/
|
||||
|
||||
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <bsp/VME.h>
|
||||
#include <bsp/VMEDMA.h>
|
||||
#include <bsp/VMEConfig.h>
|
||||
#include <bsp/irq.h>
|
||||
#include <stdio.h>
|
||||
@@ -16,16 +24,20 @@
|
||||
#if defined(_VME_DRIVER_TSI148)
|
||||
#define _VME_TSI148_DECLARE_SHOW_ROUTINES
|
||||
#include <bsp/vmeTsi148.h>
|
||||
#include <bsp/vmeTsi148DMA.h>
|
||||
#endif
|
||||
|
||||
#if defined(_VME_DRIVER_UNIVERSE)
|
||||
#define _VME_UNIVERSE_DECLARE_SHOW_ROUTINES
|
||||
#include <bsp/vmeUniverse.h>
|
||||
#include <bsp/vmeUniverseDMA.h>
|
||||
#if !defined(BSP_VME_INSTALL_IRQ_MGR) && defined(BSP_VME_UNIVERSE_INSTALL_IRQ_MGR)
|
||||
#define BSP_VME_INSTALL_IRQ_MGR BSP_VME_UNIVERSE_INSTALL_IRQ_MGR
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <bsp/bspVmeDmaList.h>
|
||||
|
||||
/* Wrap BSP VME calls around driver calls - we do this so EPICS doesn't have to
|
||||
* include bridge-specific headers. This file provides the necessary glue
|
||||
* to make VME.h and vmeconfig.c independent of the bridge chip.
|
||||
@@ -92,6 +104,16 @@ typedef struct {
|
||||
int irq_mgr_flags;
|
||||
} VMEOpsRec, *VMEOps;
|
||||
|
||||
/* two separate 'ops' structs for historic reasons */
|
||||
typedef struct DmaOpsRec_ {
|
||||
int (*setup)(int, uint32_t, uint32_t, void *);
|
||||
int (*start)(int, uint32_t, uint32_t, uint32_t);
|
||||
uint32_t (*status)(int);
|
||||
VMEDmaListClass listClass;
|
||||
int nChannels;
|
||||
int *vectors;
|
||||
} DmaOpsRec, *DmaOps;
|
||||
|
||||
#ifdef _VME_DRIVER_UNIVERSE
|
||||
static VMEOpsRec uniOpsRec = {
|
||||
xlate_adrs: vmeUniverseXlateAddr,
|
||||
@@ -108,6 +130,17 @@ static VMEOpsRec uniOpsRec = {
|
||||
irq_mgr_flags: VMEUNIVERSE_IRQ_MGR_FLAG_SHARED |
|
||||
VMEUNIVERSE_IRQ_MGR_FLAG_PW_WORKAROUND,
|
||||
};
|
||||
|
||||
static int uniVecs[] = { UNIV_DMA_INT_VEC };
|
||||
|
||||
static DmaOpsRec uniDmaOps = {
|
||||
setup: vmeUniverseDmaSetup,
|
||||
start: vmeUniverseDmaStart,
|
||||
status: vmeUniverseDmaStatus,
|
||||
listClass: &vmeUniverseDmaListClass,
|
||||
nChannels: 1,
|
||||
vectors: uniVecs,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef _VME_DRIVER_TSI148
|
||||
@@ -125,9 +158,24 @@ static VMEOpsRec tsiOpsRec = {
|
||||
install_irq_mgr: vmeTsi148InstallIrqMgrAlt,
|
||||
irq_mgr_flags: VMETSI148_IRQ_MGR_FLAG_SHARED,
|
||||
};
|
||||
|
||||
static int tsiVecs[] = {
|
||||
TSI_DMA_INT_VEC,
|
||||
TSI_DMA1_INT_VEC,
|
||||
};
|
||||
|
||||
static DmaOpsRec tsiDmaOps = {
|
||||
setup: vmeTsi148DmaSetup,
|
||||
start: vmeTsi148DmaStart,
|
||||
status: vmeTsi148DmaStatus,
|
||||
listClass: &vmeTsi148DmaListClass,
|
||||
nChannels: 2,
|
||||
vectors: tsiVecs,
|
||||
};
|
||||
#endif
|
||||
|
||||
static VMEOps theOps = 0;
|
||||
static VMEOps theOps = 0;
|
||||
static DmaOps theDmaOps = 0;
|
||||
|
||||
int
|
||||
BSP_vme2local_adrs(unsigned long am, unsigned long vmeaddr, unsigned long *plocaladdr)
|
||||
@@ -208,6 +256,96 @@ BSP_VMEInboundPortsShow(FILE *f)
|
||||
theOps->inbound_p_show(f);
|
||||
}
|
||||
|
||||
int
|
||||
BSP_VMEDmaSetup(int channel, uint32_t bus_mode, uint32_t xfer_mode, void *custom_setup)
|
||||
{
|
||||
return theDmaOps->setup(channel, bus_mode, xfer_mode, custom_setup);
|
||||
}
|
||||
|
||||
int
|
||||
BSP_VMEDmaStart(int channel, uint32_t pci_addr, uint32_t vme_addr, uint32_t n_bytes)
|
||||
{
|
||||
return theDmaOps->start(channel, pci_addr, vme_addr, n_bytes);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
BSP_VMEDmaStatus(int channel)
|
||||
{
|
||||
return theDmaOps->status(channel);
|
||||
}
|
||||
|
||||
BSP_VMEDmaListDescriptor
|
||||
BSP_VMEDmaListDescriptorSetup(
|
||||
BSP_VMEDmaListDescriptor d,
|
||||
uint32_t attr_mask,
|
||||
uint32_t xfer_mode,
|
||||
uint32_t pci_addr,
|
||||
uint32_t vme_addr,
|
||||
uint32_t n_bytes)
|
||||
{
|
||||
VMEDmaListClass pc;
|
||||
if ( !d ) {
|
||||
if ( ! (pc = theDmaOps->listClass) ) {
|
||||
pc = (theDmaOps = selectOps())->listClass;
|
||||
}
|
||||
return BSP_VMEDmaListDescriptorNewTool(
|
||||
pc,
|
||||
attr_mask,
|
||||
xfer_mode,
|
||||
pci_addr,
|
||||
vme_addr,
|
||||
n_bytes);
|
||||
|
||||
}
|
||||
return BSP_VMEDmaListDescriptorSetupTool(d, attr_mask, xfer_mode, pci_addr, vme_addr, n_bytes);
|
||||
}
|
||||
|
||||
int
|
||||
BSP_VMEDmaListStart(int channel, BSP_VMEDmaListDescriptor list)
|
||||
{
|
||||
return BSP_VMEDmaListDescriptorStartTool(0, channel, list);
|
||||
}
|
||||
|
||||
/* NOT thread safe! */
|
||||
int
|
||||
BSP_VMEDmaInstallISR(int channel, BSP_VMEDmaIRQCallback cb, void *usr_arg)
|
||||
{
|
||||
int vec;
|
||||
BSP_VME_ISR_t curr;
|
||||
void *carg;
|
||||
|
||||
if ( channel < 0 || channel >= theDmaOps->nChannels )
|
||||
return -1;
|
||||
|
||||
vec = theDmaOps->vectors[channel];
|
||||
|
||||
curr = BSP_getVME_isr(vec, &carg);
|
||||
|
||||
if ( cb && curr ) {
|
||||
/* IRQ currently in use */
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( !cb && !curr ) {
|
||||
/* Allow uninstall if no handler is currently installed;
|
||||
* just make sure IRQ is disabled
|
||||
*/
|
||||
BSP_disableVME_int_lvl(vec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( cb ) {
|
||||
if ( BSP_installVME_isr(vec, (BSP_VME_ISR_t)cb, usr_arg) )
|
||||
return -4;
|
||||
BSP_enableVME_int_lvl(vec);
|
||||
} else {
|
||||
BSP_disableVME_int_lvl(vec);
|
||||
if ( BSP_removeVME_isr(vec, curr, carg) )
|
||||
return -4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_VME_DRIVER_TSI148) && !defined(VME_CLEAR_BRIDGE_ERRORS)
|
||||
static unsigned short
|
||||
tsi_clear_errors(int quiet)
|
||||
|
||||
@@ -1,146 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Implementation of the VMEDMA.h API for the BSP using the vmeUniverse driver */
|
||||
|
||||
/*
|
||||
* Authorship
|
||||
* ----------
|
||||
* This software was created by
|
||||
* Till Straumann <strauman@slac.stanford.edu>, 2006, 2007
|
||||
* Stanford Linear Accelerator Center, Stanford University.
|
||||
*
|
||||
* Acknowledgement of sponsorship
|
||||
* ------------------------------
|
||||
* This software was produced by
|
||||
* the Stanford Linear Accelerator Center, Stanford University,
|
||||
* under Contract DE-AC03-76SFO0515 with the Department of Energy.
|
||||
*
|
||||
* Government disclaimer of liability
|
||||
* ----------------------------------
|
||||
* Neither the United States nor the United States Department of Energy,
|
||||
* nor any of their employees, makes any warranty, express or implied, or
|
||||
* assumes any legal liability or responsibility for the accuracy,
|
||||
* completeness, or usefulness of any data, apparatus, product, or process
|
||||
* disclosed, or represents that its use would not infringe privately owned
|
||||
* rights.
|
||||
*
|
||||
* Stanford disclaimer of liability
|
||||
* --------------------------------
|
||||
* Stanford University makes no representations or warranties, express or
|
||||
* implied, nor assumes any liability for the use of this software.
|
||||
*
|
||||
* Stanford disclaimer of copyright
|
||||
* --------------------------------
|
||||
* Stanford University, owner of the copyright, hereby disclaims its
|
||||
* copyright and all other rights in this software. Hence, anyone may
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* Maintenance of notices
|
||||
* ----------------------
|
||||
* In the interest of clarity regarding the origin and status of this
|
||||
* SLAC software, this and all the preceding Stanford University notices
|
||||
* are to remain affixed to any copy or derivative of this software made
|
||||
* or distributed by the recipient and are to be affixed to any copy of
|
||||
* software made or distributed by the recipient that contains a copy or
|
||||
* derivative of this software.
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <rtems.h>
|
||||
#include <bsp.h>
|
||||
#include <bsp/VME.h>
|
||||
#include <bsp/VMEDMA.h>
|
||||
#include <bsp/vmeUniverse.h>
|
||||
#include <bsp/vmeUniverseDMA.h>
|
||||
#include <bsp/bspVmeDmaList.h>
|
||||
|
||||
int
|
||||
BSP_VMEDmaSetup(int channel, uint32_t bus_mode, uint32_t xfer_mode, void *custom_setup)
|
||||
{
|
||||
return vmeUniverseDmaSetup(channel, bus_mode, xfer_mode, custom_setup);
|
||||
}
|
||||
|
||||
int
|
||||
BSP_VMEDmaStart(int channel, uint32_t pci_addr, uint32_t vme_addr, uint32_t n_bytes)
|
||||
{
|
||||
return vmeUniverseDmaStart(channel, pci_addr, vme_addr, n_bytes);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
BSP_VMEDmaStatus(int channel)
|
||||
{
|
||||
return vmeUniverseDmaStatus(channel);
|
||||
}
|
||||
|
||||
BSP_VMEDmaListDescriptor
|
||||
BSP_VMEDmaListDescriptorSetup(
|
||||
BSP_VMEDmaListDescriptor d,
|
||||
uint32_t attr_mask,
|
||||
uint32_t xfer_mode,
|
||||
uint32_t pci_addr,
|
||||
uint32_t vme_addr,
|
||||
uint32_t n_bytes)
|
||||
{
|
||||
VMEDmaListClass pc;
|
||||
if ( !d ) {
|
||||
pc = &vmeUniverseDmaListClass;
|
||||
|
||||
return BSP_VMEDmaListDescriptorNewTool(
|
||||
pc,
|
||||
attr_mask,
|
||||
xfer_mode,
|
||||
pci_addr,
|
||||
vme_addr,
|
||||
n_bytes);
|
||||
|
||||
}
|
||||
return BSP_VMEDmaListDescriptorSetupTool(d, attr_mask, xfer_mode, pci_addr, vme_addr, n_bytes);
|
||||
}
|
||||
|
||||
int
|
||||
BSP_VMEDmaListStart(int channel, BSP_VMEDmaListDescriptor list)
|
||||
{
|
||||
return BSP_VMEDmaListDescriptorStartTool(0, channel, list);
|
||||
}
|
||||
|
||||
/* NOT thread safe! */
|
||||
int
|
||||
BSP_VMEDmaInstallISR(int channel, BSP_VMEDmaIRQCallback cb, void *usr_arg)
|
||||
{
|
||||
int vec;
|
||||
BSP_VME_ISR_t curr;
|
||||
void *carg;
|
||||
|
||||
if ( channel != 0 )
|
||||
return -1;
|
||||
|
||||
vec = UNIV_DMA_INT_VEC;
|
||||
|
||||
curr = BSP_getVME_isr(vec, &carg);
|
||||
|
||||
if ( cb && curr ) {
|
||||
/* IRQ currently in use */
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( !cb && !curr ) {
|
||||
/* Allow uninstall if no handler is currently installed;
|
||||
* just make sure IRQ is disabled
|
||||
*/
|
||||
BSP_disableVME_int_lvl(vec);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( cb ) {
|
||||
if ( BSP_installVME_isr(vec, (BSP_VME_ISR_t)cb, usr_arg) )
|
||||
return -4;
|
||||
BSP_enableVME_int_lvl(vec);
|
||||
} else {
|
||||
BSP_disableVME_int_lvl(vec);
|
||||
if ( BSP_removeVME_isr(vec, curr, carg) )
|
||||
return -4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user