Home | History | Annotate | Line # | Download | only in include
bus.h revision 1.1
      1 /*	$NetBSD: bus.h,v 1.1 1998/01/11 21:26:04 thorpej 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 #ifndef _HP300_BUS_H_
     67 #define _HP300_BUS_H_
     68 
     69 /*
     70  * Values for the hp300 bus space tag, not to be used directly by MI code.
     71  */
     72 #define	HP300_BUS_SPACE_INTIO	0	/* space is intio space */
     73 #define	HP300_BUS_SPACE_DIO	1	/* space is dio space */
     74 
     75 /*
     76  * Bus address and size types
     77  */
     78 typedef u_long bus_addr_t;
     79 typedef u_long bus_size_t;
     80 
     81 /*
     82  * Access methods for bus resources and address space.
     83  */
     84 typedef int	bus_space_tag_t;
     85 typedef u_long	bus_space_handle_t;
     86 
     87 /*
     88  *	int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr,
     89  *	    bus_size_t size, int flags, bus_space_handle_t *bshp));
     90  *
     91  * Map a region of bus space.
     92  */
     93 
     94 #define	BUS_SPACE_MAP_CACHEABLE		0x01
     95 #define	BUS_SPACE_MAP_LINEAR		0x02
     96 
     97 int	bus_space_map __P((bus_space_tag_t, bus_addr_t, bus_size_t,
     98 	    int, bus_space_handle_t *));
     99 
    100 /*
    101  *	void bus_space_unmap __P((bus_space_tag_t t,
    102  *	    bus_space_handle_t bsh, bus_size_t size));
    103  *
    104  * Unmap a region of bus space.
    105  */
    106 
    107 void	bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
    108 
    109 /*
    110  *	int bus_space_subregion __P((bus_space_tag_t t,
    111  *	    bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
    112  *	    bus_space_handle_t *nbshp));
    113  *
    114  * Get a new handle for a subregion of an already-mapped area of bus space.
    115  */
    116 
    117 int	bus_space_subregion __P((bus_space_tag_t t, bus_space_handle_t bsh,
    118 	    bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp));
    119 
    120 /*
    121  *	int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t, rstart,
    122  *	    bus_addr_t rend, bus_size_t size, bus_size_t align,
    123  *	    bus_size_t boundary, int flags, bus_addr_t *addrp,
    124  *	    bus_space_handle_t *bshp));
    125  *
    126  * Allocate a region of bus space.
    127  */
    128 
    129 int	bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
    130 	    bus_addr_t rend, bus_size_t size, bus_size_t align,
    131 	    bus_size_t boundary, int cacheable, bus_addr_t *addrp,
    132 	    bus_space_handle_t *bshp));
    133 
    134 /*
    135  *	int bus_space_free __P((bus_space_tag_t t,
    136  *	    bus_space_handle_t bsh, bus_size_t size));
    137  *
    138  * Free a region of bus space.
    139  */
    140 
    141 void	bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
    142 	    bus_size_t size));
    143 
    144 /*
    145  *	int hp300_bus_space_probe __P((bus_space_tag_t t,
    146  *	    bus_space_handle_t bsh, bus_size_t offset, int sz));
    147  *
    148  * Probe the bus at t/bsh/offset, using sz as the size of the load.
    149  *
    150  * This is a machine-dependent extension, and is not to be used by
    151  * machine-independent code.
    152  */
    153 
    154 int	hp300_bus_space_probe __P((bus_space_tag_t t,
    155 	    bus_space_handle_t bsh, bus_size_t offset, int sz));
    156 
    157 /*
    158  *	u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
    159  *	    bus_space_handle_t bsh, bus_size_t offset));
    160  *
    161  * Read a 1, 2, 4, or 8 byte quantity from bus space
    162  * described by tag/handle/offset.
    163  */
    164 
    165 #define	bus_space_read_1(t, h, o)					\
    166     ((void) t, (*(volatile u_int8_t *)((h) + (o))))
    167 
    168 #define	bus_space_read_2(t, h, o)					\
    169     ((void) t, (*(volatile u_int16_t *)((h) + (o))))
    170 
    171 #define	bus_space_read_4(t, h, o)					\
    172     ((void) t, (*(volatile u_int32_t *)((h) + (o))))
    173 
    174 #if 0	/* Cause a link error for bus_space_read_8 */
    175 #define	bus_space_read_8(t, h, o)	!!! bus_space_read_8 unimplemented !!!
    176 #endif
    177 
    178 /*
    179  *	void bus_space_read_multi_N __P((bus_space_tag_t tag,
    180  *	    bus_space_handle_t bsh, bus_size_t offset,
    181  *	    u_intN_t *addr, size_t count));
    182  *
    183  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
    184  * described by tag/handle/offset and copy into buffer provided.
    185  */
    186 
    187 #define	bus_space_read_multi_1(t, h, o, a, c) do {			\
    188 	(void) t;							\
    189 	__asm __volatile ("						\
    190 		movl	%0,a0					;	\
    191 		movl	%1,a1					;	\
    192 		movl	%2,d0					;	\
    193 	1:	movb	a0@,a1@+				;	\
    194 		subql	#1,d0					;	\
    195 		jne	1b"					:	\
    196 								:	\
    197 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    198 		    "a0","a1","d0");					\
    199 } while (0)
    200 
    201 #define	bus_space_read_multi_2(t, h, o, a, c) do {			\
    202 	(void) t;							\
    203 	__asm __volatile ("						\
    204 		movl	%0,a0					;	\
    205 		movl	%1,a1					;	\
    206 		movl	%2,d0					;	\
    207 	1:	movw	a0@,a1@+				;	\
    208 		subql	#1,d0					;	\
    209 		jne	1b"					:	\
    210 								:	\
    211 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    212 		    "a0","a1","d0");					\
    213 } while (0)
    214 
    215 #define	bus_space_read_multi_4(t, h, o, a, c) do {			\
    216 	(void) t;							\
    217 	__asm __volatile ("						\
    218 		movl	%0,a0					;	\
    219 		movl	%1,a1					;	\
    220 		movl	%2,d0					;	\
    221 	1:	movl	a0@,a1@+				;	\
    222 		subql	#1,d0					;	\
    223 		jne	1b"					:	\
    224 								:	\
    225 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    226 		    "a0","a1","d0");					\
    227 } while (0)
    228 
    229 #if 0	/* Cause a link error for bus_space_read_multi_8 */
    230 #define	bus_space_read_multi_8	!!! bus_space_read_multi_8 unimplemented !!!
    231 #endif
    232 
    233 /*
    234  *	void bus_space_read_region_N __P((bus_space_tag_t tag,
    235  *	    bus_space_handle_t bsh, bus_size_t offset,
    236  *	    u_intN_t *addr, size_t count));
    237  *
    238  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
    239  * described by tag/handle and starting at `offset' and copy into
    240  * buffer provided.
    241  */
    242 
    243 #define	bus_space_read_region_1(t, h, o, a, c) do {			\
    244 	(void) t;							\
    245 	__asm __volatile ("						\
    246 		movl	%0,a0					;	\
    247 		movl	%1,a1					;	\
    248 		movl	%2,d0					;	\
    249 	1:	movb	a0@+,a1@+				;	\
    250 		subql	#1,d0					;	\
    251 		jne	1b"					:	\
    252 								:	\
    253 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    254 		    "a0","a1","d0");					\
    255 } while (0)
    256 
    257 #define	bus_space_read_region_2(t, h, o, a, c) do {			\
    258 	(void) t;							\
    259 	__asm __volatile ("						\
    260 		movl	%0,a0					;	\
    261 		movl	%1,a1					;	\
    262 		movl	%2,d0					;	\
    263 	1:	movw	a0@+,a1@+				;	\
    264 		subql	#1,d0					;	\
    265 		jne	1b"					:	\
    266 								:	\
    267 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    268 		    "a0","a1","d0");					\
    269 } while (0)
    270 
    271 #define	bus_space_read_region_4(t, h, o, a, c) do {			\
    272 	(void) t;							\
    273 	__asm __volatile ("						\
    274 		movl	%0,a0					;	\
    275 		movl	%1,a1					;	\
    276 		movl	%2,d0					;	\
    277 	1:	movl	a0@+,a1@+				;	\
    278 		subql	#1,d0					;	\
    279 		jne	1b"					:	\
    280 								:	\
    281 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    282 		    "a0","a1","d0");					\
    283 } while (0)
    284 
    285 #if 0	/* Cause a link error for bus_space_read_region_8 */
    286 #define	bus_space_read_region_8	!!! bus_space_read_region_8 unimplemented !!!
    287 #endif
    288 
    289 /*
    290  *	void bus_space_write_N __P((bus_space_tag_t tag,
    291  *	    bus_space_handle_t bsh, bus_size_t offset,
    292  *	    u_intN_t value));
    293  *
    294  * Write the 1, 2, 4, or 8 byte value `value' to bus space
    295  * described by tag/handle/offset.
    296  */
    297 
    298 #define	bus_space_write_1(t, h, o, v)					\
    299     ((void) t, ((void)(*(volatile u_int8_t *)((h) + (o)) = (v))))
    300 
    301 #define	bus_space_write_2(t, h, o, v)					\
    302     ((void) t, ((void)(*(volatile u_int16_t *)((h) + (o)) = (v))))
    303 
    304 #define	bus_space_write_4(t, h, o, v)					\
    305     ((void) t, ((void)(*(volatile u_int32_t *)((h) + (o)) = (v))))
    306 
    307 #if 0	/* Cause a link error for bus_space_write_8 */
    308 #define	bus_space_write_8	!!! bus_space_write_8 not implemented !!!
    309 #endif
    310 
    311 /*
    312  *	void bus_space_write_multi_N __P((bus_space_tag_t tag,
    313  *	    bus_space_handle_t bsh, bus_size_t offset,
    314  *	    const u_intN_t *addr, size_t count));
    315  *
    316  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
    317  * provided to bus space described by tag/handle/offset.
    318  */
    319 
    320 #define	bus_space_write_multi_1(t, h, o, a, c) do {			\
    321 	(void) t;							\
    322 	__asm __volatile ("						\
    323 		movl	%0,a0					;	\
    324 		movl	%1,a1					;	\
    325 		movl	%2,d0					;	\
    326 	1:	movb	a1@+,a0@				;	\
    327 		subql	#1,d0					;	\
    328 		jne	1b"					:	\
    329 								:	\
    330 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    331 		    "a0","a1","d0");					\
    332 } while (0)
    333 
    334 #define	bus_space_write_multi_2(t, h, o, a, c) do {			\
    335 	(void) t;							\
    336 	__asm __volatile ("						\
    337 		movl	%0,a0					;	\
    338 		movl	%1,a1					;	\
    339 		movl	%2,d0					;	\
    340 	1:	movw	a1@+,a0@				;	\
    341 		subql	#1,d0					;	\
    342 		jne	1b"					:	\
    343 								:	\
    344 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    345 		    "a0","a1","d0");					\
    346 } while (0)
    347 
    348 #define	bus_space_write_multi_4(t, h, o, a, c) do {			\
    349 	(void) t;							\
    350 	__asm __volatile ("						\
    351 		movl	%0,a0					;	\
    352 		movl	%1,a1					;	\
    353 		movl	%2,d0					;	\
    354 	1:	movl	a1@+,a0@				;	\
    355 		subql	#1,d0					;	\
    356 		jne	1b"					:	\
    357 								:	\
    358 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    359 		    "a0","a1","d0");					\
    360 } while (0)
    361 
    362 #if 0	/* Cause a link error for bus_space_write_8 */
    363 #define	bus_space_write_multi_8(t, h, o, a, c)				\
    364 			!!! bus_space_write_multi_8 unimplimented !!!
    365 #endif
    366 
    367 /*
    368  *	void bus_space_write_region_N __P((bus_space_tag_t tag,
    369  *	    bus_space_handle_t bsh, bus_size_t offset,
    370  *	    const u_intN_t *addr, size_t count));
    371  *
    372  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
    373  * to bus space described by tag/handle starting at `offset'.
    374  */
    375 
    376 #define	bus_space_write_region_1(t, h, o, a, c) do {			\
    377 	(void) t;							\
    378 	__asm __volatile ("						\
    379 		movl	%0,a0					;	\
    380 		movl	%1,a1					;	\
    381 		movl	%2,d0					;	\
    382 	1:	movb	a1@+,a0@+				;	\
    383 		subql	#1,d0					;	\
    384 		jne	1b"					:	\
    385 								:	\
    386 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    387 		    "a0","a1","d0");					\
    388 } while (0)
    389 
    390 #define	bus_space_write_region_2(t, h, o, a, c) do {			\
    391 	(void) t;							\
    392 	__asm __volatile ("						\
    393 		movl	%0,a0					;	\
    394 		movl	%1,a1					;	\
    395 		movl	%2,d0					;	\
    396 	1:	movw	a1@+,a0@+				;	\
    397 		subql	#1,d0					;	\
    398 		jne	1b"					:	\
    399 								:	\
    400 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    401 		    "a0","a1","d0");					\
    402 } while (0)
    403 
    404 #define	bus_space_write_region_4(t, h, o, a, c) do {			\
    405 	(void) t;							\
    406 	__asm __volatile ("						\
    407 		movl	%0,a0					;	\
    408 		movl	%1,a1					;	\
    409 		movl	%2,d0					;	\
    410 	1:	movl	a1@+,a0@+				;	\
    411 		subql	#1,d0					;	\
    412 		jne	1b"					:	\
    413 								:	\
    414 		    "r" ((h) + (o)), "g" (a), "g" (c)		:	\
    415 		    "a0","a1","d0");					\
    416 } while (0)
    417 
    418 #if 0	/* Cause a link error for bus_space_write_region_8 */
    419 #define	bus_space_write_region_8					\
    420 			!!! bus_space_write_region_8 unimplemented !!!
    421 #endif
    422 
    423 /*
    424  *	void bus_space_set_multi_N __P((bus_space_tag_t tag,
    425  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
    426  *	    size_t count));
    427  *
    428  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
    429  * by tag/handle/offset `count' times.
    430  */
    431 
    432 #define	bus_space_set_multi_1(t, h, o, val, c) do {			\
    433 	(void) t;							\
    434 	__asm __volatile ("						\
    435 		movl	%0,a0					;	\
    436 		movl	%1,d1					;	\
    437 		movl	%2,d0					;	\
    438 	1:	movb	d1,a0@					;	\
    439 		subql	#1,d0					;	\
    440 		jne	1b"					:	\
    441 								:	\
    442 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    443 		    "a0","d0","d1");					\
    444 } while (0)
    445 
    446 #define	bus_space_set_multi_2(t, h, o, val, c) do {			\
    447 	(void) t;							\
    448 	__asm __volatile ("						\
    449 		movl	%0,a0					;	\
    450 		movl	%1,d1					;	\
    451 		movl	%2,d0					;	\
    452 	1:	movw	d1,a0@					;	\
    453 		subql	#1,d0					;	\
    454 		jne	1b"					:	\
    455 								:	\
    456 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    457 		    "a0","d0","d1");					\
    458 } while (0)
    459 
    460 #define	bus_space_set_multi_4(t, h, o, val, c) do {			\
    461 	(void) t;							\
    462 	__asm __volatile ("						\
    463 		movl	%0,a0					;	\
    464 		movl	%1,d1					;	\
    465 		movl	%2,d0					;	\
    466 	1:	movl	d1,a0@					;	\
    467 		subql	#1,d0					;	\
    468 		jne	1b"					:	\
    469 								:	\
    470 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    471 		    "a0","d0","d1");					\
    472 } while (0)
    473 
    474 #if 0	/* Cause a link error for bus_space_set_multi_8 */
    475 #define	bus_space_set_multi_8						\
    476 			!!! bus_space_set_multi_8 unimplemented !!!
    477 #endif
    478 
    479 /*
    480  *	void bus_space_set_region_N __P((bus_space_tag_t tag,
    481  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
    482  *	    size_t count));
    483  *
    484  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
    485  * by tag/handle starting at `offset'.
    486  */
    487 
    488 #define	bus_space_set_region_1(t, h, o, val, c) do {			\
    489 	(void) t;							\
    490 	__asm __volatile ("						\
    491 		movl	%0,a0					;	\
    492 		movl	%1,d1					;	\
    493 		movl	%2,d0					;	\
    494 	1:	movb	d1,a0@+					;	\
    495 		subql	#1,d0					;	\
    496 		jne	1b"					:	\
    497 								:	\
    498 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    499 		    "a0","d0","d1");					\
    500 } while (0)
    501 
    502 #define	bus_space_set_region_2(t, h, o, val, c) do {			\
    503 	(void) t;							\
    504 	__asm __volatile ("						\
    505 		movl	%0,a0					;	\
    506 		movl	%1,d1					;	\
    507 		movl	%2,d0					;	\
    508 	1:	movw	d1,a0@+					;	\
    509 		subql	#1,d0					;	\
    510 		jne	1b"					:	\
    511 								:	\
    512 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    513 		    "a0","d0","d1");					\
    514 } while (0)
    515 
    516 #define	bus_space_set_region_4(t, h, o, val, c) do {			\
    517 	(void) t;							\
    518 	__asm __volatile ("						\
    519 		movl	%0,a0					;	\
    520 		movl	%1,d1					;	\
    521 		movl	%2,d0					;	\
    522 	1:	movl	d1,a0@+					;	\
    523 		subql	#1,d0					;	\
    524 		jne	1b"					:	\
    525 								:	\
    526 		    "r" ((h) + (o)), "g" (val), "g" (c)		:	\
    527 		    "a0","d0","d1");					\
    528 } while (0)
    529 
    530 #if 0	/* Cause a link error for bus_space_set_region_8 */
    531 #define	bus_space_set_region_8						\
    532 			!!! bus_space_set_region_8 unimplemented !!!
    533 #endif
    534 
    535 /*
    536  *	void bus_space_copy_region_N __P((bus_space_tag_t tag,
    537  *	    bus_space_handle_t bsh1, bus_size_t off1,
    538  *	    bus_space_handle_t bsh2, bus_size_t off2,
    539  *	    bus_size_t count));
    540  *
    541  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
    542  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
    543  */
    544 
    545 #define	__HP300_copy_region_N(BYTES)					\
    546 static __inline void __CONCAT(bus_space_copy_region_,BYTES)		\
    547 	__P((bus_space_tag_t,						\
    548 	    bus_space_handle_t bsh1, bus_size_t off1,			\
    549 	    bus_space_handle_t bsh2, bus_size_t off2,			\
    550 	    bus_size_t count));						\
    551 									\
    552 static __inline void							\
    553 __CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c)		\
    554 	bus_space_tag_t t;						\
    555 	bus_space_handle_t h1, h2;					\
    556 	bus_size_t o1, o2, c;						\
    557 {									\
    558 	bus_size_t o;							\
    559 									\
    560 	if ((h1 + o1) >= (h2 + o2)) {					\
    561 		/* src after dest: copy forward */			\
    562 		for (o = 0; c != 0; c--, o += BYTES)			\
    563 			__CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o,	\
    564 			    __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
    565 	} else {							\
    566 		/* dest after src: copy backwards */			\
    567 		for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES)	\
    568 			__CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o,	\
    569 			    __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
    570 	}								\
    571 }
    572 __HP300_copy_region_N(1)
    573 __HP300_copy_region_N(2)
    574 __HP300_copy_region_N(4)
    575 #if 0	/* Cause a link error for bus_space_copy_region_8 */
    576 #define	bus_space_copy_region_8						\
    577 			!!! bus_space_copy_region_8 unimplemented !!!
    578 #endif
    579 
    580 #undef __HP300_copy_region_N
    581 
    582 /*
    583  * Bus read/write barrier methods.
    584  *
    585  *	void bus_space_barrier __P((bus_space_tag_t tag,
    586  *	    bus_space_handle_t bsh, bus_size_t offset,
    587  *	    bus_size_t len, int flags));
    588  *
    589  * Note: the 680x0 does not currently require barriers, but we must
    590  * provide the flags to MI code.
    591  */
    592 #define	bus_space_barrier(t, h, o, l, f)	\
    593 	((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
    594 #define	BUS_SPACE_BARRIER_READ	0x01		/* force read barrier */
    595 #define	BUS_SPACE_BARRIER_WRITE	0x02		/* force write barrier */
    596 
    597 #endif /* _HP300_BUS_H_ */
    598