File indexing completed on 2025-05-11 08:23:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 #include <stdio.h>
0049 #include <stdint.h>
0050 #include <rtems.h>
0051 #include <bsp.h>
0052 #include <bsp/VME.h>
0053 #include <bsp/vmeTsi148.h>
0054 #include <bsp/vmeUniverse.h>
0055 #include <bsp/VMEDMA.h>
0056 #include <bsp/vmeTsi148DMA.h>
0057 #include <bsp/vmeUniverseDMA.h>
0058 #include <bsp/bspVmeDmaList.h>
0059
0060 typedef struct DmaOpsRec_ {
0061 int (*setup)(int, uint32_t, uint32_t, void *);
0062 int (*start)(int, uint32_t, uint32_t, uint32_t);
0063 uint32_t (*status)(int);
0064 VMEDmaListClass listClass;
0065 } DmaOpsRec, *DmaOps;
0066
0067 static DmaOpsRec universeOps = {
0068 vmeUniverseDmaSetup,
0069 vmeUniverseDmaStart,
0070 vmeUniverseDmaStatus,
0071 &vmeUniverseDmaListClass,
0072 };
0073
0074 static DmaOpsRec tsiOps = {
0075 vmeTsi148DmaSetup,
0076 vmeTsi148DmaStart,
0077 vmeTsi148DmaStatus,
0078 &vmeTsi148DmaListClass,
0079 };
0080
0081 static int setup(int a, uint32_t b, uint32_t c, void *d);
0082 static int start(int a, uint32_t b, uint32_t c, uint32_t d);
0083 static uint32_t status(int a);
0084
0085 static DmaOpsRec jumpstartOps = {
0086 setup,
0087 start,
0088 status,
0089 0
0090 };
0091
0092 static DmaOps dmaOps = &jumpstartOps;
0093
0094 static DmaOps selectOps()
0095 {
0096 return (MVME6100 != BSP_getBoardType()) ?
0097 &universeOps : &tsiOps;
0098 }
0099
0100 static int
0101 setup(int a, uint32_t b, uint32_t c, void *d)
0102 {
0103 return (dmaOps=selectOps())->setup(a,b,c,d);
0104 }
0105
0106 static int
0107 start(int a, uint32_t b, uint32_t c, uint32_t d)
0108 {
0109 return (dmaOps=selectOps())->start(a,b,c,d);
0110 }
0111
0112 static uint32_t
0113 status(int a)
0114 {
0115 return (dmaOps=selectOps())->status(a);
0116 }
0117
0118
0119 int
0120 BSP_VMEDmaSetup(int channel, uint32_t bus_mode, uint32_t xfer_mode, void *custom_setup)
0121 {
0122 return dmaOps->setup(channel, bus_mode, xfer_mode, custom_setup);
0123 }
0124
0125 int
0126 BSP_VMEDmaStart(int channel, uint32_t pci_addr, uint32_t vme_addr, uint32_t n_bytes)
0127 {
0128 return dmaOps->start(channel, pci_addr, vme_addr, n_bytes);
0129 }
0130
0131 uint32_t
0132 BSP_VMEDmaStatus(int channel)
0133 {
0134 return dmaOps->status(channel);
0135 }
0136
0137 BSP_VMEDmaListDescriptor
0138 BSP_VMEDmaListDescriptorSetup(
0139 BSP_VMEDmaListDescriptor d,
0140 uint32_t attr_mask,
0141 uint32_t xfer_mode,
0142 uint32_t pci_addr,
0143 uint32_t vme_addr,
0144 uint32_t n_bytes)
0145 {
0146 VMEDmaListClass pc;
0147 if ( !d ) {
0148 if ( ! (pc = dmaOps->listClass) ) {
0149 pc = (dmaOps = selectOps())->listClass;
0150 }
0151 return BSP_VMEDmaListDescriptorNewTool(
0152 pc,
0153 attr_mask,
0154 xfer_mode,
0155 pci_addr,
0156 vme_addr,
0157 n_bytes);
0158
0159 }
0160 return BSP_VMEDmaListDescriptorSetupTool(d, attr_mask, xfer_mode, pci_addr, vme_addr, n_bytes);
0161 }
0162
0163 int
0164 BSP_VMEDmaListStart(int channel, BSP_VMEDmaListDescriptor list)
0165 {
0166 return BSP_VMEDmaListDescriptorStartTool(0, channel, list);
0167 }
0168
0169
0170 int
0171 BSP_VMEDmaInstallISR(int channel, BSP_VMEDmaIRQCallback cb, void *usr_arg)
0172 {
0173 int vec;
0174 BSP_VME_ISR_t curr;
0175 void *carg;
0176
0177 if ( MVME6100 != BSP_getBoardType() ) {
0178 if ( channel != 0 )
0179 return -1;
0180
0181 vec = UNIV_DMA_INT_VEC;
0182
0183 } else {
0184 if ( channel < 0 || channel > 1 )
0185 return -1;
0186
0187 vec = (channel ? TSI_DMA1_INT_VEC : TSI_DMA_INT_VEC );
0188 }
0189
0190 curr = BSP_getVME_isr(vec, &carg);
0191
0192 if ( cb && curr ) {
0193
0194 return -1;
0195 }
0196
0197 if ( !cb && !curr ) {
0198
0199
0200
0201 BSP_disableVME_int_lvl(vec);
0202 return 0;
0203 }
0204
0205 if ( cb ) {
0206 if ( BSP_installVME_isr(vec, (BSP_VME_ISR_t)cb, usr_arg) )
0207 return -4;
0208 BSP_enableVME_int_lvl(vec);
0209 } else {
0210 BSP_disableVME_int_lvl(vec);
0211 if ( BSP_removeVME_isr(vec, curr, carg) )
0212 return -4;
0213 }
0214 return 0;
0215 }