Home | History | Annotate | Line # | Download | only in include
bus.h revision 1.6
      1 /*	$NetBSD: bus.h,v 1.6 2003/09/21 14:41:34 cl Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the NetBSD
     22  *	Foundation, Inc. and its contributors.
     23  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  *    contributors may be used to endorse or promote products derived
     25  *    from this software without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  * POSSIBILITY OF SUCH DAMAGE.
     38  */
     39 
     40 /*
     41  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
     42  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     43  *
     44  * Redistribution and use in source and binary forms, with or without
     45  * modification, are permitted provided that the following conditions
     46  * are met:
     47  * 1. Redistributions of source code must retain the above copyright
     48  *    notice, this list of conditions and the following disclaimer.
     49  * 2. Redistributions in binary form must reproduce the above copyright
     50  *    notice, this list of conditions and the following disclaimer in the
     51  *    documentation and/or other materials provided with the distribution.
     52  * 3. All advertising materials mentioning features or use of this software
     53  *    must display the following acknowledgement:
     54  *      This product includes software developed by Christopher G. Demetriou
     55  *	for the NetBSD Project.
     56  * 4. The name of the author may not be used to endorse or promote products
     57  *    derived from this software without specific prior written permission
     58  *
     59  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     60  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     61  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     62  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     63  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     64  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     65  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     66  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     67  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     68  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     69  */
     70 
     71 #ifndef _SUN68K_BUS_H_
     72 #define _SUN68K_BUS_H_
     73 
     74 #define	SUN68K_BUS_SPACE	0
     75 
     76 /*
     77  * Bus address and size types
     78  */
     79 typedef	u_long	bus_space_handle_t;
     80 typedef u_long	bus_type_t;
     81 typedef u_long	bus_addr_t;
     82 typedef u_long	bus_size_t;
     83 
     84 #define	BUS_ADDR_PADDR(x)	((x)&0xffffffff)
     85 
     86 /*
     87  * Access methods for bus resources and address space.
     88  */
     89 typedef struct sun68k_bus_space_tag	*bus_space_tag_t;
     90 
     91 struct sun68k_bus_space_tag {
     92 	void		*cookie;
     93 	bus_space_tag_t	parent;
     94 
     95 	int	(*sun68k_bus_map) __P((
     96 				bus_space_tag_t,
     97 				bus_type_t,
     98 				bus_addr_t,
     99 				bus_size_t,
    100 				int,			/*flags*/
    101 				vaddr_t,		/*preferred vaddr*/
    102 				bus_space_handle_t *));
    103 	int	(*sun68k_bus_unmap) __P((
    104 				bus_space_tag_t,
    105 				bus_space_handle_t,
    106 				bus_size_t));
    107 	int	(*sun68k_bus_subregion) __P((
    108 				bus_space_tag_t,
    109 				bus_space_handle_t,
    110 				bus_size_t,		/*offset*/
    111 				bus_size_t,		/*size*/
    112 				bus_space_handle_t *));
    113 
    114 	void	(*sun68k_bus_barrier) __P((
    115 				bus_space_tag_t,
    116 				bus_space_handle_t,
    117 				bus_size_t,		/*offset*/
    118 				bus_size_t,		/*size*/
    119 				int));			/*flags*/
    120 
    121 	paddr_t	(*sun68k_bus_mmap) __P((
    122 				bus_space_tag_t,
    123 				bus_type_t,		/**/
    124 				bus_addr_t,		/**/
    125 				off_t,			/*offset*/
    126 				int,			/*prot*/
    127 				int));			/*flags*/
    128 
    129 	void	*(*sun68k_intr_establish) __P((
    130 				bus_space_tag_t,
    131 				int,			/*bus-specific intr*/
    132 				int,			/*device class level,
    133 							  see machine/intr.h*/
    134 				int,			/*flags*/
    135 				int (*) __P((void *)),	/*handler*/
    136 				void *));		/*handler arg*/
    137 
    138 	int	(*sun68k_bus_peek) __P((
    139 				bus_space_tag_t,
    140 				bus_space_handle_t,
    141 				bus_size_t,		/*offset*/
    142 				size_t,			/*probe size*/
    143 				void *));		/*result ptr*/
    144 
    145 	int	(*sun68k_bus_poke) __P((
    146 				bus_space_tag_t,
    147 				bus_space_handle_t,
    148 				bus_size_t,		/*offset*/
    149 				size_t,			/*probe size*/
    150 				u_int32_t));		/*value*/
    151 };
    152 
    153 #if 0
    154 /*
    155  * The following macro could be used to generate the bus_space*() functions
    156  * but it uses a gcc extension and is ANSI-only.
    157 #define PROTO_bus_space_xxx		__P((bus_space_tag_t t, ...))
    158 #define RETURNTYPE_bus_space_xxx	void *
    159 #define BUSFUN(name, returntype, t, args...)			\
    160 	__inline__ RETURNTYPE_##name				\
    161 	bus_##name PROTO_##name					\
    162 	{							\
    163 		while (t->sun68k_##name == NULL)			\
    164 			t = t->parent;				\
    165 		return (*(t)->sun68k_##name)(t, args);		\
    166 	}
    167  */
    168 #endif
    169 
    170 /*
    171  * Bus space function prototypes.
    172  */
    173 static int	bus_space_map __P((
    174 				bus_space_tag_t,
    175 				bus_addr_t,
    176 				bus_size_t,
    177 				int,			/*flags*/
    178 				bus_space_handle_t *));
    179 static int	bus_space_map2 __P((
    180 				bus_space_tag_t,
    181 				bus_type_t,
    182 				bus_addr_t,
    183 				bus_size_t,
    184 				int,			/*flags*/
    185 				vaddr_t,		/*preferred vaddr*/
    186 				bus_space_handle_t *));
    187 static int	bus_space_unmap __P((
    188 				bus_space_tag_t,
    189 				bus_space_handle_t,
    190 				bus_size_t));
    191 static int	bus_space_subregion __P((
    192 				bus_space_tag_t,
    193 				bus_space_handle_t,
    194 				bus_size_t,
    195 				bus_size_t,
    196 				bus_space_handle_t *));
    197 static void	bus_space_barrier __P((
    198 				bus_space_tag_t,
    199 				bus_space_handle_t,
    200 				bus_size_t,
    201 				bus_size_t,
    202 				int));
    203 static paddr_t	bus_space_mmap __P((
    204 				bus_space_tag_t,
    205 				bus_addr_t,		/**/
    206 				off_t,			/*offset*/
    207 				int,			/*prot*/
    208 				int));			/*flags*/
    209 static paddr_t	bus_space_mmap2 __P((
    210 				bus_space_tag_t,
    211 				bus_type_t,
    212 				bus_addr_t,		/**/
    213 				off_t,			/*offset*/
    214 				int,			/*prot*/
    215 				int));			/*flags*/
    216 static void	*bus_intr_establish __P((
    217 				bus_space_tag_t,
    218 				int,			/*bus-specific intr*/
    219 				int,			/*device class level,
    220 							  see machine/intr.h*/
    221 				int,			/*flags*/
    222 				int (*) __P((void *)),	/*handler*/
    223 				void *));		/*handler arg*/
    224 static int	_bus_space_peek __P((
    225 				bus_space_tag_t,
    226 				bus_space_handle_t,
    227 				bus_size_t,		/*offset*/
    228 				size_t,			/*probe size*/
    229 				void *));		/*result ptr*/
    230 static int	_bus_space_poke __P((
    231 				bus_space_tag_t,
    232 				bus_space_handle_t,
    233 				bus_size_t,		/*offset*/
    234 				size_t,			/*probe size*/
    235 				u_int32_t));		/*value*/
    236 
    237 /* This macro finds the first "upstream" implementation of method `f' */
    238 #define _BS_CALL(t,f)			\
    239 	while (t->f == NULL)		\
    240 		t = t->parent;		\
    241 	return (*(t)->f)
    242 
    243 __inline__ int
    244 bus_space_map(t, a, s, f, hp)
    245 	bus_space_tag_t	t;
    246 	bus_addr_t	a;
    247 	bus_size_t	s;
    248 	int		f;
    249 	bus_space_handle_t *hp;
    250 {
    251 	_BS_CALL(t, sun68k_bus_map)((t), 0, (a), (s), (f), 0, (hp));
    252 }
    253 
    254 __inline__ int
    255 bus_space_map2(t, bt, a, s, f, v, hp)
    256 	bus_space_tag_t	t;
    257 	bus_type_t	bt;
    258 	bus_addr_t	a;
    259 	bus_size_t	s;
    260 	int		f;
    261 	vaddr_t		v;
    262 	bus_space_handle_t *hp;
    263 {
    264 	_BS_CALL(t, sun68k_bus_map)(t, bt, a, s, f, v, hp);
    265 }
    266 
    267 __inline__ int
    268 bus_space_unmap(t, h, s)
    269 	bus_space_tag_t t;
    270 	bus_space_handle_t h;
    271 	bus_size_t	s;
    272 {
    273 	_BS_CALL(t, sun68k_bus_unmap)(t, h, s);
    274 }
    275 
    276 __inline__ int
    277 bus_space_subregion(t, h, o, s, hp)
    278 	bus_space_tag_t	t;
    279 	bus_space_handle_t h;
    280 	bus_size_t	o;
    281 	bus_size_t	s;
    282 	bus_space_handle_t *hp;
    283 {
    284 	_BS_CALL(t, sun68k_bus_subregion)(t, h, o, s, hp);
    285 }
    286 
    287 __inline__ paddr_t
    288 bus_space_mmap(t, a, o, p, f)
    289 	bus_space_tag_t	t;
    290 	bus_addr_t	a;
    291 	off_t		o;
    292 	int		p;
    293 	int		f;
    294 {
    295 	_BS_CALL(t, sun68k_bus_mmap)(t, 0, a, o, p, f);
    296 }
    297 
    298 __inline__ paddr_t
    299 bus_space_mmap2(t, bt, a, o, p, f)
    300 	bus_space_tag_t	t;
    301 	bus_type_t	bt;
    302 	bus_addr_t	a;
    303 	off_t		o;
    304 	int		p;
    305 	int		f;
    306 {
    307 	_BS_CALL(t, sun68k_bus_mmap)(t, bt, a, o, p, f);
    308 }
    309 
    310 __inline__ void *
    311 bus_intr_establish(t, p, l, f, h, a)
    312 	bus_space_tag_t t;
    313 	int	p;
    314 	int	l;
    315 	int	f;
    316 	int	(*h)__P((void *));
    317 	void	*a;
    318 {
    319 	_BS_CALL(t, sun68k_intr_establish)(t, p, l, f, h, a);
    320 }
    321 
    322 __inline__ void
    323 bus_space_barrier(t, h, o, s, f)
    324 	bus_space_tag_t t;
    325 	bus_space_handle_t h;
    326 	bus_size_t o;
    327 	bus_size_t s;
    328 	int f;
    329 {
    330 	_BS_CALL(t, sun68k_bus_barrier)(t, h, o, s, f);
    331 }
    332 
    333 __inline__ int
    334 _bus_space_peek(t, h, o, s, vp)
    335 	bus_space_tag_t t;
    336 	bus_space_handle_t h;
    337 	bus_size_t o;
    338 	size_t s;
    339 	void *vp;
    340 {
    341 	_BS_CALL(t, sun68k_bus_peek)(t, h, o, s, vp);
    342 }
    343 
    344 __inline__ int
    345 _bus_space_poke(t, h, o, s, v)
    346 	bus_space_tag_t t;
    347 	bus_space_handle_t h;
    348 	bus_size_t o;
    349 	size_t s;
    350 	u_int32_t v;
    351 {
    352 	_BS_CALL(t, sun68k_bus_poke)(t, h, o, s, v);
    353 }
    354 
    355 #if 0
    356 int	bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
    357 	    bus_addr_t rend, bus_size_t size, bus_size_t align,
    358 	    bus_size_t boundary, int flags, bus_addr_t *addrp,
    359 	    bus_space_handle_t *bshp));
    360 void	bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
    361 	    bus_size_t size));
    362 #endif
    363 
    364 /* flags for bus space map functions */
    365 #define BUS_SPACE_MAP_CACHEABLE	0x0001
    366 #define BUS_SPACE_MAP_LINEAR	0x0002
    367 #define BUS_SPACE_MAP_PREFETCHABLE	0x0004
    368 #define BUS_SPACE_MAP_BUS1	0x0100	/* placeholders for bus functions... */
    369 #define BUS_SPACE_MAP_BUS2	0x0200
    370 #define BUS_SPACE_MAP_BUS3	0x0400
    371 #define BUS_SPACE_MAP_BUS4	0x0800
    372 
    373 /* Internal flag: try to find and use a PROM maping for the device. */
    374 #define	_SUN68K_BUS_MAP_USE_PROM		BUS_SPACE_MAP_BUS1
    375 
    376 /* flags for intr_establish() */
    377 #define BUS_INTR_ESTABLISH_FASTTRAP	1
    378 #define BUS_INTR_ESTABLISH_SOFTINTR	2
    379 
    380 /* flags for bus_space_barrier() */
    381 #define	BUS_SPACE_BARRIER_READ	0x01		/* force read barrier */
    382 #define	BUS_SPACE_BARRIER_WRITE	0x02		/* force write barrier */
    383 
    384 /*
    385  *	int bus_space_peek_N(bus_space_tag_t tag,
    386  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t *valuep);
    387  *
    388  * Cautiously read 1, 2, 4 or 8 byte quantity from bus space described
    389  * by tag/handle/offset.
    390  * If no hardware responds to the read access, the function returns a
    391  * non-zero value. Otherwise the value read is placed in `valuep'.
    392  */
    393 
    394 #define	bus_space_peek_1(t, h, o, vp)					\
    395     _bus_space_peek(t, h, o, sizeof(u_int8_t), (void *)vp)
    396 
    397 #define	bus_space_peek_2(t, h, o, vp)					\
    398     _bus_space_peek(t, h, o, sizeof(u_int16_t), (void *)vp)
    399 
    400 #define	bus_space_peek_4(t, h, o, vp)					\
    401     _bus_space_peek(t, h, o, sizeof(u_int32_t), (void *)vp)
    402 
    403 /*
    404  *	int bus_space_poke_N(bus_space_tag_t tag,
    405  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t value);
    406  *
    407  * Cautiously write 1, 2, 4 or 8 byte quantity to bus space described
    408  * by tag/handle/offset.
    409  * If no hardware responds to the write access, the function returns a
    410  * non-zero value.
    411  */
    412 
    413 #define	bus_space_poke_1(t, h, o, v)					\
    414     _bus_space_poke(t, h, o, sizeof(u_int8_t), v)
    415 
    416 #define	bus_space_poke_2(t, h, o, v)					\
    417     _bus_space_poke(t, h, o, sizeof(u_int16_t), v)
    418 
    419 #define	bus_space_poke_4(t, h, o, v)					\
    420     _bus_space_poke(t, h, o, sizeof(u_int32_t), v)
    421 
    422 /*
    423  *	u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
    424  *	    bus_space_handle_t bsh, bus_size_t offset));
    425  *
    426  * Read a 1, 2, 4, or 8 byte quantity from bus space
    427  * described by tag/handle/offset.
    428  */
    429 
    430 #define	bus_space_read_1(t, h, o)					\
    431 	    ((void)t, *(volatile u_int8_t *)((h) + (o)))
    432 
    433 #define	bus_space_read_2(t, h, o)					\
    434 	    ((void)t, *(volatile u_int16_t *)((h) + (o)))
    435 
    436 #define	bus_space_read_4(t, h, o)					\
    437 	    ((void)t, *(volatile u_int32_t *)((h) + (o)))
    438 
    439 #define	bus_space_read_8(t, h, o)					\
    440 	    ((void)t, *(volatile u_int64_t *)((h) + (o)))
    441 
    442 
    443 /*
    444  *	void bus_space_write_N __P((bus_space_tag_t tag,
    445  *	    bus_space_handle_t bsh, bus_size_t offset,
    446  *	    u_intN_t value));
    447  *
    448  * Write the 1, 2, 4, or 8 byte value `value' to bus space
    449  * described by tag/handle/offset.
    450  */
    451 
    452 #define	bus_space_write_1(t, h, o, v)	do {				\
    453 	((void)t, (void)(*(volatile u_int8_t *)((h) + (o)) = (v)));	\
    454 } while (0)
    455 
    456 #define	bus_space_write_2(t, h, o, v)	do {				\
    457 	((void)t, (void)(*(volatile u_int16_t *)((h) + (o)) = (v)));	\
    458 } while (0)
    459 
    460 #define	bus_space_write_4(t, h, o, v)	do {				\
    461 	((void)t, (void)(*(volatile u_int32_t *)((h) + (o)) = (v)));	\
    462 } while (0)
    463 
    464 #define	bus_space_write_8(t, h, o, v)	do {				\
    465 	((void)t, (void)(*(volatile u_int64_t *)((h) + (o)) = (v)));	\
    466 } while (0)
    467 
    468 
    469 /*
    470  *	void bus_space_read_multi_N __P((bus_space_tag_t tag,
    471  *	    bus_space_handle_t bsh, bus_size_t offset,
    472  *	    u_intN_t *addr, bus_size_t count));
    473  *
    474  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
    475  * described by tag/handle/offset and copy into buffer provided.
    476  */
    477 
    478 void bus_space_read_multi_1 __P((bus_space_tag_t,
    479 				 bus_space_handle_t,
    480 				 bus_size_t,
    481 				 u_int8_t *,
    482 				 bus_size_t));
    483 
    484 void bus_space_read_multi_2 __P((bus_space_tag_t,
    485 				 bus_space_handle_t,
    486 				 bus_size_t,
    487 				 u_int16_t *,
    488 				 bus_size_t));
    489 
    490 void bus_space_read_multi_4 __P((bus_space_tag_t,
    491 				 bus_space_handle_t,
    492 				 bus_size_t,
    493 				 u_int32_t *,
    494 				 bus_size_t));
    495 
    496 void bus_space_read_multi_8 __P((bus_space_tag_t,
    497 				 bus_space_handle_t,
    498 				 bus_size_t,
    499 				 u_int64_t *,
    500 				 bus_size_t));
    501 
    502 extern __inline__ void
    503 bus_space_read_multi_1(t, h, o, a, c)
    504 	bus_space_tag_t		t;
    505 	bus_space_handle_t	h;
    506 	bus_size_t		o, c;
    507 	u_int8_t		*a;
    508 {
    509 	while (c-- > 0)
    510 		*a++ = bus_space_read_1(t, h, o);
    511 }
    512 
    513 extern __inline__ void
    514 bus_space_read_multi_2(t, h, o, a, c)
    515 	bus_space_tag_t		t;
    516 	bus_space_handle_t	h;
    517 	bus_size_t		o, c;
    518 	u_int16_t		*a;
    519 {
    520 	while (c-- > 0)
    521 		*a++ = bus_space_read_2(t, h, o);
    522 }
    523 
    524 extern __inline__ void
    525 bus_space_read_multi_4(t, h, o, a, c)
    526 	bus_space_tag_t		t;
    527 	bus_space_handle_t	h;
    528 	bus_size_t		o, c;
    529 	u_int32_t		*a;
    530 {
    531 	while (c-- > 0)
    532 		*a++ = bus_space_read_4(t, h, o);
    533 }
    534 
    535 extern __inline__ void
    536 bus_space_read_multi_8(t, h, o, a, c)
    537 	bus_space_tag_t		t;
    538 	bus_space_handle_t	h;
    539 	bus_size_t		o, c;
    540 	u_int64_t		*a;
    541 {
    542 	while (c-- > 0)
    543 		*a++ = bus_space_read_8(t, h, o);
    544 }
    545 
    546 
    547 /*
    548  *	void bus_space_write_multi_N __P((bus_space_tag_t tag,
    549  *	    bus_space_handle_t bsh, bus_size_t offset,
    550  *	    const u_intN_t *addr, bus_size_t count));
    551  *
    552  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
    553  * provided to bus space described by tag/handle/offset.
    554  */
    555 void bus_space_write_multi_1 __P((bus_space_tag_t,
    556 				  bus_space_handle_t,
    557 				  bus_size_t,
    558 				  const u_int8_t *,
    559 				  bus_size_t));
    560 void bus_space_write_multi_2 __P((bus_space_tag_t,
    561 				  bus_space_handle_t,
    562 				  bus_size_t,
    563 				  const u_int16_t *,
    564 				  bus_size_t));
    565 void bus_space_write_multi_4 __P((bus_space_tag_t,
    566 				  bus_space_handle_t,
    567 				  bus_size_t,
    568 				  const u_int32_t *,
    569 				  bus_size_t));
    570 void bus_space_write_multi_8 __P((bus_space_tag_t,
    571 				  bus_space_handle_t,
    572 				  bus_size_t,
    573 				  const u_int64_t *,
    574 				  bus_size_t));
    575 extern __inline__ void
    576 bus_space_write_multi_1(t, h, o, a, c)
    577 	bus_space_tag_t		t;
    578 	bus_space_handle_t	h;
    579 	bus_size_t		o, c;
    580 	const u_int8_t		*a;
    581 {
    582 	while (c-- > 0)
    583 		bus_space_write_1(t, h, o, *a++);
    584 }
    585 
    586 extern __inline__ void
    587 bus_space_write_multi_2(t, h, o, a, c)
    588 	bus_space_tag_t		t;
    589 	bus_space_handle_t	h;
    590 	bus_size_t		o, c;
    591 	const u_int16_t		*a;
    592 {
    593 	while (c-- > 0)
    594 		bus_space_write_2(t, h, o, *a++);
    595 }
    596 
    597 extern __inline__ void
    598 bus_space_write_multi_4(t, h, o, a, c)
    599 	bus_space_tag_t		t;
    600 	bus_space_handle_t	h;
    601 	bus_size_t		o, c;
    602 	const u_int32_t		*a;
    603 {
    604 	while (c-- > 0)
    605 		bus_space_write_4(t, h, o, *a++);
    606 }
    607 
    608 extern __inline__ void
    609 bus_space_write_multi_8(t, h, o, a, c)
    610 	bus_space_tag_t		t;
    611 	bus_space_handle_t	h;
    612 	bus_size_t		o, c;
    613 	const u_int64_t		*a;
    614 {
    615 	while (c-- > 0)
    616 		bus_space_write_8(t, h, o, *a++);
    617 }
    618 
    619 /*
    620  *	void bus_space_set_multi_N __P((bus_space_tag_t tag,
    621  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
    622  *	    bus_size_t count));
    623  *
    624  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
    625  * by tag/handle/offset `count' times.
    626  */
    627 void bus_space_set_multi_1 __P((bus_space_tag_t,
    628 				bus_space_handle_t,
    629 				bus_size_t,
    630 				const u_int8_t,
    631 				bus_size_t));
    632 void bus_space_set_multi_2 __P((bus_space_tag_t,
    633 				bus_space_handle_t,
    634 				bus_size_t,
    635 				const u_int16_t,
    636 				bus_size_t));
    637 void bus_space_set_multi_4 __P((bus_space_tag_t,
    638 				bus_space_handle_t,
    639 				bus_size_t,
    640 				const u_int32_t,
    641 				bus_size_t));
    642 void bus_space_set_multi_8 __P((bus_space_tag_t,
    643 				bus_space_handle_t,
    644 				bus_size_t,
    645 				const u_int64_t,
    646 				bus_size_t));
    647 
    648 extern __inline__ void
    649 bus_space_set_multi_1(t, h, o, v, c)
    650 	bus_space_tag_t		t;
    651 	bus_space_handle_t	h;
    652 	bus_size_t		o, c;
    653 	const u_int8_t		v;
    654 {
    655 	while (c-- > 0)
    656 		bus_space_write_1(t, h, o, v);
    657 }
    658 
    659 extern __inline__ void
    660 bus_space_set_multi_2(t, h, o, v, c)
    661 	bus_space_tag_t		t;
    662 	bus_space_handle_t	h;
    663 	bus_size_t		o, c;
    664 	const u_int16_t		v;
    665 {
    666 	while (c-- > 0)
    667 		bus_space_write_2(t, h, o, v);
    668 }
    669 
    670 extern __inline__ void
    671 bus_space_set_multi_4(t, h, o, v, c)
    672 	bus_space_tag_t		t;
    673 	bus_space_handle_t	h;
    674 	bus_size_t		o, c;
    675 	const u_int32_t		v;
    676 {
    677 	while (c-- > 0)
    678 		bus_space_write_4(t, h, o, v);
    679 }
    680 
    681 extern __inline__ void
    682 bus_space_set_multi_8(t, h, o, v, c)
    683 	bus_space_tag_t		t;
    684 	bus_space_handle_t	h;
    685 	bus_size_t		o, c;
    686 	const u_int64_t		v;
    687 {
    688 	while (c-- > 0)
    689 		bus_space_write_8(t, h, o, v);
    690 }
    691 
    692 
    693 /*
    694  *	void bus_space_read_region_N __P((bus_space_tag_t tag,
    695  *	    bus_space_handle_t bsh, bus_size_t off,
    696  *	    u_intN_t *addr, bus_size_t count));
    697  *
    698  */
    699 void bus_space_read_region_1 __P((bus_space_tag_t,
    700 				  bus_space_handle_t,
    701 				  bus_size_t,
    702 				  u_int8_t *,
    703 				  bus_size_t));
    704 void bus_space_read_region_2 __P((bus_space_tag_t,
    705 				  bus_space_handle_t,
    706 				  bus_size_t,
    707 				  u_int16_t *,
    708 				  bus_size_t));
    709 void bus_space_read_region_4 __P((bus_space_tag_t,
    710 				  bus_space_handle_t,
    711 				  bus_size_t,
    712 				  u_int32_t *,
    713 				  bus_size_t));
    714 void bus_space_read_region_8 __P((bus_space_tag_t,
    715 				  bus_space_handle_t,
    716 				  bus_size_t,
    717 				  u_int64_t *,
    718 				  bus_size_t));
    719 
    720 extern __inline__ void
    721 bus_space_read_region_1(t, h, o, a, c)
    722 	bus_space_tag_t		t;
    723 	bus_space_handle_t	h;
    724 	bus_size_t		o, c;
    725 	u_int8_t		*a;
    726 {
    727 	for (; c; a++, c--, o++)
    728 		*a = bus_space_read_1(t, h, o);
    729 }
    730 extern __inline__ void
    731 bus_space_read_region_2(t, h, o, a, c)
    732 	bus_space_tag_t		t;
    733 	bus_space_handle_t	h;
    734 	bus_size_t		o, c;
    735 	u_int16_t		*a;
    736 {
    737 	for (; c; a++, c--, o+=2)
    738 		*a = bus_space_read_2(t, h, o);
    739 }
    740 extern __inline__ void
    741 bus_space_read_region_4(t, h, o, a, c)
    742 	bus_space_tag_t		t;
    743 	bus_space_handle_t	h;
    744 	bus_size_t		o, c;
    745 	u_int32_t		*a;
    746 {
    747 	for (; c; a++, c--, o+=4)
    748 		*a = bus_space_read_4(t, h, o);
    749 }
    750 extern __inline__ void
    751 bus_space_read_region_8(t, h, o, a, c)
    752 	bus_space_tag_t		t;
    753 	bus_space_handle_t	h;
    754 	bus_size_t		o, c;
    755 	u_int64_t		*a;
    756 {
    757 	for (; c; a++, c--, o+=8)
    758 		*a = bus_space_read_8(t, h, o);
    759 }
    760 
    761 /*
    762  *	void bus_space_write_region_N __P((bus_space_tag_t tag,
    763  *	    bus_space_handle_t bsh, bus_size_t off,
    764  *	    u_intN_t *addr, bus_size_t count));
    765  *
    766  */
    767 void bus_space_write_region_1 __P((bus_space_tag_t,
    768 				   bus_space_handle_t,
    769 				   bus_size_t,
    770 				   const u_int8_t *,
    771 				   bus_size_t));
    772 void bus_space_write_region_2 __P((bus_space_tag_t,
    773 				   bus_space_handle_t,
    774 				   bus_size_t,
    775 				   const u_int16_t *,
    776 				   bus_size_t));
    777 void bus_space_write_region_4 __P((bus_space_tag_t,
    778 				   bus_space_handle_t,
    779 				   bus_size_t,
    780 				   const u_int32_t *,
    781 				   bus_size_t));
    782 void bus_space_write_region_8 __P((bus_space_tag_t,
    783 				   bus_space_handle_t,
    784 				   bus_size_t,
    785 				   const u_int64_t *,
    786 				   bus_size_t));
    787 extern __inline__ void
    788 bus_space_write_region_1(t, h, o, a, c)
    789 	bus_space_tag_t		t;
    790 	bus_space_handle_t	h;
    791 	bus_size_t		o, c;
    792 	const u_int8_t		*a;
    793 {
    794 	for (; c; a++, c--, o++)
    795 		bus_space_write_1(t, h, o, *a);
    796 }
    797 
    798 extern __inline__ void
    799 bus_space_write_region_2(t, h, o, a, c)
    800 	bus_space_tag_t		t;
    801 	bus_space_handle_t	h;
    802 	bus_size_t		o, c;
    803 	const u_int16_t		*a;
    804 {
    805 	for (; c; a++, c--, o+=2)
    806 		bus_space_write_2(t, h, o, *a);
    807 }
    808 
    809 extern __inline__ void
    810 bus_space_write_region_4(t, h, o, a, c)
    811 	bus_space_tag_t		t;
    812 	bus_space_handle_t	h;
    813 	bus_size_t		o, c;
    814 	const u_int32_t		*a;
    815 {
    816 	for (; c; a++, c--, o+=4)
    817 		bus_space_write_4(t, h, o, *a);
    818 }
    819 
    820 extern __inline__ void
    821 bus_space_write_region_8(t, h, o, a, c)
    822 	bus_space_tag_t		t;
    823 	bus_space_handle_t	h;
    824 	bus_size_t		o, c;
    825 	const u_int64_t		*a;
    826 {
    827 	for (; c; a++, c--, o+=8)
    828 		bus_space_write_8(t, h, o, *a);
    829 }
    830 
    831 
    832 /*
    833  *	void bus_space_set_region_N __P((bus_space_tag_t tag,
    834  *	    bus_space_handle_t bsh, bus_size_t off,
    835  *	    u_intN_t *addr, bus_size_t count));
    836  *
    837  */
    838 void bus_space_set_region_1 __P((bus_space_tag_t,
    839 				 bus_space_handle_t,
    840 				 bus_size_t,
    841 				 const u_int8_t,
    842 				 bus_size_t));
    843 void bus_space_set_region_2 __P((bus_space_tag_t,
    844 				 bus_space_handle_t,
    845 				 bus_size_t,
    846 				 const u_int16_t,
    847 				 bus_size_t));
    848 void bus_space_set_region_4 __P((bus_space_tag_t,
    849 				 bus_space_handle_t,
    850 				 bus_size_t,
    851 				 const u_int32_t,
    852 				 bus_size_t));
    853 void bus_space_set_region_8 __P((bus_space_tag_t,
    854 				 bus_space_handle_t,
    855 				 bus_size_t,
    856 				 const u_int64_t,
    857 				 bus_size_t));
    858 
    859 extern __inline__ void
    860 bus_space_set_region_1(t, h, o, v, c)
    861 	bus_space_tag_t		t;
    862 	bus_space_handle_t	h;
    863 	bus_size_t		o, c;
    864 	const u_int8_t		v;
    865 {
    866 	for (; c; c--, o++)
    867 		bus_space_write_1(t, h, o, v);
    868 }
    869 
    870 extern __inline__ void
    871 bus_space_set_region_2(t, h, o, v, c)
    872 	bus_space_tag_t		t;
    873 	bus_space_handle_t	h;
    874 	bus_size_t		o, c;
    875 	const u_int16_t		v;
    876 {
    877 	for (; c; c--, o+=2)
    878 		bus_space_write_2(t, h, o, v);
    879 }
    880 
    881 extern __inline__ void
    882 bus_space_set_region_4(t, h, o, v, c)
    883 	bus_space_tag_t		t;
    884 	bus_space_handle_t	h;
    885 	bus_size_t		o, c;
    886 	const u_int32_t		v;
    887 {
    888 	for (; c; c--, o+=4)
    889 		bus_space_write_4(t, h, o, v);
    890 }
    891 
    892 extern __inline__ void
    893 bus_space_set_region_8(t, h, o, v, c)
    894 	bus_space_tag_t		t;
    895 	bus_space_handle_t	h;
    896 	bus_size_t		o, c;
    897 	const u_int64_t		v;
    898 {
    899 	for (; c; c--, o+=8)
    900 		bus_space_write_8(t, h, o, v);
    901 }
    902 
    903 
    904 /*
    905  *	void bus_space_copy_region_N __P((bus_space_tag_t tag,
    906  *	    bus_space_handle_t bsh1, bus_size_t off1,
    907  *	    bus_space_handle_t bsh2, bus_size_t off2,
    908  *	    bus_size_t count));
    909  *
    910  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
    911  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
    912  */
    913 void bus_space_copy_region_1 __P((bus_space_tag_t,
    914 				  bus_space_handle_t,
    915 				  bus_size_t,
    916 				  bus_space_handle_t,
    917 				  bus_size_t,
    918 				  bus_size_t));
    919 void bus_space_copy_region_2 __P((bus_space_tag_t,
    920 				  bus_space_handle_t,
    921 				  bus_size_t,
    922 				  bus_space_handle_t,
    923 				  bus_size_t,
    924 				  bus_size_t));
    925 void bus_space_copy_region_4 __P((bus_space_tag_t,
    926 				  bus_space_handle_t,
    927 				  bus_size_t,
    928 				  bus_space_handle_t,
    929 				  bus_size_t,
    930 				  bus_size_t));
    931 void bus_space_copy_region_8 __P((bus_space_tag_t,
    932 				  bus_space_handle_t,
    933 				  bus_size_t,
    934 				  bus_space_handle_t,
    935 				  bus_size_t,
    936 				  bus_size_t));
    937 
    938 
    939 extern __inline__ void
    940 bus_space_copy_region_1(t, h1, o1, h2, o2, c)
    941 	bus_space_tag_t		t;
    942 	bus_space_handle_t	h1, h2;
    943 	bus_size_t		o1, o2;
    944 	bus_size_t		c;
    945 {
    946 	for (; c; c--, o1++, o2++)
    947 	    bus_space_write_1(t, h1, o1, bus_space_read_1(t, h2, o2));
    948 }
    949 
    950 extern __inline__ void
    951 bus_space_copy_region_2(t, h1, o1, h2, o2, c)
    952 	bus_space_tag_t		t;
    953 	bus_space_handle_t	h1, h2;
    954 	bus_size_t		o1, o2;
    955 	bus_size_t		c;
    956 {
    957 	for (; c; c--, o1+=2, o2+=2)
    958 	    bus_space_write_2(t, h1, o1, bus_space_read_2(t, h2, o2));
    959 }
    960 
    961 extern __inline__ void
    962 bus_space_copy_region_4(t, h1, o1, h2, o2, c)
    963 	bus_space_tag_t		t;
    964 	bus_space_handle_t	h1, h2;
    965 	bus_size_t		o1, o2;
    966 	bus_size_t		c;
    967 {
    968 	for (; c; c--, o1+=4, o2+=4)
    969 	    bus_space_write_4(t, h1, o1, bus_space_read_4(t, h2, o2));
    970 }
    971 
    972 extern __inline__ void
    973 bus_space_copy_region_8(t, h1, o1, h2, o2, c)
    974 	bus_space_tag_t		t;
    975 	bus_space_handle_t	h1, h2;
    976 	bus_size_t		o1, o2;
    977 	bus_size_t		c;
    978 {
    979 	for (; c; c--, o1+=8, o2+=8)
    980 	    bus_space_write_8(t, h1, o1, bus_space_read_8(t, h2, o2));
    981 }
    982 
    983 /*
    984  *	void bus_space_copyin __P((bus_space_tag_t tag,
    985  *	    bus_space_handle_t bsh, bus_size_t off,
    986  *	    void *addr, bus_size_t count));
    987  *
    988  * Copy `count' bytes from bus space starting at tag/bsh/off
    989  * to kernel memory at addr using the most optimized transfer
    990  * possible for the bus.
    991  */
    992 
    993 #define	bus_space_copyin(t, h, o, a, c)					\
    994 	    ((void)t, w16copy((u_int8_t *)((h) + (o)), (a), (c)))
    995 
    996 /*
    997  *	void bus_space_copyout __P((bus_space_tag_t tag,
    998  *	    bus_space_handle_t bsh, bus_size_t off,
    999  *	    const void *addr, bus_size_t count));
   1000  *
   1001  * Copy `count' bytes to bus space starting at tag/bsh/off
   1002  * from kernel memory at addr using the most optimized transfer
   1003  * possible for the bus.
   1004  */
   1005 
   1006 #define	bus_space_copyout(t, h, o, a, c)				\
   1007 	    ((void)t, w16copy((a), (u_int8_t *)((h) + (o)), (c)))
   1008 
   1009 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
   1010 
   1011 /*--------------------------------*/
   1012 
   1013 /*
   1014  * Flags used in various bus DMA methods.
   1015  */
   1016 #define	BUS_DMA_WAITOK		0x000	/* safe to sleep (pseudo-flag) */
   1017 #define	BUS_DMA_NOWAIT		0x001	/* not safe to sleep */
   1018 #define	BUS_DMA_ALLOCNOW	0x002	/* perform resource allocation now */
   1019 #define	BUS_DMA_COHERENT	0x004	/* hint: map memory DMA coherent */
   1020 #define	BUS_DMA_BUS1		0x010	/* placeholders for bus functions... */
   1021 #define	BUS_DMA_BUS2		0x020
   1022 #define	BUS_DMA_BUS3		0x040
   1023 #define	BUS_DMA_BUS4		0x080
   1024 #define	BUS_DMA_READ		0x100	/* mapping is device -> memory only */
   1025 #define	BUS_DMA_WRITE		0x200	/* mapping is memory -> device only */
   1026 #define	BUS_DMA_NOCACHE		0x400	/* hint: map non-cached memory */
   1027 
   1028 /* For devices that have a 24-bit address space */
   1029 #define BUS_DMA_24BIT		BUS_DMA_BUS1
   1030 
   1031 /* Internal flag: current DVMA address is equal to the KVA buffer address */
   1032 #define _BUS_DMA_DIRECTMAP	BUS_DMA_BUS2
   1033 
   1034 /*
   1035  * Internal flag: current DVMA address has been double-mapped by hand
   1036  * to the KVA buffer address (without the pmap's help).
   1037  */
   1038 #define	_BUS_DMA_NOPMAP		BUS_DMA_BUS3
   1039 
   1040 /* Forwards needed by prototypes below. */
   1041 struct mbuf;
   1042 struct uio;
   1043 
   1044 /*
   1045  * Operations performed by bus_dmamap_sync().
   1046  */
   1047 #define	BUS_DMASYNC_PREREAD	0x01	/* pre-read synchronization */
   1048 #define	BUS_DMASYNC_POSTREAD	0x02	/* post-read synchronization */
   1049 #define	BUS_DMASYNC_PREWRITE	0x04	/* pre-write synchronization */
   1050 #define	BUS_DMASYNC_POSTWRITE	0x08	/* post-write synchronization */
   1051 
   1052 typedef struct sun68k_bus_dma_tag	*bus_dma_tag_t;
   1053 typedef struct sun68k_bus_dmamap	*bus_dmamap_t;
   1054 
   1055 #define BUS_DMA_TAG_VALID(t)    ((t) != (bus_dma_tag_t)0)
   1056 
   1057 /*
   1058  *	bus_dma_segment_t
   1059  *
   1060  *	Describes a single contiguous DMA transaction.  Values
   1061  *	are suitable for programming into DMA registers.
   1062  */
   1063 struct sun68k_bus_dma_segment {
   1064 	bus_addr_t	ds_addr;	/* DVMA address */
   1065 	bus_size_t	ds_len;		/* length of transfer */
   1066 	bus_size_t	_ds_sgsize;	/* size of allocated DVMA segment */
   1067 	void		*_ds_mlist;	/* page list when dmamem_alloc'ed */
   1068 	vaddr_t		_ds_va;		/* VA when dmamem_map'ed */
   1069 };
   1070 typedef struct sun68k_bus_dma_segment	bus_dma_segment_t;
   1071 
   1072 
   1073 /*
   1074  *	bus_dma_tag_t
   1075  *
   1076  *	A machine-dependent opaque type describing the implementation of
   1077  *	DMA for a given bus.
   1078  */
   1079 struct sun68k_bus_dma_tag {
   1080 	void	*_cookie;		/* cookie used in the guts */
   1081 
   1082 	/*
   1083 	 * DMA mapping methods.
   1084 	 */
   1085 	int	(*_dmamap_create) __P((bus_dma_tag_t, bus_size_t, int,
   1086 		    bus_size_t, bus_size_t, int, bus_dmamap_t *));
   1087 	void	(*_dmamap_destroy) __P((bus_dma_tag_t, bus_dmamap_t));
   1088 	int	(*_dmamap_load) __P((bus_dma_tag_t, bus_dmamap_t, void *,
   1089 		    bus_size_t, struct proc *, int));
   1090 	int	(*_dmamap_load_mbuf) __P((bus_dma_tag_t, bus_dmamap_t,
   1091 		    struct mbuf *, int));
   1092 	int	(*_dmamap_load_uio) __P((bus_dma_tag_t, bus_dmamap_t,
   1093 		    struct uio *, int));
   1094 	int	(*_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t,
   1095 		    bus_dma_segment_t *, int, bus_size_t, int));
   1096 	void	(*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
   1097 	void	(*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
   1098 		    bus_addr_t, bus_size_t, int));
   1099 
   1100 	/*
   1101 	 * DMA memory utility functions.
   1102 	 */
   1103 	int	(*_dmamem_alloc) __P((bus_dma_tag_t, bus_size_t, bus_size_t,
   1104 		    bus_size_t, bus_dma_segment_t *, int, int *, int));
   1105 	void	(*_dmamem_free) __P((bus_dma_tag_t,
   1106 		    bus_dma_segment_t *, int));
   1107 	int	(*_dmamem_map) __P((bus_dma_tag_t, bus_dma_segment_t *,
   1108 		    int, size_t, caddr_t *, int));
   1109 	void	(*_dmamem_unmap) __P((bus_dma_tag_t, caddr_t, size_t));
   1110 	paddr_t	(*_dmamem_mmap) __P((bus_dma_tag_t, bus_dma_segment_t *,
   1111 		    int, off_t, int, int));
   1112 };
   1113 
   1114 #define	bus_dmamap_create(t, s, n, m, b, f, p)			\
   1115 	(*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
   1116 #define	bus_dmamap_destroy(t, p)				\
   1117 	(*(t)->_dmamap_destroy)((t), (p))
   1118 #define	bus_dmamap_load(t, m, b, s, p, f)			\
   1119 	(*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
   1120 #define	bus_dmamap_load_mbuf(t, m, b, f)			\
   1121 	(*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
   1122 #define	bus_dmamap_load_uio(t, m, u, f)				\
   1123 	(*(t)->_dmamap_load_uio)((t), (m), (u), (f))
   1124 #define	bus_dmamap_load_raw(t, m, sg, n, s, f)			\
   1125 	(*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
   1126 #define	bus_dmamap_unload(t, p)					\
   1127 	(*(t)->_dmamap_unload)((t), (p))
   1128 #define	bus_dmamap_sync(t, p, o, l, ops)			\
   1129 	(void)((t)->_dmamap_sync ?				\
   1130 	    (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
   1131 
   1132 #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
   1133 	(*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
   1134 #define	bus_dmamem_free(t, sg, n)				\
   1135 	(*(t)->_dmamem_free)((t), (sg), (n))
   1136 #define	bus_dmamem_map(t, sg, n, s, k, f)			\
   1137 	(*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
   1138 #define	bus_dmamem_unmap(t, k, s)				\
   1139 	(*(t)->_dmamem_unmap)((t), (k), (s))
   1140 #define	bus_dmamem_mmap(t, sg, n, o, p, f)			\
   1141 	(*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
   1142 
   1143 /*
   1144  *	bus_dmamap_t
   1145  *
   1146  *	Describes a DMA mapping.
   1147  */
   1148 struct sun68k_bus_dmamap {
   1149 	/*
   1150 	 * PRIVATE MEMBERS: not for use by machine-independent code.
   1151 	 */
   1152 	bus_size_t	_dm_size;	/* largest DMA transfer mappable */
   1153 	int		_dm_segcnt;	/* number of segs this map can map */
   1154 	bus_size_t	_dm_maxsegsz;	/* largest possible segment */
   1155 	bus_size_t	_dm_boundary;	/* don't cross this */
   1156 	int		_dm_flags;	/* misc. flags */
   1157 
   1158 	void		*_dm_cookie;	/* cookie for bus-specific functions */
   1159 
   1160 	u_long		_dm_align;	/* DVMA alignment; must be a
   1161 					   multiple of the page size */
   1162 	u_long		_dm_ex_start;	/* constraints on DVMA map */
   1163 	u_long		_dm_ex_end;	/* allocations; used by the VME bus
   1164 					   driver and by the IOMMU driver
   1165 					   when mapping 24-bit devices */
   1166 
   1167 	/*
   1168 	 * PUBLIC MEMBERS: these are used by machine-independent code.
   1169 	 */
   1170 	bus_size_t	dm_mapsize;	/* size of the mapping */
   1171 	int		dm_nsegs;	/* # valid segments in mapping */
   1172 	bus_dma_segment_t dm_segs[1];	/* segments; variable length */
   1173 };
   1174 
   1175 #ifdef _SUN68K_BUS_DMA_PRIVATE
   1176 int	_bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t,
   1177 	    bus_size_t, int, bus_dmamap_t *));
   1178 void	_bus_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t));
   1179 int	_bus_dmamap_load_mbuf __P((bus_dma_tag_t, bus_dmamap_t,
   1180 	    struct mbuf *, int));
   1181 int	_bus_dmamap_load_uio __P((bus_dma_tag_t, bus_dmamap_t,
   1182 	    struct uio *, int));
   1183 int	_bus_dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t,
   1184 	    bus_dma_segment_t *, int, bus_size_t, int));
   1185 int	_bus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *,
   1186 				bus_size_t, struct proc *, int));
   1187 void	_bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
   1188 void	_bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
   1189 	    bus_size_t, int));
   1190 
   1191 int	_bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size,
   1192 	    bus_size_t alignment, bus_size_t boundary,
   1193 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags));
   1194 void	_bus_dmamem_free __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
   1195 	    int nsegs));
   1196 int	_bus_dmamem_map __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
   1197 				int nsegs, size_t size, caddr_t *kvap,
   1198 				int flags));
   1199 void	_bus_dmamem_unmap __P((bus_dma_tag_t tag, caddr_t kva,
   1200 	    size_t size));
   1201 paddr_t	_bus_dmamem_mmap __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
   1202 	    int nsegs, off_t off, int prot, int flags));
   1203 
   1204 int	_bus_dmamem_alloc_range __P((bus_dma_tag_t tag, bus_size_t size,
   1205 	    bus_size_t alignment, bus_size_t boundary,
   1206 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
   1207 	    vaddr_t low, vaddr_t high));
   1208 
   1209 vaddr_t	_bus_dma_valloc_skewed(size_t, u_long, u_long, u_long);
   1210 #endif /* _SUN68K_BUS_DMA_PRIVATE */
   1211 
   1212 #endif /* _SUN68K_BUS_H_ */
   1213