dma.c revision 1.5 1 1.5 cgd /* $NetBSD: dma.c,v 1.5 1994/10/26 07:23:40 cgd Exp $ */
2 1.5 cgd
3 1.1 cgd /*
4 1.4 mycroft * Copyright (c) 1982, 1990, 1993
5 1.4 mycroft * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.1 cgd * This product includes software developed by the University of
18 1.1 cgd * California, Berkeley and its contributors.
19 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
20 1.1 cgd * may be used to endorse or promote products derived from this software
21 1.1 cgd * without specific prior written permission.
22 1.1 cgd *
23 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 cgd * SUCH DAMAGE.
34 1.1 cgd *
35 1.5 cgd * @(#)dma.c 8.1 (Berkeley) 6/10/93
36 1.1 cgd */
37 1.1 cgd
38 1.1 cgd /*
39 1.1 cgd * DMA driver
40 1.1 cgd */
41 1.1 cgd
42 1.4 mycroft #include <sys/param.h>
43 1.4 mycroft #include <sys/systm.h>
44 1.4 mycroft #include <sys/time.h>
45 1.4 mycroft #include <sys/kernel.h>
46 1.4 mycroft #include <sys/proc.h>
47 1.4 mycroft
48 1.4 mycroft #include <machine/cpu.h>
49 1.4 mycroft
50 1.4 mycroft #include <hp300/dev/device.h>
51 1.4 mycroft #include <hp300/dev/dmareg.h>
52 1.4 mycroft #include <hp300/dev/dmavar.h>
53 1.1 cgd
54 1.4 mycroft #include <hp300/hp300/isr.h>
55 1.1 cgd
56 1.1 cgd extern void isrlink();
57 1.1 cgd extern void _insque();
58 1.1 cgd extern void _remque();
59 1.1 cgd extern u_int kvtop();
60 1.1 cgd extern void PCIA();
61 1.1 cgd
62 1.1 cgd /*
63 1.1 cgd * The largest single request will be MAXPHYS bytes which will require
64 1.1 cgd * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
65 1.1 cgd * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
66 1.1 cgd * buffer is not page aligned (+1).
67 1.1 cgd */
68 1.1 cgd #define DMAMAXIO (MAXPHYS/NBPG+1)
69 1.1 cgd
70 1.1 cgd struct dma_chain {
71 1.1 cgd int dc_count;
72 1.1 cgd char *dc_addr;
73 1.1 cgd };
74 1.1 cgd
75 1.1 cgd struct dma_softc {
76 1.1 cgd struct dmadevice *sc_hwaddr;
77 1.1 cgd struct dmaBdevice *sc_Bhwaddr;
78 1.1 cgd char sc_type;
79 1.1 cgd char sc_flags;
80 1.1 cgd u_short sc_cmd;
81 1.1 cgd struct dma_chain *sc_cur;
82 1.1 cgd struct dma_chain *sc_last;
83 1.1 cgd struct dma_chain sc_chain[DMAMAXIO];
84 1.1 cgd } dma_softc[NDMA];
85 1.1 cgd
86 1.1 cgd /* types */
87 1.1 cgd #define DMA_B 0
88 1.1 cgd #define DMA_C 1
89 1.1 cgd
90 1.1 cgd /* flags */
91 1.1 cgd #define DMAF_PCFLUSH 0x01
92 1.1 cgd #define DMAF_VCFLUSH 0x02
93 1.1 cgd #define DMAF_NOINTR 0x04
94 1.1 cgd
95 1.1 cgd struct devqueue dmachan[NDMA + 1];
96 1.1 cgd int dmaintr();
97 1.1 cgd
98 1.1 cgd #ifdef DEBUG
99 1.1 cgd int dmadebug = 0;
100 1.1 cgd #define DDB_WORD 0x01 /* same as DMAGO_WORD */
101 1.1 cgd #define DDB_LWORD 0x02 /* same as DMAGO_LWORD */
102 1.1 cgd #define DDB_FOLLOW 0x04
103 1.1 cgd #define DDB_IO 0x08
104 1.1 cgd
105 1.3 mycroft void dmatimeout __P((void *));
106 1.1 cgd int dmatimo[NDMA];
107 1.1 cgd
108 1.1 cgd long dmahits[NDMA];
109 1.1 cgd long dmamisses[NDMA];
110 1.1 cgd long dmabyte[NDMA];
111 1.1 cgd long dmaword[NDMA];
112 1.1 cgd long dmalword[NDMA];
113 1.1 cgd #endif
114 1.1 cgd
115 1.1 cgd void
116 1.1 cgd dmainit()
117 1.1 cgd {
118 1.1 cgd register struct dmareg *dma = (struct dmareg *)DMA_BASE;
119 1.1 cgd register struct dma_softc *dc;
120 1.1 cgd register int i;
121 1.1 cgd char rev;
122 1.1 cgd
123 1.1 cgd /*
124 1.1 cgd * Determine the DMA type.
125 1.1 cgd * Don't know how to easily differentiate the A and B cards,
126 1.1 cgd * so we just hope nobody has an A card (A cards will work if
127 1.1 cgd * DMAINTLVL is set to 3).
128 1.1 cgd */
129 1.1 cgd if (!badbaddr((char *)&dma->dma_id[2]))
130 1.1 cgd rev = dma->dma_id[2];
131 1.1 cgd else {
132 1.1 cgd rev = 'B';
133 1.1 cgd #if !defined(HP320)
134 1.1 cgd panic("dmainit: DMA card requires hp320 support");
135 1.1 cgd #endif
136 1.1 cgd }
137 1.1 cgd
138 1.1 cgd dc = &dma_softc[0];
139 1.1 cgd for (i = 0; i < NDMA; i++) {
140 1.1 cgd dc->sc_hwaddr = (i & 1) ? &dma->dma_chan1 : &dma->dma_chan0;
141 1.1 cgd dc->sc_Bhwaddr = (i & 1) ? &dma->dma_Bchan1 : &dma->dma_Bchan0;
142 1.1 cgd dc->sc_type = rev == 'B' ? DMA_B : DMA_C;
143 1.1 cgd dc++;
144 1.1 cgd dmachan[i].dq_forw = dmachan[i].dq_back = &dmachan[i];
145 1.1 cgd }
146 1.1 cgd dmachan[i].dq_forw = dmachan[i].dq_back = &dmachan[i];
147 1.1 cgd #ifdef DEBUG
148 1.1 cgd /* make sure timeout is really not needed */
149 1.4 mycroft timeout(dmatimeout, (void *)0, 30 * hz);
150 1.1 cgd #endif
151 1.1 cgd
152 1.1 cgd printf("dma: 98620%c with 2 channels, %d bit DMA\n",
153 1.1 cgd rev, rev == 'B' ? 16 : 32);
154 1.1 cgd }
155 1.1 cgd
156 1.1 cgd int
157 1.1 cgd dmareq(dq)
158 1.1 cgd register struct devqueue *dq;
159 1.1 cgd {
160 1.1 cgd register int i;
161 1.1 cgd register int chan;
162 1.1 cgd register int s = splbio();
163 1.1 cgd
164 1.1 cgd chan = dq->dq_ctlr;
165 1.1 cgd i = NDMA;
166 1.1 cgd while (--i >= 0) {
167 1.1 cgd if ((chan & (1 << i)) == 0)
168 1.1 cgd continue;
169 1.1 cgd if (dmachan[i].dq_forw != &dmachan[i])
170 1.1 cgd continue;
171 1.1 cgd insque(dq, &dmachan[i]);
172 1.1 cgd dq->dq_ctlr = i;
173 1.1 cgd splx(s);
174 1.1 cgd return(1);
175 1.1 cgd }
176 1.1 cgd insque(dq, dmachan[NDMA].dq_back);
177 1.1 cgd splx(s);
178 1.1 cgd return(0);
179 1.1 cgd }
180 1.1 cgd
181 1.1 cgd void
182 1.1 cgd dmafree(dq)
183 1.1 cgd register struct devqueue *dq;
184 1.1 cgd {
185 1.1 cgd int unit = dq->dq_ctlr;
186 1.1 cgd register struct dma_softc *dc = &dma_softc[unit];
187 1.1 cgd register struct devqueue *dn;
188 1.1 cgd register int chan, s;
189 1.1 cgd
190 1.1 cgd s = splbio();
191 1.1 cgd #ifdef DEBUG
192 1.1 cgd dmatimo[unit] = 0;
193 1.1 cgd #endif
194 1.1 cgd DMA_CLEAR(dc);
195 1.4 mycroft #if defined(HP360) || defined(HP370) || defined(HP380)
196 1.1 cgd /*
197 1.1 cgd * XXX we may not always go thru the flush code in dmastop()
198 1.1 cgd */
199 1.1 cgd if (dc->sc_flags & DMAF_PCFLUSH) {
200 1.1 cgd PCIA();
201 1.1 cgd dc->sc_flags &= ~DMAF_PCFLUSH;
202 1.1 cgd }
203 1.1 cgd #endif
204 1.1 cgd #if defined(HP320) || defined(HP350)
205 1.1 cgd if (dc->sc_flags & DMAF_VCFLUSH) {
206 1.1 cgd /*
207 1.1 cgd * 320/350s have VACs that may also need flushing.
208 1.1 cgd * In our case we only flush the supervisor side
209 1.1 cgd * because we know that if we are DMAing to user
210 1.1 cgd * space, the physical pages will also be mapped
211 1.1 cgd * in kernel space (via vmapbuf) and hence cache-
212 1.1 cgd * inhibited by the pmap module due to the multiple
213 1.1 cgd * mapping.
214 1.1 cgd */
215 1.1 cgd DCIS();
216 1.1 cgd dc->sc_flags &= ~DMAF_VCFLUSH;
217 1.1 cgd }
218 1.1 cgd #endif
219 1.1 cgd remque(dq);
220 1.1 cgd chan = 1 << unit;
221 1.1 cgd for (dn = dmachan[NDMA].dq_forw;
222 1.1 cgd dn != &dmachan[NDMA]; dn = dn->dq_forw) {
223 1.1 cgd if (dn->dq_ctlr & chan) {
224 1.1 cgd remque((caddr_t)dn);
225 1.1 cgd insque((caddr_t)dn, (caddr_t)dq->dq_back);
226 1.1 cgd splx(s);
227 1.1 cgd dn->dq_ctlr = dq->dq_ctlr;
228 1.1 cgd (dn->dq_driver->d_start)(dn->dq_unit);
229 1.1 cgd return;
230 1.1 cgd }
231 1.1 cgd }
232 1.1 cgd splx(s);
233 1.1 cgd }
234 1.1 cgd
235 1.1 cgd void
236 1.1 cgd dmago(unit, addr, count, flags)
237 1.1 cgd int unit;
238 1.1 cgd register char *addr;
239 1.1 cgd register int count;
240 1.1 cgd register int flags;
241 1.1 cgd {
242 1.1 cgd register struct dma_softc *dc = &dma_softc[unit];
243 1.1 cgd register struct dma_chain *dcp;
244 1.1 cgd register char *dmaend = NULL;
245 1.1 cgd register int tcount;
246 1.1 cgd
247 1.1 cgd if (count > MAXPHYS)
248 1.1 cgd panic("dmago: count > MAXPHYS");
249 1.1 cgd #if defined(HP320)
250 1.1 cgd if (dc->sc_type == DMA_B && (flags & DMAGO_LWORD))
251 1.1 cgd panic("dmago: no can do 32-bit DMA");
252 1.1 cgd #endif
253 1.1 cgd #ifdef DEBUG
254 1.1 cgd if (dmadebug & DDB_FOLLOW)
255 1.1 cgd printf("dmago(%d, %x, %x, %x)\n",
256 1.1 cgd unit, addr, count, flags);
257 1.1 cgd if (flags & DMAGO_LWORD)
258 1.1 cgd dmalword[unit]++;
259 1.1 cgd else if (flags & DMAGO_WORD)
260 1.1 cgd dmaword[unit]++;
261 1.1 cgd else
262 1.1 cgd dmabyte[unit]++;
263 1.1 cgd #endif
264 1.1 cgd /*
265 1.1 cgd * Build the DMA chain
266 1.1 cgd */
267 1.1 cgd for (dcp = dc->sc_chain; count > 0; dcp++) {
268 1.1 cgd dcp->dc_addr = (char *) kvtop(addr);
269 1.4 mycroft #if defined(HP380)
270 1.4 mycroft /*
271 1.4 mycroft * Push back dirty cache lines
272 1.4 mycroft */
273 1.4 mycroft if (mmutype == MMU_68040)
274 1.4 mycroft DCFP(dcp->dc_addr);
275 1.4 mycroft #endif
276 1.1 cgd if (count < (tcount = NBPG - ((int)addr & PGOFSET)))
277 1.1 cgd tcount = count;
278 1.1 cgd dcp->dc_count = tcount;
279 1.1 cgd addr += tcount;
280 1.1 cgd count -= tcount;
281 1.1 cgd if (flags & DMAGO_LWORD)
282 1.1 cgd tcount >>= 2;
283 1.1 cgd else if (flags & DMAGO_WORD)
284 1.1 cgd tcount >>= 1;
285 1.1 cgd if (dcp->dc_addr == dmaend
286 1.1 cgd #if defined(HP320)
287 1.1 cgd /* only 16-bit count on 98620B */
288 1.1 cgd && (dc->sc_type != DMA_B ||
289 1.1 cgd (dcp-1)->dc_count + tcount <= 65536)
290 1.1 cgd #endif
291 1.1 cgd ) {
292 1.1 cgd #ifdef DEBUG
293 1.1 cgd dmahits[unit]++;
294 1.1 cgd #endif
295 1.1 cgd dmaend += dcp->dc_count;
296 1.1 cgd (--dcp)->dc_count += tcount;
297 1.1 cgd } else {
298 1.1 cgd #ifdef DEBUG
299 1.1 cgd dmamisses[unit]++;
300 1.1 cgd #endif
301 1.1 cgd dmaend = dcp->dc_addr + dcp->dc_count;
302 1.1 cgd dcp->dc_count = tcount;
303 1.1 cgd }
304 1.1 cgd }
305 1.1 cgd dc->sc_cur = dc->sc_chain;
306 1.1 cgd dc->sc_last = --dcp;
307 1.1 cgd dc->sc_flags = 0;
308 1.1 cgd /*
309 1.1 cgd * Set up the command word based on flags
310 1.1 cgd */
311 1.1 cgd dc->sc_cmd = DMA_ENAB | DMA_IPL(DMAINTLVL) | DMA_START;
312 1.1 cgd if ((flags & DMAGO_READ) == 0)
313 1.1 cgd dc->sc_cmd |= DMA_WRT;
314 1.1 cgd if (flags & DMAGO_LWORD)
315 1.1 cgd dc->sc_cmd |= DMA_LWORD;
316 1.1 cgd else if (flags & DMAGO_WORD)
317 1.1 cgd dc->sc_cmd |= DMA_WORD;
318 1.1 cgd if (flags & DMAGO_PRI)
319 1.1 cgd dc->sc_cmd |= DMA_PRI;
320 1.4 mycroft #if defined(HP380)
321 1.4 mycroft /*
322 1.4 mycroft * On the 68040 we need to flush (push) the data cache before a
323 1.4 mycroft * DMA (already done above) and flush again after DMA completes.
324 1.4 mycroft * In theory we should only need to flush prior to a write DMA
325 1.4 mycroft * and purge after a read DMA but if the entire page is not
326 1.4 mycroft * involved in the DMA we might purge some valid data.
327 1.4 mycroft */
328 1.4 mycroft if (mmutype == MMU_68040 && (flags & DMAGO_READ))
329 1.4 mycroft dc->sc_flags |= DMAF_PCFLUSH;
330 1.4 mycroft #endif
331 1.1 cgd #if defined(HP360) || defined(HP370)
332 1.1 cgd /*
333 1.1 cgd * Remember if we need to flush external physical cache when
334 1.1 cgd * DMA is done. We only do this if we are reading (writing memory).
335 1.1 cgd */
336 1.1 cgd if (ectype == EC_PHYS && (flags & DMAGO_READ))
337 1.1 cgd dc->sc_flags |= DMAF_PCFLUSH;
338 1.1 cgd #endif
339 1.1 cgd #if defined(HP320) || defined(HP350)
340 1.1 cgd if (ectype == EC_VIRT && (flags & DMAGO_READ))
341 1.1 cgd dc->sc_flags |= DMAF_VCFLUSH;
342 1.1 cgd #endif
343 1.1 cgd /*
344 1.1 cgd * Remember if we can skip the dma completion interrupt on
345 1.1 cgd * the last segment in the chain.
346 1.1 cgd */
347 1.1 cgd if (flags & DMAGO_NOINT) {
348 1.1 cgd if (dc->sc_cur == dc->sc_last)
349 1.1 cgd dc->sc_cmd &= ~DMA_ENAB;
350 1.1 cgd else
351 1.1 cgd dc->sc_flags |= DMAF_NOINTR;
352 1.1 cgd }
353 1.1 cgd #ifdef DEBUG
354 1.1 cgd if (dmadebug & DDB_IO)
355 1.1 cgd if ((dmadebug&DDB_WORD) && (dc->sc_cmd&DMA_WORD) ||
356 1.1 cgd (dmadebug&DDB_LWORD) && (dc->sc_cmd&DMA_LWORD)) {
357 1.1 cgd printf("dmago: cmd %x, flags %x\n",
358 1.1 cgd dc->sc_cmd, dc->sc_flags);
359 1.1 cgd for (dcp = dc->sc_chain; dcp <= dc->sc_last; dcp++)
360 1.1 cgd printf(" %d: %d@%x\n", dcp-dc->sc_chain,
361 1.1 cgd dcp->dc_count, dcp->dc_addr);
362 1.1 cgd }
363 1.1 cgd dmatimo[unit] = 1;
364 1.1 cgd #endif
365 1.1 cgd DMA_ARM(dc);
366 1.1 cgd }
367 1.1 cgd
368 1.1 cgd void
369 1.1 cgd dmastop(unit)
370 1.1 cgd register int unit;
371 1.1 cgd {
372 1.1 cgd register struct dma_softc *dc = &dma_softc[unit];
373 1.1 cgd register struct devqueue *dq;
374 1.1 cgd
375 1.1 cgd #ifdef DEBUG
376 1.1 cgd if (dmadebug & DDB_FOLLOW)
377 1.1 cgd printf("dmastop(%d)\n", unit);
378 1.1 cgd dmatimo[unit] = 0;
379 1.1 cgd #endif
380 1.1 cgd DMA_CLEAR(dc);
381 1.4 mycroft #if defined(HP360) || defined(HP370) || defined(HP380)
382 1.1 cgd if (dc->sc_flags & DMAF_PCFLUSH) {
383 1.1 cgd PCIA();
384 1.1 cgd dc->sc_flags &= ~DMAF_PCFLUSH;
385 1.1 cgd }
386 1.1 cgd #endif
387 1.1 cgd #if defined(HP320) || defined(HP350)
388 1.1 cgd if (dc->sc_flags & DMAF_VCFLUSH) {
389 1.1 cgd /*
390 1.1 cgd * 320/350s have VACs that may also need flushing.
391 1.1 cgd * In our case we only flush the supervisor side
392 1.1 cgd * because we know that if we are DMAing to user
393 1.1 cgd * space, the physical pages will also be mapped
394 1.1 cgd * in kernel space (via vmapbuf) and hence cache-
395 1.1 cgd * inhibited by the pmap module due to the multiple
396 1.1 cgd * mapping.
397 1.1 cgd */
398 1.1 cgd DCIS();
399 1.1 cgd dc->sc_flags &= ~DMAF_VCFLUSH;
400 1.1 cgd }
401 1.1 cgd #endif
402 1.1 cgd /*
403 1.1 cgd * We may get this interrupt after a device service routine
404 1.1 cgd * has freed the dma channel. So, ignore the intr if there's
405 1.1 cgd * nothing on the queue.
406 1.1 cgd */
407 1.1 cgd dq = dmachan[unit].dq_forw;
408 1.1 cgd if (dq != &dmachan[unit])
409 1.1 cgd (dq->dq_driver->d_done)(dq->dq_unit);
410 1.1 cgd }
411 1.1 cgd
412 1.1 cgd int
413 1.1 cgd dmaintr()
414 1.1 cgd {
415 1.1 cgd register struct dma_softc *dc;
416 1.1 cgd register int i, stat;
417 1.1 cgd int found = 0;
418 1.1 cgd
419 1.1 cgd #ifdef DEBUG
420 1.1 cgd if (dmadebug & DDB_FOLLOW)
421 1.1 cgd printf("dmaintr\n");
422 1.1 cgd #endif
423 1.1 cgd for (i = 0, dc = dma_softc; i < NDMA; i++, dc++) {
424 1.1 cgd stat = DMA_STAT(dc);
425 1.1 cgd if ((stat & DMA_INTR) == 0)
426 1.1 cgd continue;
427 1.1 cgd found++;
428 1.1 cgd #ifdef DEBUG
429 1.1 cgd if (dmadebug & DDB_IO) {
430 1.1 cgd if ((dmadebug&DDB_WORD) && (dc->sc_cmd&DMA_WORD) ||
431 1.1 cgd (dmadebug&DDB_LWORD) && (dc->sc_cmd&DMA_LWORD))
432 1.1 cgd printf("dmaintr: unit %d stat %x next %d\n",
433 1.1 cgd i, stat, (dc->sc_cur-dc->sc_chain)+1);
434 1.1 cgd }
435 1.1 cgd if (stat & DMA_ARMED)
436 1.1 cgd printf("dma%d: intr when armed\n", i);
437 1.1 cgd #endif
438 1.1 cgd if (++dc->sc_cur <= dc->sc_last) {
439 1.1 cgd #ifdef DEBUG
440 1.1 cgd dmatimo[i] = 1;
441 1.1 cgd #endif
442 1.1 cgd /*
443 1.1 cgd * Last chain segment, disable DMA interrupt.
444 1.1 cgd */
445 1.1 cgd if (dc->sc_cur == dc->sc_last &&
446 1.1 cgd (dc->sc_flags & DMAF_NOINTR))
447 1.1 cgd dc->sc_cmd &= ~DMA_ENAB;
448 1.1 cgd DMA_CLEAR(dc);
449 1.1 cgd DMA_ARM(dc);
450 1.1 cgd } else
451 1.1 cgd dmastop(i);
452 1.1 cgd }
453 1.1 cgd return(found);
454 1.1 cgd }
455 1.1 cgd
456 1.1 cgd #ifdef DEBUG
457 1.1 cgd void
458 1.3 mycroft dmatimeout(arg)
459 1.3 mycroft void *arg;
460 1.1 cgd {
461 1.1 cgd register int i, s;
462 1.1 cgd
463 1.1 cgd for (i = 0; i < NDMA; i++) {
464 1.1 cgd s = splbio();
465 1.1 cgd if (dmatimo[i]) {
466 1.1 cgd if (dmatimo[i] > 1)
467 1.1 cgd printf("dma%d: timeout #%d\n",
468 1.1 cgd i, dmatimo[i]-1);
469 1.1 cgd dmatimo[i]++;
470 1.1 cgd }
471 1.1 cgd splx(s);
472 1.1 cgd }
473 1.4 mycroft timeout(dmatimeout, (void *)0, 30 * hz);
474 1.1 cgd }
475 1.1 cgd #endif
476