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