Home | History | Annotate | Line # | Download | only in dev
ebus.c revision 1.25
      1 /*	$NetBSD: ebus.c,v 1.25 2001/09/10 16:17:06 eeh Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1999, 2000 Matthew R. Green
      5  * 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,
     23  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  */
     30 
     31 #include "opt_ddb.h"
     32 
     33 /*
     34  * UltraSPARC 5 and beyond ebus support.
     35  *
     36  * note that this driver is not complete:
     37  *	- ebus2 dma code is completely unwritten
     38  *	- interrupt establish is written and appears to work
     39  *	- bus map code is written and appears to work
     40  */
     41 
     42 #undef DEBUG
     43 #define DEBUG
     44 
     45 #ifdef DEBUG
     46 #define	EDB_PROM	0x01
     47 #define EDB_CHILD	0x02
     48 #define	EDB_INTRMAP	0x04
     49 #define EDB_BUSMAP	0x08
     50 #define EDB_BUSDMA	0x10
     51 #define EDB_INTR	0x20
     52 int ebus_debug = 0x0;
     53 #define DPRINTF(l, s)   do { if (ebus_debug & l) printf s; } while (0)
     54 #else
     55 #define DPRINTF(l, s)
     56 #endif
     57 
     58 #include <sys/param.h>
     59 #include <sys/conf.h>
     60 #include <sys/device.h>
     61 #include <sys/errno.h>
     62 #include <sys/extent.h>
     63 #include <sys/malloc.h>
     64 #include <sys/systm.h>
     65 #include <sys/time.h>
     66 
     67 #define _SPARC_BUS_DMA_PRIVATE
     68 #include <machine/bus.h>
     69 #include <machine/autoconf.h>
     70 #include <machine/openfirm.h>
     71 
     72 #include <dev/pci/pcivar.h>
     73 #include <dev/pci/pcireg.h>
     74 #include <dev/pci/pcidevs.h>
     75 
     76 #include <sparc64/dev/iommureg.h>
     77 #include <sparc64/dev/iommuvar.h>
     78 #include <sparc64/dev/psychoreg.h>
     79 #include <sparc64/dev/psychovar.h>
     80 #include <sparc64/dev/ebusreg.h>
     81 #include <sparc64/dev/ebusvar.h>
     82 #include <sparc64/sparc64/cache.h>
     83 
     84 int	ebus_match __P((struct device *, struct cfdata *, void *));
     85 void	ebus_attach __P((struct device *, struct device *, void *));
     86 
     87 struct cfattach ebus_ca = {
     88 	sizeof(struct ebus_softc), ebus_match, ebus_attach
     89 };
     90 
     91 int	ebus_setup_attach_args __P((struct ebus_softc *, int,
     92 	    struct ebus_attach_args *));
     93 void	ebus_destroy_attach_args __P((struct ebus_attach_args *));
     94 int	ebus_print __P((void *, const char *));
     95 void	ebus_find_ino __P((struct ebus_softc *, struct ebus_attach_args *));
     96 int	ebus_find_node __P((struct pci_attach_args *));
     97 
     98 /*
     99  * here are our bus space and bus dma routines.
    100  */
    101 static int ebus_bus_mmap __P((bus_space_tag_t, bus_type_t, bus_addr_t,
    102 				int, bus_space_handle_t *));
    103 static int _ebus_bus_map __P((bus_space_tag_t, bus_type_t, bus_addr_t,
    104 				bus_size_t, int, vaddr_t,
    105 				bus_space_handle_t *));
    106 static void *ebus_intr_establish __P((bus_space_tag_t, int, int, int,
    107 				int (*) __P((void *)), void *));
    108 
    109 static int ebus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *,
    110 			  bus_size_t, struct proc *, int));
    111 static void ebus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
    112 static void ebus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
    113 				  bus_size_t, int));
    114 int ebus_dmamem_alloc __P((bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t,
    115 			   bus_dma_segment_t *, int, int *, int));
    116 void ebus_dmamem_free __P((bus_dma_tag_t, bus_dma_segment_t *, int));
    117 int ebus_dmamem_map __P((bus_dma_tag_t, bus_dma_segment_t *, int, size_t,
    118 			 caddr_t *, int));
    119 void ebus_dmamem_unmap __P((bus_dma_tag_t, caddr_t, size_t));
    120 
    121 int
    122 ebus_match(parent, match, aux)
    123 	struct device *parent;
    124 	struct cfdata *match;
    125 	void *aux;
    126 {
    127 	struct pci_attach_args *pa = aux;
    128 	char name[10];
    129 	int node;
    130 
    131 	/* Only attach if there's a PROM node. */
    132 	node = PCITAG_NODE(pa->pa_tag);
    133 	if (node == -1) return (0);
    134 
    135 	/* Match a real ebus */
    136 	OF_getprop(node, "name", &name, sizeof(name));
    137 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
    138 	    PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN &&
    139 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_EBUS &&
    140 		strcmp(name, "ebus") == 0)
    141 		return (1);
    142 
    143 	/* Or a real ebus III */
    144 	OF_getprop(node, "name", &name, sizeof(name));
    145 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
    146 	    PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN &&
    147 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_EBUSIII &&
    148 		strcmp(name, "ebus") == 0)
    149 		return (1);
    150 
    151 	/* Or a PCI-ISA bridge XXX I hope this is on-board. */
    152 	if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
    153 	    PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA) {
    154 		return (1);
    155 	}
    156 
    157 	return (0);
    158 }
    159 
    160 /*
    161  * attach an ebus and all it's children.  this code is modeled
    162  * after the sbus code which does similar things.
    163  */
    164 void
    165 ebus_attach(parent, self, aux)
    166 	struct device *parent, *self;
    167 	void *aux;
    168 {
    169 	struct ebus_softc *sc = (struct ebus_softc *)self;
    170 	struct pci_attach_args *pa = aux;
    171 	struct ebus_attach_args eba;
    172 	struct ebus_interrupt_map_mask *immp;
    173 	int node, nmapmask, error;
    174 	char devinfo[256];
    175 
    176 	printf("\n");
    177 
    178 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
    179 	printf("%s: %s, revision 0x%02x\n", self->dv_xname, devinfo,
    180 	    PCI_REVISION(pa->pa_class));
    181 
    182 	sc->sc_parent = (struct psycho_softc *)parent;
    183 	sc->sc_memtag = pa->pa_memt;
    184 	sc->sc_iotag = pa->pa_iot;
    185 	sc->sc_childbustag = ebus_alloc_bus_tag(sc, PCI_MEMORY_BUS_SPACE);
    186 	sc->sc_dmatag = ebus_alloc_dma_tag(sc, pa->pa_dmat);
    187 
    188 	node = PCITAG_NODE(pa->pa_tag);
    189 	if (node == -1)
    190 		panic("could not find ebus node");
    191 
    192 	sc->sc_node = node;
    193 
    194 	/*
    195 	 * fill in our softc with information from the prom
    196 	 */
    197 	sc->sc_intmap = NULL;
    198 	sc->sc_range = NULL;
    199 	error = getprop(node, "interrupt-map",
    200 			sizeof(struct ebus_interrupt_map),
    201 			&sc->sc_nintmap, (void **)&sc->sc_intmap);
    202 	switch (error) {
    203 	case 0:
    204 		immp = &sc->sc_intmapmask;
    205 		error = getprop(node, "interrupt-map-mask",
    206 			    sizeof(struct ebus_interrupt_map_mask), &nmapmask,
    207 			    (void **)&immp);
    208 		if (error)
    209 			panic("could not get ebus interrupt-map-mask");
    210 		if (nmapmask != 1)
    211 			panic("ebus interrupt-map-mask is broken");
    212 		break;
    213 	case ENOENT:
    214 		break;
    215 	default:
    216 		panic("ebus interrupt-map: error %d", error);
    217 		break;
    218 	}
    219 
    220 	error = getprop(node, "ranges", sizeof(struct ebus_ranges),
    221 	    &sc->sc_nrange, (void **)&sc->sc_range);
    222 	if (error)
    223 		panic("ebus ranges: error %d", error);
    224 
    225 	/*
    226 	 * now attach all our children
    227 	 */
    228 	DPRINTF(EDB_CHILD, ("ebus node %08x, searching children...\n", node));
    229 	for (node = firstchild(node); node; node = nextsibling(node)) {
    230 		char *name = getpropstring(node, "name");
    231 
    232 		if (ebus_setup_attach_args(sc, node, &eba) != 0) {
    233 			printf("ebus_attach: %s: incomplete\n", name);
    234 			continue;
    235 		} else {
    236 			DPRINTF(EDB_CHILD, ("- found child `%s', attaching\n",
    237 			    eba.ea_name));
    238 			(void)config_found(self, &eba, ebus_print);
    239 		}
    240 		ebus_destroy_attach_args(&eba);
    241 	}
    242 }
    243 
    244 int
    245 ebus_setup_attach_args(sc, node, ea)
    246 	struct ebus_softc	*sc;
    247 	int			node;
    248 	struct ebus_attach_args	*ea;
    249 {
    250 	int	n, rv;
    251 
    252 	bzero(ea, sizeof(struct ebus_attach_args));
    253 	rv = getprop(node, "name", 1, &n, (void **)&ea->ea_name);
    254 	if (rv != 0)
    255 		return (rv);
    256 	ea->ea_name[n] = '\0';
    257 
    258 	ea->ea_node = node;
    259 	ea->ea_bustag = sc->sc_childbustag;
    260 	ea->ea_dmatag = sc->sc_dmatag;
    261 
    262 	rv = getprop(node, "reg", sizeof(struct ebus_regs), &ea->ea_nregs,
    263 	    (void **)&ea->ea_regs);
    264 	if (rv)
    265 		return (rv);
    266 
    267 	rv = getprop(node, "address", sizeof(u_int32_t), &ea->ea_nvaddrs,
    268 	    (void **)&ea->ea_vaddrs);
    269 	if (rv != ENOENT) {
    270 		if (rv)
    271 			return (rv);
    272 
    273 		if (ea->ea_nregs != ea->ea_nvaddrs)
    274 			printf("ebus loses: device %s: %d regs and %d addrs\n",
    275 			    ea->ea_name, ea->ea_nregs, ea->ea_nvaddrs);
    276 	} else
    277 		ea->ea_nvaddrs = 0;
    278 
    279 	if (getprop(node, "interrupts", sizeof(u_int32_t), &ea->ea_nintrs,
    280 	    (void **)&ea->ea_intrs))
    281 		ea->ea_nintrs = 0;
    282 	else
    283 		ebus_find_ino(sc, ea);
    284 
    285 	return (0);
    286 }
    287 
    288 void
    289 ebus_destroy_attach_args(ea)
    290 	struct ebus_attach_args	*ea;
    291 {
    292 
    293 	if (ea->ea_name)
    294 		free((void *)ea->ea_name, M_DEVBUF);
    295 	if (ea->ea_regs)
    296 		free((void *)ea->ea_regs, M_DEVBUF);
    297 	if (ea->ea_intrs)
    298 		free((void *)ea->ea_intrs, M_DEVBUF);
    299 	if (ea->ea_vaddrs)
    300 		free((void *)ea->ea_vaddrs, M_DEVBUF);
    301 }
    302 
    303 int
    304 ebus_print(aux, p)
    305 	void *aux;
    306 	const char *p;
    307 {
    308 	struct ebus_attach_args *ea = aux;
    309 	int i;
    310 
    311 	if (p)
    312 		printf("%s at %s", ea->ea_name, p);
    313 	for (i = 0; i < ea->ea_nregs; i++)
    314 		printf("%s %x-%x", i == 0 ? " addr" : ",",
    315 		    ea->ea_regs[i].lo,
    316 		    ea->ea_regs[i].lo + ea->ea_regs[i].size - 1);
    317 	for (i = 0; i < ea->ea_nintrs; i++)
    318 		printf(" ipl %d", ea->ea_intrs[i]);
    319 	return (UNCONF);
    320 }
    321 
    322 
    323 /*
    324  * find the INO values for each interrupt and fill them in.
    325  *
    326  * for each "reg" property of this device, mask it's hi and lo
    327  * values with the "interrupt-map-mask"'s hi/lo values, and also
    328  * mask the interrupt number with the interrupt mask.  search the
    329  * "interrupt-map" list for matching values of hi, lo and interrupt
    330  * to give the INO for this interrupt.
    331  */
    332 void
    333 ebus_find_ino(sc, ea)
    334 	struct ebus_softc *sc;
    335 	struct ebus_attach_args *ea;
    336 {
    337 	u_int32_t hi, lo, intr;
    338 	int i, j, k;
    339 
    340 	if (sc->sc_nintmap == 0) {
    341 		for (i = 0; i < ea->ea_nintrs; i++) {
    342 			OF_mapintr(ea->ea_node, &ea->ea_intrs[i],
    343 				sizeof(ea->ea_intrs[0]),
    344 				sizeof(ea->ea_intrs[0]));
    345 		}
    346 		return;
    347 	}
    348 
    349 	DPRINTF(EDB_INTRMAP,
    350 	    ("ebus_find_ino: searching %d interrupts", ea->ea_nintrs));
    351 
    352 	for (j = 0; j < ea->ea_nintrs; j++) {
    353 
    354 		intr = ea->ea_intrs[j] & sc->sc_intmapmask.intr;
    355 
    356 		DPRINTF(EDB_INTRMAP,
    357 		    ("; intr %x masked to %x", ea->ea_intrs[j], intr));
    358 		for (i = 0; i < ea->ea_nregs; i++) {
    359 			hi = ea->ea_regs[i].hi & sc->sc_intmapmask.hi;
    360 			lo = ea->ea_regs[i].lo & sc->sc_intmapmask.lo;
    361 
    362 			DPRINTF(EDB_INTRMAP,
    363 			    ("; reg hi.lo %08x.%08x masked to %08x.%08x",
    364 			    ea->ea_regs[i].hi, ea->ea_regs[i].lo, hi, lo));
    365 			for (k = 0; k < sc->sc_nintmap; k++) {
    366 				DPRINTF(EDB_INTRMAP,
    367 				    ("; checking hi.lo %08x.%08x intr %x",
    368 				    sc->sc_intmap[k].hi, sc->sc_intmap[k].lo,
    369 				    sc->sc_intmap[k].intr));
    370 				if (hi == sc->sc_intmap[k].hi &&
    371 				    lo == sc->sc_intmap[k].lo &&
    372 				    intr == sc->sc_intmap[k].intr) {
    373 					ea->ea_intrs[j] =
    374 					    sc->sc_intmap[k].cintr;
    375 					DPRINTF(EDB_INTRMAP,
    376 					    ("; FOUND IT! changing to %d\n",
    377 					    sc->sc_intmap[k].cintr));
    378 					goto next_intr;
    379 				}
    380 			}
    381 		}
    382 next_intr:;
    383 	}
    384 }
    385 
    386 
    387 /*
    388  * bus space and bus dma below here
    389  */
    390 bus_space_tag_t
    391 ebus_alloc_bus_tag(sc, type)
    392 	struct ebus_softc *sc;
    393 	int type;
    394 {
    395 	bus_space_tag_t bt;
    396 
    397 	bt = (bus_space_tag_t)
    398 		malloc(sizeof(struct sparc_bus_space_tag), M_DEVBUF, M_NOWAIT);
    399 	if (bt == NULL)
    400 		panic("could not allocate ebus bus tag");
    401 
    402 	bzero(bt, sizeof *bt);
    403 	bt->cookie = sc;
    404 	bt->parent = sc->sc_memtag;
    405 	bt->type = type;
    406 	bt->sparc_bus_map = _ebus_bus_map;
    407 	bt->sparc_bus_mmap = ebus_bus_mmap;
    408 	bt->sparc_intr_establish = ebus_intr_establish;
    409 	return (bt);
    410 }
    411 
    412 /* XXX? */
    413 bus_dma_tag_t
    414 ebus_alloc_dma_tag(sc, pdt)
    415 	struct ebus_softc *sc;
    416 	bus_dma_tag_t pdt;
    417 {
    418 	bus_dma_tag_t dt;
    419 
    420 	dt = (bus_dma_tag_t)
    421 		malloc(sizeof(struct sparc_bus_dma_tag), M_DEVBUF, M_NOWAIT);
    422 	if (dt == NULL)
    423 		panic("could not allocate ebus dma tag");
    424 
    425 	bzero(dt, sizeof *dt);
    426 	dt->_cookie = sc;
    427 	dt->_parent = pdt;
    428 #define PCOPY(x)	dt->x = pdt->x
    429 	PCOPY(_dmamap_create);
    430 	PCOPY(_dmamap_destroy);
    431 	dt->_dmamap_load = ebus_dmamap_load;
    432 	PCOPY(_dmamap_load_mbuf);
    433 	PCOPY(_dmamap_load_uio);
    434 	PCOPY(_dmamap_load_raw);
    435 	dt->_dmamap_unload = ebus_dmamap_unload;
    436 	dt->_dmamap_sync = ebus_dmamap_sync;
    437 	dt->_dmamem_alloc = ebus_dmamem_alloc;
    438 	dt->_dmamem_free = ebus_dmamem_free;
    439 	dt->_dmamem_map = ebus_dmamem_map;
    440 	dt->_dmamem_unmap = ebus_dmamem_unmap;
    441 	PCOPY(_dmamem_mmap);
    442 #undef	PCOPY
    443 	return (dt);
    444 }
    445 
    446 /*
    447  * bus space support.  <sparc64/dev/psychoreg.h> has a discussion
    448  * about PCI physical addresses, which also applies to ebus.
    449  */
    450 static int
    451 _ebus_bus_map(t, btype, offset, size, flags, vaddr, hp)
    452 	bus_space_tag_t t;
    453 	bus_type_t btype;
    454 	bus_addr_t offset;
    455 	bus_size_t size;
    456 	int	flags;
    457 	vaddr_t vaddr;
    458 	bus_space_handle_t *hp;
    459 {
    460 	struct ebus_softc *sc = t->cookie;
    461 	bus_addr_t hi, lo;
    462 	int i, ss;
    463 
    464 	DPRINTF(EDB_BUSMAP,
    465 	    ("\n_ebus_bus_map: type %d off %016llx sz %x flags %d va %p",
    466 	    (int)t->type, (unsigned long long)offset, (int)size, (int)flags,
    467 	    (void *)vaddr));
    468 
    469 	hi = offset >> 32UL;
    470 	lo = offset & 0xffffffff;
    471 	DPRINTF(EDB_BUSMAP, (" (hi %08x lo %08x)", (u_int)hi, (u_int)lo));
    472 	for (i = 0; i < sc->sc_nrange; i++) {
    473 		bus_addr_t pciaddr;
    474 
    475 		if (hi != sc->sc_range[i].child_hi)
    476 			continue;
    477 		if (lo < sc->sc_range[i].child_lo ||
    478 		    (lo + size) >
    479 		      (sc->sc_range[i].child_lo + sc->sc_range[i].size))
    480 			continue;
    481 
    482 		/* Isolate address space and find the right tag */
    483 		ss = (sc->sc_range[i].phys_hi>>24)&3;
    484 		switch (ss) {
    485 		case 1:	/* I/O space */
    486 			t = sc->sc_iotag;
    487 			break;
    488 		case 2:	/* Memory space */
    489 			t = sc->sc_memtag;
    490 			break;
    491 		case 0:	/* Config space */
    492 		case 3:	/* 64-bit Memory space */
    493 		default: /* WTF? */
    494 			/* We don't handle these */
    495 			panic("_ebus_bus_map: illegal space %x", ss);
    496 			break;
    497 		}
    498 		pciaddr = ((bus_addr_t)sc->sc_range[i].phys_mid << 32UL) |
    499 				       sc->sc_range[i].phys_lo;
    500 		pciaddr += lo;
    501 		DPRINTF(EDB_BUSMAP,
    502 		    ("\n_ebus_bus_map: mapping space %x paddr offset %qx pciaddr %qx\n",
    503 		    ss, (unsigned long long)offset, (unsigned long long)pciaddr));
    504 		/* pass it onto the psycho */
    505 		return (bus_space_map2(t, sc->sc_range[i].phys_hi,
    506 			pciaddr, size, flags, vaddr, hp));
    507 	}
    508 	DPRINTF(EDB_BUSMAP, (": FAILED\n"));
    509 	return (EINVAL);
    510 }
    511 
    512 static int
    513 ebus_bus_mmap(t, btype, paddr, flags, hp)
    514 	bus_space_tag_t t;
    515 	bus_type_t btype;
    516 	bus_addr_t paddr;
    517 	int flags;
    518 	bus_space_handle_t *hp;
    519 {
    520 	bus_addr_t offset = paddr;
    521 	struct ebus_softc *sc = t->cookie;
    522 	int i;
    523 
    524 	for (i = 0; i < sc->sc_nrange; i++) {
    525 		bus_addr_t paddr = ((bus_addr_t)sc->sc_range[i].child_hi << 32) |
    526 		    sc->sc_range[i].child_lo;
    527 
    528 		if (offset != paddr)
    529 			continue;
    530 
    531 		DPRINTF(EDB_BUSMAP, ("\n_ebus_bus_mmap: mapping paddr %qx\n",
    532 		    (unsigned long long)paddr));
    533 		return (bus_space_mmap(sc->sc_memtag, 0, paddr,
    534 				       flags, hp));
    535 	}
    536 
    537 	return (-1);
    538 }
    539 
    540 /*
    541  * install an interrupt handler for a PCI device
    542  */
    543 void *
    544 ebus_intr_establish(t, pri, level, flags, handler, arg)
    545 	bus_space_tag_t t;
    546 	int pri;
    547 	int level;
    548 	int flags;
    549 	int (*handler) __P((void *));
    550 	void *arg;
    551 {
    552 	return (bus_intr_establish(t->parent, pri, level, flags, handler, arg));
    553 }
    554 
    555 /*
    556  * bus dma support
    557  */
    558 int
    559 ebus_dmamap_load(t, map, buf, buflen, p, flags)
    560 	bus_dma_tag_t t;
    561 	bus_dmamap_t map;
    562 	void *buf;
    563 	bus_size_t buflen;
    564 	struct proc *p;
    565 	int flags;
    566 {
    567 	struct ebus_softc *sc = t->_cookie;
    568 
    569 	return (iommu_dvmamap_load(t, sc->sc_parent->sc_is, map, buf, buflen,
    570 	    p, flags));
    571 }
    572 
    573 void
    574 ebus_dmamap_unload(t, map)
    575 	bus_dma_tag_t t;
    576 	bus_dmamap_t map;
    577 {
    578 	struct ebus_softc *sc = t->_cookie;
    579 
    580 	iommu_dvmamap_unload(t, sc->sc_parent->sc_is, map);
    581 }
    582 
    583 void
    584 ebus_dmamap_sync(t, map, offset, len, ops)
    585 	bus_dma_tag_t t;
    586 	bus_dmamap_t map;
    587 	bus_addr_t offset;
    588 	bus_size_t len;
    589 	int ops;
    590 {
    591 	struct ebus_softc *sc = t->_cookie;
    592 
    593 	iommu_dvmamap_sync(t, sc->sc_parent->sc_is, map, offset, len, ops);
    594 	bus_dmamap_sync(t->_parent, map, offset, len, ops);
    595 }
    596 
    597 int
    598 ebus_dmamem_alloc(t, size, alignment, boundary, segs, nsegs, rsegs, flags)
    599 	bus_dma_tag_t t;
    600 	bus_size_t size;
    601 	bus_size_t alignment;
    602 	bus_size_t boundary;
    603 	bus_dma_segment_t *segs;
    604 	int nsegs;
    605 	int *rsegs;
    606 	int flags;
    607 {
    608 	struct ebus_softc *sc = t->_cookie;
    609 
    610 	return (iommu_dvmamem_alloc(t, sc->sc_parent->sc_is, size, alignment,
    611 	    boundary, segs, nsegs, rsegs, flags));
    612 }
    613 
    614 void
    615 ebus_dmamem_free(t, segs, nsegs)
    616 	bus_dma_tag_t t;
    617 	bus_dma_segment_t *segs;
    618 	int nsegs;
    619 {
    620 	struct ebus_softc *sc = t->_cookie;
    621 
    622 	iommu_dvmamem_free(t, sc->sc_parent->sc_is, segs, nsegs);
    623 }
    624 
    625 int
    626 ebus_dmamem_map(t, segs, nsegs, size, kvap, flags)
    627 	bus_dma_tag_t t;
    628 	bus_dma_segment_t *segs;
    629 	int nsegs;
    630 	size_t size;
    631 	caddr_t *kvap;
    632 	int flags;
    633 {
    634 	struct ebus_softc *sc = t->_cookie;
    635 
    636 	return (iommu_dvmamem_map(t, sc->sc_parent->sc_is, segs, nsegs,
    637 	    size, kvap, flags));
    638 }
    639 
    640 void
    641 ebus_dmamem_unmap(t, kva, size)
    642 	bus_dma_tag_t t;
    643 	caddr_t kva;
    644 	size_t size;
    645 {
    646 	struct ebus_softc *sc = t->_cookie;
    647 
    648 	iommu_dvmamem_unmap(t, sc->sc_parent->sc_is, kva, size);
    649 }
    650