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