Home | History | Annotate | Line # | Download | only in pci
btvmei.c revision 1.3
      1 /* $NetBSD: btvmei.c,v 1.3 2000/08/08 20:06:48 tv 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 		char sbuf[sizeof(BIT3_LSR_BITS) + 64];
    286 
    287 		bitmask_snprintf(status, BIT3_LSR_BITS, sbuf, sizeof(sbuf));
    288 		printf("%s: interface error, lsr=%s\n", sc->sc_dev.dv_xname,
    289 		       sbuf);
    290 		return (-1);
    291 	}
    292 	return (0);
    293 }
    294 
    295 int
    296 b3_617_init(sc)
    297 	struct b3_617_softc *sc;
    298 {
    299 	unsigned int i;
    300 
    301 	if (b3_617_reset(sc))
    302 		return (-1);
    303 
    304 	/* all maps invalid */
    305 	for (i = MR_PCI_VME; i < MR_PCI_VME + MR_PCI_VME_SIZE; i += 4)
    306 		write_mapmem(sc, i, MR_RAM_INVALID);
    307 	for (i = MR_VME_PCI; i < MR_VME_PCI + MR_VME_PCI_SIZE; i += 4)
    308 		write_mapmem(sc, i, MR_RAM_INVALID);
    309 	for (i = MR_DMA_PCI; i < MR_DMA_PCI + MR_DMA_PCI_SIZE; i += 4)
    310 		write_mapmem(sc, i, MR_RAM_INVALID);
    311 
    312 	/*
    313 	 * set up scatter page allocation control
    314 	 */
    315 	sc->vmeext = extent_create("pcivme", MR_PCI_VME,
    316 				   MR_PCI_VME + MR_PCI_VME_SIZE - 1, M_DEVBUF,
    317 				   sc->vmemap, sizeof(sc->vmemap),
    318 				   EX_NOCOALESCE);
    319 #if 0
    320 	sc->pciext = extent_create("vmepci", MR_VME_PCI,
    321 				   MR_VME_PCI + MR_VME_PCI_SIZE - 1, M_DEVBUF,
    322 				   sc->pcimap, sizeof(sc->pcimap),
    323 				   EX_NOCOALESCE);
    324 	sc->dmaext = extent_create("dmapci", MR_DMA_PCI,
    325 				   MR_DMA_PCI + MR_DMA_PCI_SIZE - 1, M_DEVBUF,
    326 				   sc->dmamap, sizeof(sc->dmamap),
    327 				   EX_NOCOALESCE);
    328 #endif
    329 
    330 	/*
    331 	 * init int handler queue,
    332 	 * enable interrupts if PCI interrupt available
    333 	 */
    334 	TAILQ_INIT(&(sc->intrhdls));
    335 	sc->strayintrs = 0;
    336 
    337 	if (sc->sc_ih)
    338 		write_csr_byte(sc, LOC_INT_CTRL, LIC_INT_ENABLE);
    339 	/* no error ints */
    340 	write_csr_byte(sc, REM_CMD2, 0); /* enables VME IRQ */
    341 
    342 	return (0);
    343 }
    344 
    345 #ifdef notyet /* for detach */
    346 void
    347 b3_617_halt(sc)
    348 	struct b3_617_softc *sc;
    349 {
    350 	/*
    351 	 * because detach code checks for existence of children,
    352 	 * all ressources (mappings, VME IRQs, DMA requests)
    353 	 * should be deallocated at this point
    354 	 */
    355 
    356 	/* disable IRQ */
    357 	write_csr_byte(sc, LOC_INT_CTRL, 0);
    358 }
    359 #endif
    360 
    361 static void
    362 b3_617_vmeintr(sc, lstat)
    363 	struct b3_617_softc *sc;
    364 	unsigned char lstat;
    365 {
    366 	int level;
    367 
    368 	for (level = 7; level >= 1; level--) {
    369 		unsigned char vector;
    370 		struct b3_617_vmeintrhand *ih;
    371 		int found;
    372 
    373 		if (!(lstat & (1 << level)))
    374 			continue;
    375 
    376 		write_csr_byte(sc, REM_CMD1, level);
    377 		vector = read_csr_byte(sc, REM_IACK);
    378 
    379 		found = 0;
    380 
    381 		for (ih = sc->intrhdls.tqh_first; ih;
    382 		     ih = ih->ih_next.tqe_next) {
    383 			if ((ih->ih_level == level) &&
    384 			    ((ih->ih_vector == -1) ||
    385 			     (ih->ih_vector == vector))) {
    386 				int s, res;
    387 				/*
    388 				 * We should raise the interrupt level
    389 				 * to ih->ih_prior here. How to do this
    390 				 * machine-independantly?
    391 				 * To be safe, raise to the maximum.
    392 				 */
    393 				s = splhigh();
    394 				found |= (res = (*(ih->ih_fun))(ih->ih_arg));
    395 				splx(s);
    396 				if (res)
    397 					ih->ih_count++;
    398 				if (res == 1)
    399 					break;
    400 			}
    401 		}
    402 		if (!found)
    403 			sc->strayintrs++;
    404 	}
    405 }
    406 
    407 #define sc ((struct b3_617_softc*)vsc)
    408 
    409 int
    410 b3_617_map_vme(vsc, vmeaddr, len, am, datasizes, swap, tag, handle, resc)
    411 	void *vsc;
    412 	vme_addr_t vmeaddr;
    413 	vme_size_t len;
    414 	vme_am_t am;
    415 	vme_datasize_t datasizes;
    416 	vme_swap_t swap;
    417 	bus_space_tag_t *tag;
    418 	bus_space_handle_t *handle;
    419 	vme_mapresc_t *resc;
    420 {
    421 	vme_addr_t vmebase, vmeend, va;
    422 	unsigned long maplen, first, i;
    423 	u_int32_t mapreg;
    424 	bus_addr_t pcibase;
    425 	int res;
    426 	struct b3_617_vmeresc *r;
    427 
    428 	/* first mapped address */
    429 	vmebase = vmeaddr & ~(VME_PAGESIZE - 1);
    430 	/* base of last mapped page */
    431 	vmeend = (vmeaddr + len - 1) & ~(VME_PAGESIZE - 1);
    432 	/* bytes in scatter table required */
    433 	maplen = ((vmeend - vmebase) / VME_PAGESIZE + 1) * 4;
    434 
    435 	if (extent_alloc(sc->vmeext, maplen, 4, 0, EX_FAST, &first))
    436 		return (ENOMEM);
    437 
    438 	/*
    439 	 * set up adapter mapping registers
    440 	 */
    441 	mapreg = (am << MR_AMOD_SHIFT) | MR_FC_RRAM | swap;
    442 
    443 	for (i = first, va = vmebase;
    444 	     i < first + maplen;
    445 	     i += 4, va += VME_PAGESIZE) {
    446 		write_mapmem(sc, i, mapreg | va);
    447 #ifdef BIT3DEBUG
    448 		printf("mapreg@%lx=%x\n", i, read_mapmem(sc, i));
    449 #endif
    450 	}
    451 
    452 #ifdef DIAGNOSTIC
    453 	if (va != vmeend + VME_PAGESIZE)
    454 		panic("b3_617_map_pci_vme: botch");
    455 #endif
    456 	/*
    457 	 * map needed range in PCI space
    458 	 */
    459 	pcibase = sc->vmepbase + (first - MR_PCI_VME) / 4 * VME_PAGESIZE
    460 	    + (vmeaddr & (VME_PAGESIZE - 1));
    461 
    462 	if ((res = bus_space_map(sc->sc_vmet, pcibase, len, 0, handle))) {
    463 		for (i = first; i < first + maplen; i += 4)
    464 			write_mapmem(sc, i, MR_RAM_INVALID);
    465 		extent_free(sc->vmeext, first, maplen, 0);
    466 		return (res);
    467 	}
    468 
    469 	*tag = sc->sc_vmet;
    470 
    471 	/*
    472 	 * save all data needed for later unmapping
    473 	 */
    474 	r = malloc(sizeof(*r), M_DEVBUF, M_NOWAIT); /* XXX check! */
    475 	r->handle = *handle;
    476 	r->len = len;
    477 	r->firstpage = first;
    478 	r->maplen = maplen;
    479 	*resc = r;
    480 	return (0);
    481 }
    482 
    483 void
    484 b3_617_unmap_vme(vsc, resc)
    485 	void *vsc;
    486 	vme_mapresc_t resc;
    487 {
    488 	unsigned long i;
    489 	struct b3_617_vmeresc *r = resc;
    490 
    491 	/* unmap PCI window */
    492 	bus_space_unmap(sc->sc_vmet, r->handle, r->len);
    493 
    494 	for (i = r->firstpage; i < r->firstpage + r->maplen; i += 4)
    495 		write_mapmem(sc, i, MR_RAM_INVALID);
    496 
    497 	extent_free(sc->vmeext, r->firstpage, r->maplen, 0);
    498 
    499 	free(r, M_DEVBUF);
    500 }
    501 
    502 int
    503 b3_617_vme_probe(vsc, addr, len, am, datasize, callback, cbarg)
    504 	void *vsc;
    505 	vme_addr_t addr;
    506 	vme_size_t len;
    507 	vme_am_t am;
    508 	vme_datasize_t datasize;
    509 	int (*callback) __P((void *, bus_space_tag_t, bus_space_handle_t));
    510 	void *cbarg;
    511 {
    512 	bus_space_tag_t tag;
    513 	bus_space_handle_t handle;
    514 	vme_mapresc_t resc;
    515 	int res, i;
    516 	volatile u_int32_t dummy;
    517 	int status;
    518 
    519 	res = b3_617_map_vme(vsc, addr, len, am, 0, 0,
    520 			     &tag, &handle, &resc);
    521 	if (res)
    522 		return (res);
    523 
    524 	if (read_csr_byte(sc, LOC_STATUS) & LSR_ERROR_MASK) {
    525 		printf("b3_617_vme_badaddr: error bit not clean - resetting\n");
    526 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
    527 	}
    528 
    529 	if (callback)
    530 		res = (*callback)(cbarg, tag, handle);
    531 	else {
    532 		for (i = 0; i < len;) {
    533 			switch (datasize) {
    534 			    case VME_D8:
    535 				dummy = bus_space_read_1(tag, handle, i);
    536 				i++;
    537 				break;
    538 			    case VME_D16:
    539 				dummy = bus_space_read_2(tag, handle, i);
    540 				i += 2;
    541 				break;
    542 			    case VME_D32:
    543 				dummy = bus_space_read_4(tag, handle, i);
    544 				i += 4;
    545 				break;
    546 			    default:
    547 				panic("b3_617_vme_probe: invalid datasize %x",
    548 				      datasize);
    549 			}
    550 		}
    551 	}
    552 
    553 	if ((status = read_csr_byte(sc, LOC_STATUS)) & LSR_ERROR_MASK) {
    554 #ifdef BIT3DEBUG
    555 		printf("b3_617_vme_badaddr: caught error %x\n", status);
    556 #endif
    557 		write_csr_byte(sc, LOC_CMD1, LC1_CLR_ERROR);
    558 		res = EIO;
    559 	}
    560 
    561 	b3_617_unmap_vme(vsc, resc);
    562 	return (res);
    563 }
    564 
    565 int
    566 b3_617_map_vmeint(vsc, level, vector, handlep)
    567 	void *vsc;
    568 	int level, vector;
    569 	vme_intr_handle_t *handlep;
    570 {
    571 	if (!sc->sc_ih) {
    572 		printf("%s: b3_617_map_vmeint: no IRQ\n",
    573 		       sc->sc_dev.dv_xname);
    574 		return (ENXIO);
    575 	}
    576 	/*
    577 	 * We should check whether the interface can pass this interrupt
    578 	 * level at all, but we don't know much about the jumper setting.
    579 	 */
    580 	*handlep = (void *)(long)((level << 8) | vector); /* XXX */
    581 	return (0);
    582 }
    583 
    584 void *
    585 b3_617_establish_vmeint(vsc, handle, prior, func, arg)
    586 	void *vsc;
    587 	vme_intr_handle_t handle;
    588 	int prior;
    589 	int (*func) __P((void *));
    590 	void *arg;
    591 {
    592 	struct b3_617_vmeintrhand *ih;
    593 	long lv;
    594 	int s;
    595 	extern int cold;
    596 
    597 	/* no point in sleeping unless someone can free memory. */
    598 	ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
    599 	if (ih == NULL)
    600 		panic("b3_617_map_vmeint: can't malloc handler info");
    601 
    602 	lv = (long)handle; /* XXX */
    603 
    604 	ih->ih_fun = func;
    605 	ih->ih_arg = arg;
    606 	ih->ih_level = lv >> 8;
    607 	ih->ih_vector = lv & 0xff;
    608 	ih->ih_prior = prior;
    609 	ih->ih_count = 0;
    610 
    611 	s = splhigh();
    612 	TAILQ_INSERT_TAIL(&(sc->intrhdls), ih, ih_next);
    613 	splx(s);
    614 
    615 	return (ih);
    616 }
    617 
    618 void
    619 b3_617_disestablish_vmeint(vsc, cookie)
    620 	void *vsc;
    621 	void *cookie;
    622 {
    623 	struct b3_617_vmeintrhand *ih = cookie;
    624 	int s;
    625 
    626 	if (!ih) {
    627 		printf("b3_617_unmap_vmeint: NULL arg\n");
    628 		return;
    629 	}
    630 
    631 	s = splhigh();
    632 	TAILQ_REMOVE(&(sc->intrhdls), ih, ih_next);
    633 	splx(s);
    634 
    635 	free(ih, M_DEVBUF);
    636 }
    637 
    638 int
    639 b3_617_intr(vsc)
    640 	void *vsc;
    641 {
    642 	int handled = 0;
    643 
    644 	/* follows ch. 5.5.5 (reordered for speed) */
    645 	while (read_csr_byte(sc, LOC_INT_CTRL) & LIC_INT_PENDING) {
    646 		unsigned char lstat;
    647 
    648 		handled = 1;
    649 
    650 		/* no error interrupts! */
    651 
    652 		lstat = read_csr_byte(sc, LDMA_CMD);
    653 		if ((lstat & LDC_DMA_DONE) && (lstat & LDC_DMA_INT_ENABLE)) {
    654 			/* DMA done indicator flag */
    655 			write_csr_byte(sc, LDMA_CMD, lstat & (~LDC_DMA_DONE));
    656 #if 0
    657 			b3_617_cntlrdma_done(sc);
    658 #endif
    659 			continue;
    660 		}
    661 
    662 		lstat = read_csr_byte(sc, LOC_INT_STATUS);
    663 		if (lstat & LIS_CINT_MASK) {
    664 			/* VME backplane interrupt, ch. 5.5.3 */
    665 			b3_617_vmeintr(sc, lstat);
    666 		}
    667 
    668 		/* for now, ignore "mailbox interrupts" */
    669 
    670 		lstat = read_csr_byte(sc, LOC_STATUS);
    671 		if (lstat & LSR_PR_STATUS) {
    672 			/* PR interrupt recieved from REMOTE  */
    673 			write_csr_byte(sc, LOC_CMD1, LC1_CLR_PR_INT);
    674 			continue;
    675 		}
    676 
    677 		lstat = read_csr_byte(sc, REM_STATUS);
    678 		if (lstat & RSR_PT_STATUS) {
    679 			/* PT interrupt is set */
    680 			write_csr_byte(sc, REM_CMD1, RC1_CLR_PT_INT);
    681 			continue;
    682 		}
    683 	}
    684 	return (handled);
    685 }
    686 
    687 int
    688 b3_617_dmamap_create(vsc, len, am, datasize, swap,
    689 		   nsegs, segsz, bound,
    690 		   flags, mapp)
    691 	void *vsc;
    692 	vme_size_t len;
    693 	vme_am_t am;
    694 	vme_datasize_t datasize;
    695 	vme_swap_t swap;
    696 	int nsegs;
    697 	vme_size_t segsz;
    698 	vme_addr_t bound;
    699 	int flags;
    700 	bus_dmamap_t *mapp;
    701 {
    702 	return (EINVAL);
    703 }
    704 
    705 void
    706 b3_617_dmamap_destroy(vsc, map)
    707 	void *vsc;
    708 	bus_dmamap_t map;
    709 {
    710 }
    711 
    712 int
    713 b3_617_dmamem_alloc(vsc, len, am, datasizes, swap,
    714 		    segs, nsegs, rsegs, flags)
    715 	void *vsc;
    716 	vme_size_t len;
    717 	vme_am_t am;
    718 	vme_datasize_t datasizes;
    719 	vme_swap_t swap;
    720 	bus_dma_segment_t *segs;
    721 	int nsegs;
    722 	int *rsegs;
    723 	int flags;
    724 {
    725 	return (EINVAL);
    726 }
    727 
    728 void
    729 b3_617_dmamem_free(vsc, segs, nsegs)
    730 	void *vsc;
    731 	bus_dma_segment_t *segs;
    732 	int nsegs;
    733 {
    734 }
    735 
    736 #undef sc
    737