source: rtems/c/src/lib/libbsp/powerpc/beatnik/vme/vme_dma.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/* Setup/glue to attach VME DMA driver to the beatnik BSP */
2
3/*
4 * Authorship
5 * ----------
6 * This software ('beatnik' RTEMS BSP for MVME6100 and MVME5500) was
7 *     created by Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
8 *         Stanford Linear Accelerator Center, Stanford University.
9 *
10 * Acknowledgement of sponsorship
11 * ------------------------------
12 * The 'beatnik' BSP was produced by
13 *     the Stanford Linear Accelerator Center, Stanford University,
14 *         under Contract DE-AC03-76SFO0515 with the Department of Energy.
15 *
16 * Government disclaimer of liability
17 * ----------------------------------
18 * Neither the United States nor the United States Department of Energy,
19 * nor any of their employees, makes any warranty, express or implied, or
20 * assumes any legal liability or responsibility for the accuracy,
21 * completeness, or usefulness of any data, apparatus, product, or process
22 * disclosed, or represents that its use would not infringe privately owned
23 * rights.
24 *
25 * Stanford disclaimer of liability
26 * --------------------------------
27 * Stanford University makes no representations or warranties, express or
28 * implied, nor assumes any liability for the use of this software.
29 *
30 * Stanford disclaimer of copyright
31 * --------------------------------
32 * Stanford University, owner of the copyright, hereby disclaims its
33 * copyright and all other rights in this software.  Hence, anyone may
34 * freely use it for any purpose without restriction. 
35 *
36 * Maintenance of notices
37 * ----------------------
38 * In the interest of clarity regarding the origin and status of this
39 * SLAC software, this and all the preceding Stanford University notices
40 * are to remain affixed to any copy or derivative of this software made
41 * or distributed by the recipient and are to be affixed to any copy of
42 * software made or distributed by the recipient that contains a copy or
43 * derivative of this software.
44 *
45 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
46 */
47
48#include <stdio.h>
49#include <stdint.h>
50#include <rtems.h>
51#include <bsp.h>
52#include <bsp/VME.h>
53#include <bsp/vmeTsi148.h>
54#include <bsp/vmeUniverse.h>
55#include <bsp/VMEDMA.h>
56#include <bsp/vmeTsi148DMA.h>
57#include <bsp/vmeUniverseDMA.h>
58#include <bsp/bspVmeDmaList.h>
59
60typedef struct DmaOpsRec_ {
61        int                             (*setup)(int, uint32_t, uint32_t, void *);
62        int                             (*start)(int, uint32_t, uint32_t, uint32_t);
63        uint32_t                (*status)(int);
64        VMEDmaListClass listClass;
65} DmaOpsRec, *DmaOps;
66
67static DmaOpsRec universeOps = {
68        vmeUniverseDmaSetup,
69        vmeUniverseDmaStart,
70        vmeUniverseDmaStatus,
71        &vmeUniverseDmaListClass,
72};
73
74static DmaOpsRec tsiOps = {
75        vmeTsi148DmaSetup,
76        vmeTsi148DmaStart,
77        vmeTsi148DmaStatus,
78        &vmeTsi148DmaListClass,
79};
80
81static int      setup(int a, uint32_t b, uint32_t c, void *d);
82static int      start(int a, uint32_t b, uint32_t c, uint32_t d);
83static uint32_t status(int a);
84
85static DmaOpsRec jumpstartOps = {
86        setup,
87        start,
88        status,
89        0
90};
91
92static DmaOps dmaOps = &jumpstartOps;
93
94static DmaOps selectOps()
95{
96        return (MVME6100 != BSP_getBoardType()) ?
97                                &universeOps : &tsiOps;
98}
99
100static int
101setup(int a, uint32_t b, uint32_t c, void *d)
102{
103        return (dmaOps=selectOps())->setup(a,b,c,d);
104}
105
106static int
107start(int a, uint32_t b, uint32_t c, uint32_t d)
108{
109        return (dmaOps=selectOps())->start(a,b,c,d);
110}
111
112static uint32_t
113status(int a)
114{
115        return (dmaOps=selectOps())->status(a);
116}
117
118
119int
120BSP_VMEDmaSetup(int channel, uint32_t bus_mode, uint32_t xfer_mode, void *custom_setup)
121{
122        return dmaOps->setup(channel, bus_mode, xfer_mode, custom_setup);
123}
124
125int
126BSP_VMEDmaStart(int channel, uint32_t pci_addr, uint32_t vme_addr, uint32_t n_bytes)
127{
128        return dmaOps->start(channel, pci_addr, vme_addr, n_bytes);
129}
130
131uint32_t
132BSP_VMEDmaStatus(int channel)
133{
134        return dmaOps->status(channel);
135}
136
137BSP_VMEDmaListDescriptor
138BSP_VMEDmaListDescriptorSetup(
139                BSP_VMEDmaListDescriptor d,
140                uint32_t                 attr_mask,
141                uint32_t                                 xfer_mode,
142                uint32_t                 pci_addr,
143                uint32_t                 vme_addr,
144                uint32_t                 n_bytes)
145{
146VMEDmaListClass pc;
147        if ( !d ) {
148                if ( ! (pc = dmaOps->listClass) ) {
149                        pc = (dmaOps = selectOps())->listClass;
150                }
151                return BSP_VMEDmaListDescriptorNewTool(
152                                        pc,
153                                        attr_mask,
154                                        xfer_mode,
155                                        pci_addr,
156                                        vme_addr,
157                                        n_bytes);
158                                       
159        }
160        return BSP_VMEDmaListDescriptorSetupTool(d, attr_mask, xfer_mode, pci_addr, vme_addr, n_bytes);
161}
162
163int
164BSP_VMEDmaListStart(int channel, BSP_VMEDmaListDescriptor list)
165{
166        return BSP_VMEDmaListDescriptorStartTool(0, channel, list);
167}
168
169/* NOT thread safe! */
170int
171BSP_VMEDmaInstallISR(int channel, BSP_VMEDmaIRQCallback cb, void *usr_arg)
172{
173int vec;
174BSP_VME_ISR_t curr;
175void          *carg;
176
177        if ( MVME6100 != BSP_getBoardType() ) {
178                if ( channel != 0 )
179                        return -1;
180
181                vec = UNIV_DMA_INT_VEC;
182
183        } else {
184                if ( channel < 0 || channel > 1 )
185                        return -1;
186
187                vec  = (channel ? TSI_DMA1_INT_VEC : TSI_DMA_INT_VEC );
188        }
189
190        curr = BSP_getVME_isr(vec, &carg);
191
192        if ( cb && curr ) {
193                /* IRQ currently in use */
194                return -1;
195        }
196
197        if ( !cb && !curr ) {
198                /* Allow uninstall if no handler is currently installed;
199                 * just make sure IRQ is disabled
200                 */
201                BSP_disableVME_int_lvl(vec);
202                return 0;
203        }
204       
205        if ( cb ) {
206                if ( BSP_installVME_isr(vec, (BSP_VME_ISR_t)cb, usr_arg) )
207                        return -4;
208                BSP_enableVME_int_lvl(vec);
209        } else {
210                BSP_disableVME_int_lvl(vec);
211                if ( BSP_removeVME_isr(vec, curr, carg) )
212                        return -4;
213        }
214        return 0;
215}
Note: See TracBrowser for help on using the repository browser.