xref: /netbsd-src/sys/dev/pci/btvmei.c (revision e4d7c2e329d54c97e0c0bd3016bbe74f550c3d5e)
1 /* $NetBSD: btvmei.c,v 1.1 1999/06/30 17:45:38 drochner Exp $ */
2 
3 /*
4  * Copyright (c) 1999
5  *	Matthias Drochner.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  *
29  */
30 
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/device.h>
34 #include <sys/proc.h>
35 #include <sys/malloc.h>
36 
37 #include <machine/bus.h>
38 #include <sys/extent.h>
39 
40 #include <dev/pci/pcireg.h>
41 #include <dev/pci/pcivar.h>
42 #include <dev/pci/pcidevs.h>
43 
44 #include <dev/vme/vmereg.h>
45 #include <dev/vme/vmevar.h>
46 
47 #include <dev/pci/btvmeireg.h>
48 #include <dev/pci/btvmeivar.h>
49 
50 static int b3_617_match __P((struct device *, struct cfdata *, void *));
51 static void b3_617_attach __P((struct device *, struct device *, void *));
52 #ifdef notyet
53 static int b3_617_detach __P((struct device *));
54 #endif
55 void b3_617_slaveconfig __P((struct device *, struct vme_attach_args *));
56 
57 static void b3_617_vmeintr __P((struct b3_617_softc *, unsigned char));
58 
59 /*
60  * mapping ressources, needed for deallocation
61  */
62 struct b3_617_vmeresc {
63 	bus_space_handle_t handle;
64 	bus_size_t len;
65 	int firstpage, maplen;
66 };
67 
68 struct cfattach btvmei_ca = {
69 	sizeof(struct b3_617_softc), b3_617_match, b3_617_attach,
70 #ifdef notyet
71 	b3_617_detach
72 #endif
73 };
74 
75 static int
76 b3_617_match(parent, match, aux)
77 	struct device *parent;
78 	struct cfdata *match;
79 	void *aux;
80 {
81 	struct pci_attach_args *pa = aux;
82 
83 	if ((PCI_VENDOR(pa->pa_id) != PCI_VENDOR_BIT3)
84 	    || (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_BIT3_PCIVME617))
85 		return (0);
86 	return (1);
87 }
88 
89 static void
90 b3_617_attach(parent, self, aux)
91 	struct device *parent, *self;
92 	void *aux;
93 {
94 	struct b3_617_softc *sc = (struct b3_617_softc*)self;
95 	struct pci_attach_args *pa = aux;
96 	pci_chipset_tag_t pc = pa->pa_pc;
97 
98 	int rev;
99 
100 	pci_intr_handle_t ih;
101 	const char *intrstr;
102 	struct vmebus_attach_args vaa;
103 
104 	sc->sc_pc = pc;
105 	sc->sc_dmat = pa->pa_dmat;
106 
107 	rev = PCI_REVISION(pci_conf_read(pc, pa->pa_tag, PCI_CLASS_REG));
108 	printf(": BIT3 PCI-VME 617 rev %d\n", rev);
109 
110 	/*
111 	 * Map CSR and mapping table spaces.
112 	 * Don't map VME window; parts are mapped as needed to
113 	 * save kernel virtual memory space
114 	 */
115 	if (pci_mapreg_map(pa, 0x14,
116 			   PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
117 			   0, &sc->csrt, &sc->csrh, NULL, NULL) &&
118 	    pci_mapreg_map(pa, 0x10,
119 			   PCI_MAPREG_TYPE_IO,
120 			   0, &sc->csrt, &sc->csrh, NULL, NULL)) {
121 		printf("%s: can't map CSR space\n", self->dv_xname);
122 		return;
123 	}
124 
125 	if (pci_mapreg_map(pa, 0x18,
126 			   PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
127 			   0, &sc->mapt, &sc->maph, NULL, NULL)) {
128 		printf("%s: can't map map space\n", self->dv_xname);
129 		return;
130 	}
131 
132 	if (pci_mapreg_info(pc, pa->pa_tag, 0x1c,
133 			    PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
134 			    &sc->vmepbase, 0, 0)) {
135 		printf("%s: can't get VME range\n", self->dv_xname);
136 		return;
137 	}
138 	sc->sc_vmet = pa->pa_memt; /* XXX needed for VME mappings */
139 
140 	/* Map and establish the interrupt. */
141 	if (pci_intr_map(pc, pa->pa_intrtag, pa->pa_intrpin,
142 			 pa->pa_intrline, &ih)) {
143 		printf("%s: couldn't map interrupt\n", sc->sc_dev.dv_xname);
144 		return;
145 	}
146 	intrstr = pci_intr_string(pc, ih);
147 	/*
148 	 * Use a low interrupt level (the lowest?).
149 	 * We will raise before calling a subdevice's handler.
150 	 */
151 	sc->sc_ih = pci_intr_establish(pc, ih, IPL_BIO, b3_617_intr, sc);
152 	if (sc->sc_ih == NULL) {
153 		printf("%s: couldn't establish interrupt",
154 		       sc->sc_dev.dv_xname);
155 		if (intrstr != NULL)
156 			printf(" at %s", intrstr);
157 		printf("\n");
158 		return;
159 	}
160 	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
161 
162 	if (b3_617_init(sc))
163 		return;
164 
165 	/*
166 	 * set up all the tags for use by VME devices
167 	 */
168 	sc->sc_vct.cookie = self;
169 	sc->sc_vct.vct_probe = b3_617_vme_probe;
170 	sc->sc_vct.vct_map = b3_617_map_vme;
171 	sc->sc_vct.vct_unmap = b3_617_unmap_vme;
172 	sc->sc_vct.vct_int_map = b3_617_map_vmeint;
173 	sc->sc_vct.vct_int_establish = b3_617_establish_vmeint;
174 	sc->sc_vct.vct_int_disestablish = b3_617_disestablish_vmeint;
175 	sc->sc_vct.vct_dmamap_create = b3_617_dmamap_create;
176 	sc->sc_vct.vct_dmamap_destroy = b3_617_dmamap_destroy;
177 	sc->sc_vct.vct_dmamem_alloc = b3_617_dmamem_alloc;
178 	sc->sc_vct.vct_dmamem_free = b3_617_dmamem_free;
179 
180 	vaa.va_vct = &(sc->sc_vct);
181 	vaa.va_bdt = pa->pa_dmat;
182 	vaa.va_slaveconfig = b3_617_slaveconfig;
183 
184 	sc->csrwindow.offset = -1;
185 	sc->dmawindow24.offset = -1;
186 	sc->dmawindow32.offset = -1;
187 	config_found(self, &vaa, 0);
188 }
189 
190 #ifdef notyet
191 static int
192 b3_617_detach(dev)
193 	struct device *dev;
194 {
195 	struct b3_617_softc *sc = (struct b3_617_softc *)dev;
196 
197 	b3_617_halt(sc);
198 
199 	if (sc->sc_ih)
200 		pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
201 
202 	bus_space_unmap(sc->sc_bc, sc->csrbase, 32);
203 	bus_space_unmap(sc->sc_bc, sc->mapbase, 64*1024);
204 
205 	return(0);
206 }
207 #endif
208 
209 void
210 b3_617_slaveconfig(dev, va)
211 	struct device *dev;
212 	struct vme_attach_args *va;
213 {
214 	struct b3_617_softc *sc = (struct b3_617_softc *)dev;
215 	vme_chipset_tag_t vmect;
216 	int i, res;
217 	char *name = 0; /* XXX gcc! */
218 
219 	vmect = &sc->sc_vct;
220 	if (!va)
221 		goto freeit;
222 
223 #ifdef DIAGNOSTIC
224 	if (vmect != va->va_vct)
225 		panic("pcivme_slaveconfig: chipset tag?\n");
226 #endif
227 
228 	for (i = 0; i < va->numcfranges; i++) {
229 		res = vme_space_alloc(vmect, va->r[i].offset,
230 				      va->r[i].size, va->r[i].am);
231 		if (res)
232 			panic("%s: can't alloc slave window %x/%x/%x",
233 			       dev->dv_xname, va->r[i].offset,
234 			       va->r[i].size, va->r[i].am);
235 
236 		switch (va->r[i].am & VME_AM_ADRSIZEMASK) {
237 			/* structure assignments! */
238 		    case VME_AM_A16:
239 			sc->csrwindow = va->r[i];
240 			name = "VME CSR";
241 			break;
242 		    case VME_AM_A24:
243 			sc->dmawindow24 = va->r[i];
244 			name = "A24 DMA";
245 			break;
246 		    case VME_AM_A32:
247 			sc->dmawindow32 = va->r[i];
248 			name = "A32 DMA";
249 			break;
250 		}
251 		printf("%s: %s window: %x-%x\n", dev->dv_xname,
252 		       name, va->r[i].offset,
253 		       va->r[i].offset + va->r[i].size - 1);
254 	}
255 	return;
256 
257 freeit:
258 	if (sc->csrwindow.offset != -1)
259 		vme_space_free(vmect, sc->csrwindow.offset,
260 			       sc->csrwindow.size, sc->csrwindow.am);
261 	if (sc->dmawindow32.offset != -1)
262 		vme_space_free(vmect, sc->dmawindow32.offset,
263 			       sc->dmawindow32.size, sc->dmawindow32.am);
264 	if (sc->dmawindow24.offset != -1)
265 		vme_space_free(vmect, sc->dmawindow24.offset,
266 			       sc->dmawindow24.size, sc->dmawindow24.am);
267 }
268 
269 int
270 b3_617_reset(sc)
271 	struct b3_617_softc *sc;
272 {
273 	unsigned char status;
274 
275 	/* reset sequence, ch 5.2 */
276 	status = read_csr_byte(sc, LOC_STATUS);
277 	if (status & LSR_NO_CONNECT) {
278 		printf("%s: not connected\n", sc->sc_dev.dv_xname);
279 		return (-1);
280 	}
281 	status = read_csr_byte(sc, REM_STATUS); /* discard */
282 	write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
283 	status = read_csr_byte(sc, LOC_STATUS);
284 	if (status & LSR_CERROR_MASK) {
285 		printf("%s: interface error, lsr=%b\n", sc->sc_dev.dv_xname,
286 		       status, BIT3_LSR_BITS);
287 		return (-1);
288 	}
289 	return (0);
290 }
291 
292 int
293 b3_617_init(sc)
294 	struct b3_617_softc *sc;
295 {
296 	unsigned int i;
297 
298 	if (b3_617_reset(sc))
299 		return (-1);
300 
301 	/* all maps invalid */
302 	for (i = MR_PCI_VME; i < MR_PCI_VME + MR_PCI_VME_SIZE; i += 4)
303 		write_mapmem(sc, i, MR_RAM_INVALID);
304 	for (i = MR_VME_PCI; i < MR_VME_PCI + MR_VME_PCI_SIZE; i += 4)
305 		write_mapmem(sc, i, MR_RAM_INVALID);
306 	for (i = MR_DMA_PCI; i < MR_DMA_PCI + MR_DMA_PCI_SIZE; i += 4)
307 		write_mapmem(sc, i, MR_RAM_INVALID);
308 
309 	/*
310 	 * set up scatter page allocation control
311 	 */
312 	sc->vmeext = extent_create("pcivme", MR_PCI_VME,
313 				   MR_PCI_VME + MR_PCI_VME_SIZE - 1, M_DEVBUF,
314 				   sc->vmemap, sizeof(sc->vmemap),
315 				   EX_NOCOALESCE);
316 #if 0
317 	sc->pciext = extent_create("vmepci", MR_VME_PCI,
318 				   MR_VME_PCI + MR_VME_PCI_SIZE - 1, M_DEVBUF,
319 				   sc->pcimap, sizeof(sc->pcimap),
320 				   EX_NOCOALESCE);
321 	sc->dmaext = extent_create("dmapci", MR_DMA_PCI,
322 				   MR_DMA_PCI + MR_DMA_PCI_SIZE - 1, M_DEVBUF,
323 				   sc->dmamap, sizeof(sc->dmamap),
324 				   EX_NOCOALESCE);
325 #endif
326 
327 	/*
328 	 * init int handler queue,
329 	 * enable interrupts if PCI interrupt available
330 	 */
331 	TAILQ_INIT(&(sc->intrhdls));
332 	sc->strayintrs = 0;
333 
334 	if (sc->sc_ih)
335 		write_csr_byte(sc, LOC_INT_CTRL, LIC_INT_ENABLE);
336 	/* no error ints */
337 	write_csr_byte(sc, REM_CMD2, 0); /* enables VME IRQ */
338 
339 	return (0);
340 }
341 
342 #ifdef notyet /* for detach */
343 void
344 b3_617_halt(sc)
345 	struct b3_617_softc *sc;
346 {
347 	/*
348 	 * because detach code checks for existence of children,
349 	 * all ressources (mappings, VME IRQs, DMA requests)
350 	 * should be deallocated at this point
351 	 */
352 
353 	/* disable IRQ */
354 	write_csr_byte(sc, LOC_INT_CTRL, 0);
355 }
356 #endif
357 
358 static void
359 b3_617_vmeintr(sc, lstat)
360 	struct b3_617_softc *sc;
361 	unsigned char lstat;
362 {
363 	int level;
364 
365 	for (level = 7; level >= 1; level--) {
366 		unsigned char vector;
367 		struct b3_617_vmeintrhand *ih;
368 		int found;
369 
370 		if (!(lstat & (1 << level)))
371 			continue;
372 
373 		write_csr_byte(sc, REM_CMD1, level);
374 		vector = read_csr_byte(sc, REM_IACK);
375 
376 		found = 0;
377 
378 		for (ih = sc->intrhdls.tqh_first; ih;
379 		     ih = ih->ih_next.tqe_next) {
380 			if ((ih->ih_level == level) &&
381 			    ((ih->ih_vector == -1) ||
382 			     (ih->ih_vector == vector))) {
383 				int s, res;
384 				/*
385 				 * We should raise the interrupt level
386 				 * to ih->ih_prior here. How to do this
387 				 * machine-independantly?
388 				 * To be safe, raise to the maximum.
389 				 */
390 				s = splhigh();
391 				found |= (res = (*(ih->ih_fun))(ih->ih_arg));
392 				splx(s);
393 				if (res)
394 					ih->ih_count++;
395 				if (res == 1)
396 					break;
397 			}
398 		}
399 		if (!found)
400 			sc->strayintrs++;
401 	}
402 }
403 
404 #define sc ((struct b3_617_softc*)vsc)
405 
406 int
407 b3_617_map_vme(vsc, vmeaddr, len, am, datasizes, swap, tag, handle, resc)
408 	void *vsc;
409 	vme_addr_t vmeaddr;
410 	vme_size_t len;
411 	vme_am_t am;
412 	vme_datasize_t datasizes;
413 	vme_swap_t swap;
414 	bus_space_tag_t *tag;
415 	bus_space_handle_t *handle;
416 	vme_mapresc_t *resc;
417 {
418 	vme_addr_t vmebase, vmeend, va;
419 	unsigned long maplen, first, i;
420 	u_int32_t mapreg;
421 	bus_addr_t pcibase;
422 	int res;
423 	struct b3_617_vmeresc *r;
424 
425 	/* first mapped address */
426 	vmebase = vmeaddr & ~(VME_PAGESIZE - 1);
427 	/* base of last mapped page */
428 	vmeend = (vmeaddr + len - 1) & ~(VME_PAGESIZE - 1);
429 	/* bytes in scatter table required */
430 	maplen = ((vmeend - vmebase) / VME_PAGESIZE + 1) * 4;
431 
432 	if (extent_alloc(sc->vmeext, maplen, 4, 0, EX_FAST, &first))
433 		return (ENOMEM);
434 
435 	/*
436 	 * set up adapter mapping registers
437 	 */
438 	mapreg = (am << MR_AMOD_SHIFT) | MR_FC_RRAM | swap;
439 
440 	for (i = first, va = vmebase;
441 	     i < first + maplen;
442 	     i += 4, va += VME_PAGESIZE) {
443 		write_mapmem(sc, i, mapreg | va);
444 #ifdef BIT3DEBUG
445 		printf("mapreg@%lx=%x\n", i, read_mapmem(sc, i));
446 #endif
447 	}
448 
449 #ifdef DIAGNOSTIC
450 	if (va != vmeend + VME_PAGESIZE)
451 		panic("b3_617_map_pci_vme: botch");
452 #endif
453 	/*
454 	 * map needed range in PCI space
455 	 */
456 	pcibase = sc->vmepbase + (first - MR_PCI_VME) / 4 * VME_PAGESIZE
457 	    + (vmeaddr & (VME_PAGESIZE - 1));
458 
459 	if ((res = bus_space_map(sc->sc_vmet, pcibase, len, 0, handle))) {
460 		for (i = first; i < first + maplen; i += 4)
461 			write_mapmem(sc, i, MR_RAM_INVALID);
462 		extent_free(sc->vmeext, first, maplen, 0);
463 		return (res);
464 	}
465 
466 	*tag = sc->sc_vmet;
467 
468 	/*
469 	 * save all data needed for later unmapping
470 	 */
471 	r = malloc(sizeof(*r), M_DEVBUF, M_NOWAIT); /* XXX check! */
472 	r->handle = *handle;
473 	r->len = len;
474 	r->firstpage = first;
475 	r->maplen = maplen;
476 	*resc = r;
477 	return (0);
478 }
479 
480 void
481 b3_617_unmap_vme(vsc, resc)
482 	void *vsc;
483 	vme_mapresc_t resc;
484 {
485 	unsigned long i;
486 	struct b3_617_vmeresc *r = resc;
487 
488 	/* unmap PCI window */
489 	bus_space_unmap(sc->sc_vmet, r->handle, r->len);
490 
491 	for (i = r->firstpage; i < r->firstpage + r->maplen; i += 4)
492 		write_mapmem(sc, i, MR_RAM_INVALID);
493 
494 	extent_free(sc->vmeext, r->firstpage, r->maplen, 0);
495 
496 	free(r, M_DEVBUF);
497 }
498 
499 int
500 b3_617_vme_probe(vsc, addr, len, am, datasize, callback, cbarg)
501 	void *vsc;
502 	vme_addr_t addr;
503 	vme_size_t len;
504 	vme_am_t am;
505 	vme_datasize_t datasize;
506 	int (*callback) __P((void *, bus_space_tag_t, bus_space_handle_t));
507 	void *cbarg;
508 {
509 	bus_space_tag_t tag;
510 	bus_space_handle_t handle;
511 	vme_mapresc_t resc;
512 	int res, i;
513 	volatile u_int32_t dummy;
514 	int status;
515 
516 	res = b3_617_map_vme(vsc, addr, len, am, 0, 0,
517 			     &tag, &handle, &resc);
518 	if (res)
519 		return (res);
520 
521 	if (read_csr_byte(sc, LOC_STATUS) & LSR_ERROR_MASK) {
522 		printf("b3_617_vme_badaddr: error bit not clean - resetting\n");
523 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
524 	}
525 
526 	if (callback)
527 		res = (*callback)(cbarg, tag, handle);
528 	else {
529 		for (i = 0; i < len;) {
530 			switch (datasize) {
531 			    case VME_D8:
532 				dummy = bus_space_read_1(tag, handle, i);
533 				i++;
534 				break;
535 			    case VME_D16:
536 				dummy = bus_space_read_2(tag, handle, i);
537 				i += 2;
538 				break;
539 			    case VME_D32:
540 				dummy = bus_space_read_4(tag, handle, i);
541 				i += 4;
542 				break;
543 			    default:
544 				panic("b3_617_vme_probe: invalid datasize %x",
545 				      datasize);
546 			}
547 		}
548 	}
549 
550 	if ((status = read_csr_byte(sc, LOC_STATUS)) & LSR_ERROR_MASK) {
551 #ifdef BIT3DEBUG
552 		printf("b3_617_vme_badaddr: caught error %x\n", status);
553 #endif
554 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
555 		res = EIO;
556 	}
557 
558 	b3_617_unmap_vme(vsc, resc);
559 	return (res);
560 }
561 
562 int
563 b3_617_map_vmeint(vsc, level, vector, handlep)
564 	void *vsc;
565 	int level, vector;
566 	vme_intr_handle_t *handlep;
567 {
568 	if (!sc->sc_ih) {
569 		printf("%s: b3_617_map_vmeint: no IRQ\n",
570 		       sc->sc_dev.dv_xname);
571 		return (ENXIO);
572 	}
573 	/*
574 	 * We should check whether the interface can pass this interrupt
575 	 * level at all, but we don't know much about the jumper setting.
576 	 */
577 	*handlep = (void *)(long)((level << 8) | vector); /* XXX */
578 	return (0);
579 }
580 
581 void *
582 b3_617_establish_vmeint(vsc, handle, prior, func, arg)
583 	void *vsc;
584 	vme_intr_handle_t handle;
585 	int prior;
586 	int (*func) __P((void *));
587 	void *arg;
588 {
589 	struct b3_617_vmeintrhand *ih;
590 	long lv;
591 	int s;
592 	extern int cold;
593 
594 	/* no point in sleeping unless someone can free memory. */
595 	ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
596 	if (ih == NULL)
597 		panic("b3_617_map_vmeint: can't malloc handler info");
598 
599 	lv = (long)handle; /* XXX */
600 
601 	ih->ih_fun = func;
602 	ih->ih_arg = arg;
603 	ih->ih_level = lv >> 8;
604 	ih->ih_vector = lv & 0xff;
605 	ih->ih_prior = prior;
606 	ih->ih_count = 0;
607 
608 	s = splhigh();
609 	TAILQ_INSERT_TAIL(&(sc->intrhdls), ih, ih_next);
610 	splx(s);
611 
612 	return (ih);
613 }
614 
615 void
616 b3_617_disestablish_vmeint(vsc, cookie)
617 	void *vsc;
618 	void *cookie;
619 {
620 	struct b3_617_vmeintrhand *ih = cookie;
621 	int s;
622 
623 	if (!ih) {
624 		printf("b3_617_unmap_vmeint: NULL arg\n");
625 		return;
626 	}
627 
628 	s = splhigh();
629 	TAILQ_REMOVE(&(sc->intrhdls), ih, ih_next);
630 	splx(s);
631 
632 	free(ih, M_DEVBUF);
633 }
634 
635 int
636 b3_617_intr(vsc)
637 	void *vsc;
638 {
639 	int handled = 0;
640 
641 	/* follows ch. 5.5.5 (reordered for speed) */
642 	while (read_csr_byte(sc, LOC_INT_CTRL) & LIC_INT_PENDING) {
643 		unsigned char lstat;
644 
645 		handled = 1;
646 
647 		/* no error interrupts! */
648 
649 		lstat = read_csr_byte(sc, LDMA_CMD);
650 		if ((lstat & LDC_DMA_DONE) && (lstat & LDC_DMA_INT_ENABLE)) {
651 			/* DMA done indicator flag */
652 			write_csr_byte(sc, LDMA_CMD, lstat & (~LDC_DMA_DONE));
653 #if 0
654 			b3_617_cntlrdma_done(sc);
655 #endif
656 			continue;
657 		}
658 
659 		lstat = read_csr_byte(sc, LOC_INT_STATUS);
660 		if (lstat & LIS_CINT_MASK) {
661 			/* VME backplane interrupt, ch. 5.5.3 */
662 			b3_617_vmeintr(sc, lstat);
663 		}
664 
665 		/* for now, ignore "mailbox interrupts" */
666 
667 		lstat = read_csr_byte(sc, LOC_STATUS);
668 		if (lstat & LSR_PR_STATUS) {
669 			/* PR interrupt recieved from REMOTE  */
670 			write_csr_byte(sc, LOC_CMD1, LC1_CLR_PR_INT);
671 			continue;
672 		}
673 
674 		lstat = read_csr_byte(sc, REM_STATUS);
675 		if (lstat & RSR_PT_STATUS) {
676 			/* PT interrupt is set */
677 			write_csr_byte(sc, REM_CMD1, RC1_CLR_PT_INT);
678 			continue;
679 		}
680 	}
681 	return (handled);
682 }
683 
684 int
685 b3_617_dmamap_create(vsc, len, am, datasize, swap,
686 		   nsegs, segsz, bound,
687 		   flags, mapp)
688 	void *vsc;
689 	vme_size_t len;
690 	vme_am_t am;
691 	vme_datasize_t datasize;
692 	vme_swap_t swap;
693 	int nsegs;
694 	vme_size_t segsz;
695 	vme_addr_t bound;
696 	int flags;
697 	bus_dmamap_t *mapp;
698 {
699 	return (EINVAL);
700 }
701 
702 void
703 b3_617_dmamap_destroy(vsc, map)
704 	void *vsc;
705 	bus_dmamap_t map;
706 {
707 }
708 
709 int
710 b3_617_dmamem_alloc(vsc, len, am, datasizes, swap,
711 		    segs, nsegs, rsegs, flags)
712 	void *vsc;
713 	vme_size_t len;
714 	vme_am_t am;
715 	vme_datasize_t datasizes;
716 	vme_swap_t swap;
717 	bus_dma_segment_t *segs;
718 	int nsegs;
719 	int *rsegs;
720 	int flags;
721 {
722 	return (EINVAL);
723 }
724 
725 void
726 b3_617_dmamem_free(vsc, segs, nsegs)
727 	void *vsc;
728 	bus_dma_segment_t *segs;
729 	int nsegs;
730 {
731 }
732 
733 #undef sc
734