Home | History | Annotate | Line # | Download | only in include
bus.h revision 1.7
      1 /*	$NetBSD: bus.h,v 1.7 2006/02/16 20:17:14 perry Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1996, 1997, 1998 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) 1997 Scott Reynolds.  All rights reserved.
     42  *
     43  * Redistribution and use in source and binary forms, with or without
     44  * modification, are permitted provided that the following conditions
     45  * are met:
     46  * 1. Redistributions of source code must retain the above copyright
     47  *    notice, this list of conditions and the following disclaimer.
     48  * 2. Redistributions in binary form must reproduce the above copyright
     49  *    notice, this list of conditions and the following disclaimer in the
     50  *    documentation and/or other materials provided with the distribution.
     51  * 3. The name of the author may not be used to endorse or promote products
     52  *    derived from this software without specific prior written permission
     53  *
     54  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     55  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     56  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     57  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     58  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     59  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     60  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     61  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     62  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     63  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     64  */
     65 
     66 /* bus_space(9) functions for news68k. Just taken from hp300. */
     67 
     68 #ifndef _NEWS68K_BUS_H_
     69 #define _NEWS68K_BUS_H_
     70 
     71 /*
     72  * Values for the news68k bus space tag, not to be used directly by MI code.
     73  */
     74 #define	NEWS68K_BUS_SPACE_INTIO	0	/* space is intio space */
     75 #define	NEWS68K_BUS_SPACE_EIO	1	/* space is eio space */
     76 
     77 /*
     78  * Bus address and size types
     79  */
     80 typedef u_long bus_addr_t;
     81 typedef u_long bus_size_t;
     82 
     83 /*
     84  * Access methods for bus resources and address space.
     85  */
     86 typedef int	bus_space_tag_t;
     87 typedef u_long	bus_space_handle_t;
     88 
     89 /*
     90  *	int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
     91  *	    bus_size_t size, int flags, bus_space_handle_t *bshp);
     92  *
     93  * Map a region of bus space.
     94  */
     95 
     96 #define	BUS_SPACE_MAP_CACHEABLE		0x01
     97 #define	BUS_SPACE_MAP_LINEAR		0x02
     98 #define	BUS_SPACE_MAP_PREFETCHABLE	0x04
     99 
    100 int	bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t,
    101 	    int, bus_space_handle_t *);
    102 
    103 /*
    104  *	void bus_space_unmap(bus_space_tag_t t,
    105  *	    bus_space_handle_t bsh, bus_size_t size);
    106  *
    107  * Unmap a region of bus space.
    108  */
    109 
    110 void	bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
    111 
    112 /*
    113  *	int bus_space_subregion(bus_space_tag_t t,
    114  *	    bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
    115  *	    bus_space_handle_t *nbshp);
    116  *
    117  * Get a new handle for a subregion of an already-mapped area of bus space.
    118  */
    119 
    120 int	bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
    121 	    bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
    122 
    123 /*
    124  *	int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart,
    125  *	    bus_addr_t rend, bus_size_t size, bus_size_t align,
    126  *	    bus_size_t boundary, int flags, bus_addr_t *addrp,
    127  *	    bus_space_handle_t *bshp);
    128  *
    129  * Allocate a region of bus space.
    130  */
    131 
    132 int	bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
    133 	    bus_addr_t rend, bus_size_t size, bus_size_t align,
    134 	    bus_size_t boundary, int cacheable, bus_addr_t *addrp,
    135 	    bus_space_handle_t *bshp);
    136 
    137 /*
    138  *	int bus_space_free(bus_space_tag_t t,
    139  *	    bus_space_handle_t bsh, bus_size_t size);
    140  *
    141  * Free a region of bus space.
    142  */
    143 
    144 void	bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
    145 	    bus_size_t size);
    146 
    147 /*
    148  *	int news68k_bus_space_probe(bus_space_tag_t t,
    149  *	    bus_space_handle_t bsh, bus_size_t offset, int sz);
    150  *
    151  * Probe the bus at t/bsh/offset, using sz as the size of the load.
    152  *
    153  * This is a machine-dependent extension, and is not to be used by
    154  * machine-independent code.
    155  */
    156 
    157 int	news68k_bus_space_probe(bus_space_tag_t t,
    158 	    bus_space_handle_t bsh, bus_size_t offset, int sz);
    159 
    160 /*
    161  *	uintN_t bus_space_read_N(bus_space_tag_t tag,
    162  *	    bus_space_handle_t bsh, bus_size_t offset);
    163  *
    164  * Read a 1, 2, 4, or 8 byte quantity from bus space
    165  * described by tag/handle/offset.
    166  */
    167 
    168 #define	bus_space_read_1(t, h, o)					\
    169     ((void) t, (*(volatile uint8_t *)((h) + (o))))
    170 
    171 #define	bus_space_read_2(t, h, o)					\
    172     ((void) t, (*(volatile uint16_t *)((h) + (o))))
    173 
    174 #define	bus_space_read_4(t, h, o)					\
    175     ((void) t, (*(volatile uint32_t *)((h) + (o))))
    176 
    177 #if 0	/* Cause a link error for bus_space_read_8 */
    178 #define	bus_space_read_8(t, h, o)	!!! bus_space_read_8 unimplemented !!!
    179 #endif
    180 
    181 /*
    182  *	void bus_space_read_multi_N(bus_space_tag_t tag,
    183  *	    bus_space_handle_t bsh, bus_size_t offset,
    184  *	    uintN_t *addr, size_t count);
    185  *
    186  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
    187  * described by tag/handle/offset and copy into buffer provided.
    188  */
    189 
    190 #define	bus_space_read_multi_1(t, h, o, a, c) do {			\
    191 	(void) t;							\
    192 	__asm volatile ("						\
    193 		movl	%0,%%a0					;	\
    194 		movl	%1,%%a1					;	\
    195 		movl	%2,%%d0					;	\
    196 	1:	movb	%%a0@,%%a1@+				;	\
    197 		subql	#1,%%d0					;	\
    198 		jne	1b"					:	\
    199 								:	\
    200 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    201 		    "%a0","%a1","%d0");					\
    202 } while (0)
    203 
    204 #define	bus_space_read_multi_2(t, h, o, a, c) do {			\
    205 	(void) t;							\
    206 	__asm volatile ("						\
    207 		movl	%0,%%a0					;	\
    208 		movl	%1,%%a1					;	\
    209 		movl	%2,%%d0					;	\
    210 	1:	movw	%%a0@,%%a1@+				;	\
    211 		subql	#1,%%d0					;	\
    212 		jne	1b"					:	\
    213 								:	\
    214 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    215 		    "%a0","%a1","%d0");					\
    216 } while (0)
    217 
    218 #define	bus_space_read_multi_4(t, h, o, a, c) do {			\
    219 	(void) t;							\
    220 	__asm volatile ("						\
    221 		movl	%0,%%a0					;	\
    222 		movl	%1,%%a1					;	\
    223 		movl	%2,%%d0					;	\
    224 	1:	movl	%%a0@,%%a1@+				;	\
    225 		subql	#1,%%d0					;	\
    226 		jne	1b"					:	\
    227 								:	\
    228 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    229 		    "%a0","%a1","%d0");					\
    230 } while (0)
    231 
    232 #if 0	/* Cause a link error for bus_space_read_multi_8 */
    233 #define	bus_space_read_multi_8	!!! bus_space_read_multi_8 unimplemented !!!
    234 #endif
    235 
    236 /*
    237  *	void bus_space_read_region_N(bus_space_tag_t tag,
    238  *	    bus_space_handle_t bsh, bus_size_t offset,
    239  *	    uintN_t *addr, size_t count);
    240  *
    241  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
    242  * described by tag/handle and starting at `offset' and copy into
    243  * buffer provided.
    244  */
    245 
    246 #define	bus_space_read_region_1(t, h, o, a, c) do {			\
    247 	(void) t;							\
    248 	__asm volatile ("						\
    249 		movl	%0,%%a0					;	\
    250 		movl	%1,%%a1					;	\
    251 		movl	%2,%%d0					;	\
    252 	1:	movb	%%a0@+,%%a1@+				;	\
    253 		subql	#1,%%d0					;	\
    254 		jne	1b"					:	\
    255 								:	\
    256 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    257 		    "%a0","%a1","%d0");					\
    258 } while (0)
    259 
    260 #define	bus_space_read_region_2(t, h, o, a, c) do {			\
    261 	(void) t;							\
    262 	__asm volatile ("						\
    263 		movl	%0,%%a0					;	\
    264 		movl	%1,%%a1					;	\
    265 		movl	%2,%%d0					;	\
    266 	1:	movw	%%a0@+,%%a1@+				;	\
    267 		subql	#1,%%d0					;	\
    268 		jne	1b"					:	\
    269 								:	\
    270 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    271 		    "%a0","%a1","%d0");					\
    272 } while (0)
    273 
    274 #define	bus_space_read_region_4(t, h, o, a, c) do {			\
    275 	(void) t;							\
    276 	__asm volatile ("						\
    277 		movl	%0,%%a0					;	\
    278 		movl	%1,%%a1					;	\
    279 		movl	%2,%%d0					;	\
    280 	1:	movl	%%a0@+,%%a1@+				;	\
    281 		subql	#1,%%d0					;	\
    282 		jne	1b"					:	\
    283 								:	\
    284 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    285 		    "%a0","%a1","%d0");					\
    286 } while (0)
    287 
    288 #if 0	/* Cause a link error for bus_space_read_region_8 */
    289 #define	bus_space_read_region_8	!!! bus_space_read_region_8 unimplemented !!!
    290 #endif
    291 
    292 /*
    293  *	void bus_space_write_N(bus_space_tag_t tag,
    294  *	    bus_space_handle_t bsh, bus_size_t offset,
    295  *	    uintN_t value);
    296  *
    297  * Write the 1, 2, 4, or 8 byte value `value' to bus space
    298  * described by tag/handle/offset.
    299  */
    300 
    301 #define	bus_space_write_1(t, h, o, v)					\
    302     ((void) t, ((void)(*(volatile uint8_t *)((h) + (o)) = (v))))
    303 
    304 #define	bus_space_write_2(t, h, o, v)					\
    305     ((void) t, ((void)(*(volatile uint16_t *)((h) + (o)) = (v))))
    306 
    307 #define	bus_space_write_4(t, h, o, v)					\
    308     ((void) t, ((void)(*(volatile uint32_t *)((h) + (o)) = (v))))
    309 
    310 #if 0	/* Cause a link error for bus_space_write_8 */
    311 #define	bus_space_write_8	!!! bus_space_write_8 not implemented !!!
    312 #endif
    313 
    314 /*
    315  *	void bus_space_write_multi_N(bus_space_tag_t tag,
    316  *	    bus_space_handle_t bsh, bus_size_t offset,
    317  *	    const uintN_t *addr, size_t count);
    318  *
    319  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
    320  * provided to bus space described by tag/handle/offset.
    321  */
    322 
    323 #define	bus_space_write_multi_1(t, h, o, a, c) do {			\
    324 	(void) t;							\
    325 	__asm volatile ("						\
    326 		movl	%0,%%a0					;	\
    327 		movl	%1,%%a1					;	\
    328 		movl	%2,%%d0					;	\
    329 	1:	movb	%%a1@+,%%a0@				;	\
    330 		subql	#1,%%d0					;	\
    331 		jne	1b"					:	\
    332 								:	\
    333 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    334 		    "%a0","%a1","%d0");					\
    335 } while (0)
    336 
    337 #define	bus_space_write_multi_2(t, h, o, a, c) do {			\
    338 	(void) t;							\
    339 	__asm volatile ("						\
    340 		movl	%0,%%a0					;	\
    341 		movl	%1,%%a1					;	\
    342 		movl	%2,%%d0					;	\
    343 	1:	movw	%%a1@+,%%a0@				;	\
    344 		subql	#1,%%d0					;	\
    345 		jne	1b"					:	\
    346 								:	\
    347 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    348 		    "%a0","%a1","%d0");					\
    349 } while (0)
    350 
    351 #define	bus_space_write_multi_4(t, h, o, a, c) do {			\
    352 	(void) t;							\
    353 	__asm volatile ("						\
    354 		movl	%0,%%a0					;	\
    355 		movl	%1,%%a1					;	\
    356 		movl	%2,%%d0					;	\
    357 	1:	movl	%%a1@+,%%a0@				;	\
    358 		subql	#1,%%d0					;	\
    359 		jne	1b"					:	\
    360 								:	\
    361 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    362 		    "%a0","%a1","%d0");					\
    363 } while (0)
    364 
    365 #if 0	/* Cause a link error for bus_space_write_8 */
    366 #define	bus_space_write_multi_8(t, h, o, a, c)				\
    367 			!!! bus_space_write_multi_8 unimplimented !!!
    368 #endif
    369 
    370 /*
    371  *	void bus_space_write_region_N(bus_space_tag_t tag,
    372  *	    bus_space_handle_t bsh, bus_size_t offset,
    373  *	    const uintN_t *addr, size_t count);
    374  *
    375  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
    376  * to bus space described by tag/handle starting at `offset'.
    377  */
    378 
    379 #define	bus_space_write_region_1(t, h, o, a, c) do {			\
    380 	(void) t;							\
    381 	__asm volatile ("						\
    382 		movl	%0,%%a0					;	\
    383 		movl	%1,%%a1					;	\
    384 		movl	%2,%%d0					;	\
    385 	1:	movb	%%a1@+,%%a0@+				;	\
    386 		subql	#1,%%d0					;	\
    387 		jne	1b"					:	\
    388 								:	\
    389 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    390 		    "%a0","%a1","%d0");					\
    391 } while (0)
    392 
    393 #define	bus_space_write_region_2(t, h, o, a, c) do {			\
    394 	(void) t;							\
    395 	__asm volatile ("						\
    396 		movl	%0,%%a0					;	\
    397 		movl	%1,%%a1					;	\
    398 		movl	%2,%%d0					;	\
    399 	1:	movw	%%a1@+,%%a0@+				;	\
    400 		subql	#1,%%d0					;	\
    401 		jne	1b"					:	\
    402 								:	\
    403 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    404 		    "%a0","%a1","%d0");					\
    405 } while (0)
    406 
    407 #define	bus_space_write_region_4(t, h, o, a, c) do {			\
    408 	(void) t;							\
    409 	__asm volatile ("						\
    410 		movl	%0,%%a0					;	\
    411 		movl	%1,%%a1					;	\
    412 		movl	%2,%%d0					;	\
    413 	1:	movl	%%a1@+,%%a0@+				;	\
    414 		subql	#1,%%d0					;	\
    415 		jne	1b"					:	\
    416 								:	\
    417 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    418 		    "%a0","%a1","%d0");					\
    419 } while (0)
    420 
    421 #if 0	/* Cause a link error for bus_space_write_region_8 */
    422 #define	bus_space_write_region_8					\
    423 			!!! bus_space_write_region_8 unimplemented !!!
    424 #endif
    425 
    426 /*
    427  *	void bus_space_set_multi_N(bus_space_tag_t tag,
    428  *	    bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
    429  *	    size_t count);
    430  *
    431  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
    432  * by tag/handle/offset `count' times.
    433  */
    434 
    435 #define	bus_space_set_multi_1(t, h, o, val, c) do {			\
    436 	(void) t;							\
    437 	__asm volatile ("						\
    438 		movl	%0,%%a0					;	\
    439 		movl	%1,%%d1					;	\
    440 		movl	%2,%%d0					;	\
    441 	1:	movb	%%d1,%%a0@				;	\
    442 		subql	#1,%%d0					;	\
    443 		jne	1b"					:	\
    444 								:	\
    445 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    446 		    "%a0","%d0","%d1");					\
    447 } while (0)
    448 
    449 #define	bus_space_set_multi_2(t, h, o, val, c) do {			\
    450 	(void) t;							\
    451 	__asm volatile ("						\
    452 		movl	%0,%%a0					;	\
    453 		movl	%1,%%d1					;	\
    454 		movl	%2,%%d0					;	\
    455 	1:	movw	%%d1,%%a0@				;	\
    456 		subql	#1,%%d0					;	\
    457 		jne	1b"					:	\
    458 								:	\
    459 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    460 		    "%a0","%d0","%d1");					\
    461 } while (0)
    462 
    463 #define	bus_space_set_multi_4(t, h, o, val, c) do {			\
    464 	(void) t;							\
    465 	__asm volatile ("						\
    466 		movl	%0,%%a0					;	\
    467 		movl	%1,%%d1					;	\
    468 		movl	%2,%%d0					;	\
    469 	1:	movl	%%d1,%%a0@				;	\
    470 		subql	#1,%%d0					;	\
    471 		jne	1b"					:	\
    472 								:	\
    473 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    474 		    "%a0","%d0","%d1");					\
    475 } while (0)
    476 
    477 #if 0	/* Cause a link error for bus_space_set_multi_8 */
    478 #define	bus_space_set_multi_8						\
    479 			!!! bus_space_set_multi_8 unimplemented !!!
    480 #endif
    481 
    482 /*
    483  *	void bus_space_set_region_N(bus_space_tag_t tag,
    484  *	    bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
    485  *	    size_t count);
    486  *
    487  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
    488  * by tag/handle starting at `offset'.
    489  */
    490 
    491 #define	bus_space_set_region_1(t, h, o, val, c) do {			\
    492 	(void) t;							\
    493 	__asm volatile ("						\
    494 		movl	%0,%%a0					;	\
    495 		movl	%1,%%d1					;	\
    496 		movl	%2,%%d0					;	\
    497 	1:	movb	%%d1,%%a0@+				;	\
    498 		subql	#1,%%d0					;	\
    499 		jne	1b"					:	\
    500 								:	\
    501 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    502 		    "%a0","%d0","%d1");					\
    503 } while (0)
    504 
    505 #define	bus_space_set_region_2(t, h, o, val, c) do {			\
    506 	(void) t;							\
    507 	__asm volatile ("						\
    508 		movl	%0,%%a0					;	\
    509 		movl	%1,%%d1					;	\
    510 		movl	%2,%%d0					;	\
    511 	1:	movw	%%d1,%%a0@+				;	\
    512 		subql	#1,%%d0					;	\
    513 		jne	1b"					:	\
    514 								:	\
    515 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    516 		    "%a0","%d0","%d1");					\
    517 } while (0)
    518 
    519 #define	bus_space_set_region_4(t, h, o, val, c) do {			\
    520 	(void) t;							\
    521 	__asm volatile ("						\
    522 		movl	%0,%%a0					;	\
    523 		movl	%1,%%d1					;	\
    524 		movl	%2,%%d0					;	\
    525 	1:	movl	%%d1,%%a0@+				;	\
    526 		subql	#1,%%d0					;	\
    527 		jne	1b"					:	\
    528 								:	\
    529 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    530 		    "%a0","%d0","%d1");					\
    531 } while (0)
    532 
    533 #if 0	/* Cause a link error for bus_space_set_region_8 */
    534 #define	bus_space_set_region_8						\
    535 			!!! bus_space_set_region_8 unimplemented !!!
    536 #endif
    537 
    538 /*
    539  *	void bus_space_copy_region_N(bus_space_tag_t tag,
    540  *	    bus_space_handle_t bsh1, bus_size_t off1,
    541  *	    bus_space_handle_t bsh2, bus_size_t off2,
    542  *	    bus_size_t count);
    543  *
    544  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
    545  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
    546  */
    547 
    548 #define	__NEWS68K_copy_region_N(BYTES)					\
    549 static __inline void __CONCAT(bus_space_copy_region_,BYTES)		\
    550 	(bus_space_tag_t,						\
    551 	 bus_space_handle_t bsh1, bus_size_t off1,			\
    552 	 bus_space_handle_t bsh2, bus_size_t off2,			\
    553 	 bus_size_t count);						\
    554 									\
    555 static __inline void							\
    556 __CONCAT(bus_space_copy_region_,BYTES)(bus_space_tag_t t,		\
    557     bus_space_handle_t h1, bus_space_handle_t h2,			\
    558     bus_size_t o1, bus_size_t o2, bus_size_t c)				\
    559 {									\
    560 	bus_size_t o;							\
    561 									\
    562 	if ((h1 + o1) >= (h2 + o2)) {					\
    563 		/* src after dest: copy forward */			\
    564 		for (o = 0; c != 0; c--, o += BYTES)			\
    565 			__CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o,	\
    566 			    __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
    567 	} else {							\
    568 		/* dest after src: copy backwards */			\
    569 		for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES)	\
    570 			__CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o,	\
    571 			    __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
    572 	}								\
    573 }
    574 __NEWS68K_copy_region_N(1)
    575 __NEWS68K_copy_region_N(2)
    576 __NEWS68K_copy_region_N(4)
    577 #if 0	/* Cause a link error for bus_space_copy_region_8 */
    578 #define	bus_space_copy_region_8						\
    579 			!!! bus_space_copy_region_8 unimplemented !!!
    580 #endif
    581 
    582 #undef __NEWS68K_copy_region_N
    583 
    584 /*
    585  * Bus read/write barrier methods.
    586  *
    587  *	void bus_space_barrier(bus_space_tag_t tag,
    588  *	    bus_space_handle_t bsh, bus_size_t offset,
    589  *	    bus_size_t len, int flags);
    590  *
    591  * Note: the 680x0 does not currently require barriers, but we must
    592  * provide the flags to MI code.
    593  */
    594 #define	bus_space_barrier(t, h, o, l, f)	\
    595 	((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
    596 #define	BUS_SPACE_BARRIER_READ	0x01		/* force read barrier */
    597 #define	BUS_SPACE_BARRIER_WRITE	0x02		/* force write barrier */
    598 
    599 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
    600 
    601 #endif /* _NEWS68K_BUS_H_ */
    602