Home | History | Annotate | Line # | Download | only in include
bus.h revision 1.9
      1  1.9   thorpej /*	$NetBSD: bus.h,v 1.9 2004/08/28 19:46:41 thorpej Exp $	*/
      2  1.1   thorpej 
      3  1.1   thorpej /*-
      4  1.1   thorpej  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
      5  1.1   thorpej  * All rights reserved.
      6  1.1   thorpej  *
      7  1.1   thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1   thorpej  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  1.1   thorpej  * NASA Ames Research Center.
     10  1.1   thorpej  *
     11  1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     12  1.1   thorpej  * modification, are permitted provided that the following conditions
     13  1.1   thorpej  * are met:
     14  1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     15  1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     16  1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     18  1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     19  1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     20  1.1   thorpej  *    must display the following acknowledgement:
     21  1.1   thorpej  *	This product includes software developed by the NetBSD
     22  1.1   thorpej  *	Foundation, Inc. and its contributors.
     23  1.1   thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24  1.1   thorpej  *    contributors may be used to endorse or promote products derived
     25  1.1   thorpej  *    from this software without specific prior written permission.
     26  1.1   thorpej  *
     27  1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28  1.1   thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29  1.1   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30  1.1   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31  1.1   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32  1.1   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33  1.1   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34  1.1   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35  1.1   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36  1.1   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37  1.1   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     38  1.1   thorpej  */
     39  1.1   thorpej 
     40  1.1   thorpej /*
     41  1.1   thorpej  * Copyright (C) 1997 Scott Reynolds.  All rights reserved.
     42  1.1   thorpej  *
     43  1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     44  1.1   thorpej  * modification, are permitted provided that the following conditions
     45  1.1   thorpej  * are met:
     46  1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     47  1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     48  1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     49  1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     50  1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     51  1.1   thorpej  * 3. The name of the author may not be used to endorse or promote products
     52  1.1   thorpej  *    derived from this software without specific prior written permission
     53  1.1   thorpej  *
     54  1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     55  1.1   thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     56  1.1   thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     57  1.1   thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     58  1.1   thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     59  1.1   thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     60  1.1   thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     61  1.1   thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     62  1.1   thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     63  1.1   thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     64  1.1   thorpej  */
     65  1.1   thorpej 
     66  1.1   thorpej #ifndef _HP300_BUS_H_
     67  1.1   thorpej #define _HP300_BUS_H_
     68  1.1   thorpej 
     69  1.1   thorpej /*
     70  1.1   thorpej  * Values for the hp300 bus space tag, not to be used directly by MI code.
     71  1.1   thorpej  */
     72  1.1   thorpej #define	HP300_BUS_SPACE_INTIO	0	/* space is intio space */
     73  1.1   thorpej #define	HP300_BUS_SPACE_DIO	1	/* space is dio space */
     74  1.1   thorpej 
     75  1.1   thorpej /*
     76  1.1   thorpej  * Bus address and size types
     77  1.1   thorpej  */
     78  1.1   thorpej typedef u_long bus_addr_t;
     79  1.1   thorpej typedef u_long bus_size_t;
     80  1.1   thorpej 
     81  1.1   thorpej /*
     82  1.1   thorpej  * Access methods for bus resources and address space.
     83  1.1   thorpej  */
     84  1.7   tsutsui typedef struct bus_space_tag *bus_space_tag_t;
     85  1.7   tsutsui typedef u_long bus_space_handle_t;
     86  1.7   tsutsui 
     87  1.7   tsutsui /*
     88  1.7   tsutsui  * Implementation specific structures.
     89  1.7   tsutsui  * XXX Don't use outside of bus_space definitions!
     90  1.7   tsutsui  * XXX maybe this should be encapsuled in a non-global .h file?
     91  1.8   tsutsui  */
     92  1.7   tsutsui 
     93  1.7   tsutsui struct bus_space_tag {
     94  1.7   tsutsui 	u_int		bustype;
     95  1.7   tsutsui 
     96  1.9   thorpej 	u_int8_t	(*bsr1)(bus_space_tag_t, bus_space_handle_t,
     97  1.9   thorpej 			    bus_size_t);
     98  1.9   thorpej 	u_int16_t	(*bsr2)(bus_space_tag_t, bus_space_handle_t,
     99  1.9   thorpej 			    bus_size_t);
    100  1.9   thorpej 	u_int32_t	(*bsr4)(bus_space_tag_t, bus_space_handle_t,
    101  1.9   thorpej 			    bus_size_t);
    102  1.9   thorpej 	void		(*bsrm1)(bus_space_tag_t, bus_space_handle_t,
    103  1.9   thorpej 			    bus_size_t, u_int8_t *, bus_size_t);
    104  1.9   thorpej 	void		(*bsrm2)(bus_space_tag_t, bus_space_handle_t,
    105  1.9   thorpej 			    bus_size_t, u_int16_t *, bus_size_t);
    106  1.9   thorpej 	void		(*bsrm4)(bus_space_tag_t, bus_space_handle_t,
    107  1.9   thorpej 			    bus_size_t, u_int32_t *, bus_size_t);
    108  1.9   thorpej 	void		(*bsrr1)(bus_space_tag_t, bus_space_handle_t,
    109  1.9   thorpej 			    bus_size_t, u_int8_t *, bus_size_t);
    110  1.9   thorpej 	void		(*bsrr2)(bus_space_tag_t, bus_space_handle_t,
    111  1.9   thorpej 			    bus_size_t, u_int16_t *, bus_size_t);
    112  1.9   thorpej 	void		(*bsrr4)(bus_space_tag_t, bus_space_handle_t,
    113  1.9   thorpej 			    bus_size_t, u_int32_t *, bus_size_t);
    114  1.9   thorpej 	void		(*bsw1)(bus_space_tag_t, bus_space_handle_t,
    115  1.9   thorpej 			    bus_size_t, u_int8_t);
    116  1.9   thorpej 	void		(*bsw2)(bus_space_tag_t, bus_space_handle_t,
    117  1.9   thorpej 			    bus_size_t, u_int16_t);
    118  1.9   thorpej 	void		(*bsw4)(bus_space_tag_t, bus_space_handle_t,
    119  1.9   thorpej 			    bus_size_t, u_int32_t);
    120  1.9   thorpej 	void		(*bswm1)(bus_space_tag_t, bus_space_handle_t,
    121  1.9   thorpej 			    bus_size_t, const u_int8_t *, bus_size_t);
    122  1.9   thorpej 	void		(*bswm2)(bus_space_tag_t, bus_space_handle_t,
    123  1.9   thorpej 			    bus_size_t, const u_int16_t *, bus_size_t);
    124  1.9   thorpej 	void		(*bswm4)(bus_space_tag_t, bus_space_handle_t,
    125  1.9   thorpej 			    bus_size_t, const u_int32_t *, bus_size_t);
    126  1.9   thorpej 	void		(*bswr1)(bus_space_tag_t, bus_space_handle_t ,
    127  1.9   thorpej 			    bus_size_t, const u_int8_t *, bus_size_t);
    128  1.9   thorpej 	void		(*bswr2)(bus_space_tag_t, bus_space_handle_t,
    129  1.9   thorpej 			    bus_size_t, const u_int16_t *, bus_size_t);
    130  1.9   thorpej 	void		(*bswr4)(bus_space_tag_t, bus_space_handle_t,
    131  1.9   thorpej 			    bus_size_t, const u_int32_t *, bus_size_t);
    132  1.9   thorpej 	void		(*bssm1)(bus_space_tag_t, bus_space_handle_t,
    133  1.9   thorpej 			    bus_size_t, u_int8_t, bus_size_t);
    134  1.9   thorpej 	void		(*bssm2)(bus_space_tag_t, bus_space_handle_t,
    135  1.9   thorpej 			    bus_size_t, u_int16_t, bus_size_t);
    136  1.9   thorpej 	void		(*bssm4)(bus_space_tag_t, bus_space_handle_t,
    137  1.9   thorpej 			    bus_size_t, u_int32_t, bus_size_t);
    138  1.9   thorpej 	void		(*bssr1)(bus_space_tag_t, bus_space_handle_t,
    139  1.9   thorpej 			    bus_size_t, u_int8_t, bus_size_t);
    140  1.9   thorpej 	void		(*bssr2)(bus_space_tag_t, bus_space_handle_t,
    141  1.9   thorpej 			    bus_size_t, u_int16_t, bus_size_t);
    142  1.9   thorpej 	void		(*bssr4)(bus_space_tag_t, bus_space_handle_t,
    143  1.9   thorpej 			    bus_size_t, u_int32_t, bus_size_t);
    144  1.7   tsutsui };
    145  1.1   thorpej 
    146  1.1   thorpej /*
    147  1.9   thorpej  *	int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
    148  1.9   thorpej  *	    bus_size_t size, int flags, bus_space_handle_t *bshp);
    149  1.1   thorpej  *
    150  1.1   thorpej  * Map a region of bus space.
    151  1.1   thorpej  */
    152  1.1   thorpej 
    153  1.1   thorpej #define	BUS_SPACE_MAP_CACHEABLE		0x01
    154  1.1   thorpej #define	BUS_SPACE_MAP_LINEAR		0x02
    155  1.7   tsutsui #define	BUS_SPACE_MAP_PREFETCHABLE	0x04
    156  1.1   thorpej 
    157  1.9   thorpej int	bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t,
    158  1.9   thorpej 	    int, bus_space_handle_t *);
    159  1.1   thorpej 
    160  1.1   thorpej /*
    161  1.9   thorpej  *	void bus_space_unmap(bus_space_tag_t t,
    162  1.9   thorpej  *	    bus_space_handle_t bsh, bus_size_t size);
    163  1.1   thorpej  *
    164  1.1   thorpej  * Unmap a region of bus space.
    165  1.1   thorpej  */
    166  1.1   thorpej 
    167  1.9   thorpej void	bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
    168  1.1   thorpej 
    169  1.1   thorpej /*
    170  1.9   thorpej  *	int bus_space_subregion(bus_space_tag_t t,
    171  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
    172  1.9   thorpej  *	    bus_space_handle_t *nbshp);
    173  1.1   thorpej  *
    174  1.1   thorpej  * Get a new handle for a subregion of an already-mapped area of bus space.
    175  1.1   thorpej  */
    176  1.1   thorpej 
    177  1.9   thorpej int	bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
    178  1.9   thorpej 	    bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
    179  1.1   thorpej 
    180  1.1   thorpej /*
    181  1.9   thorpej  *	int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart,
    182  1.1   thorpej  *	    bus_addr_t rend, bus_size_t size, bus_size_t align,
    183  1.1   thorpej  *	    bus_size_t boundary, int flags, bus_addr_t *addrp,
    184  1.9   thorpej  *	    bus_space_handle_t *bshp);
    185  1.1   thorpej  *
    186  1.1   thorpej  * Allocate a region of bus space.
    187  1.1   thorpej  */
    188  1.1   thorpej 
    189  1.9   thorpej int	bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
    190  1.1   thorpej 	    bus_addr_t rend, bus_size_t size, bus_size_t align,
    191  1.1   thorpej 	    bus_size_t boundary, int cacheable, bus_addr_t *addrp,
    192  1.9   thorpej 	    bus_space_handle_t *bshp);
    193  1.1   thorpej 
    194  1.1   thorpej /*
    195  1.9   thorpej  *	int bus_space_free(bus_space_tag_t t,
    196  1.9   thorpej  *	    bus_space_handle_t bsh, bus_size_t size);
    197  1.1   thorpej  *
    198  1.1   thorpej  * Free a region of bus space.
    199  1.1   thorpej  */
    200  1.1   thorpej 
    201  1.9   thorpej void	bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
    202  1.9   thorpej 	    bus_size_t size);
    203  1.5  gmcgarry 
    204  1.5  gmcgarry /*
    205  1.9   thorpej  *	void *bus_space_vaddr(bus_space_tag_t, bus_space_handle_t);
    206  1.5  gmcgarry  *
    207  1.5  gmcgarry  * Get the kernel virtual address for the mapped bus space.
    208  1.5  gmcgarry  * Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR.
    209  1.5  gmcgarry  *  (XXX not enforced)
    210  1.5  gmcgarry  */
    211  1.6  gmcgarry #define bus_space_vaddr(t, h)	(void *)(h)
    212  1.1   thorpej 
    213  1.1   thorpej /*
    214  1.9   thorpej  *	int hp300_bus_space_probe(bus_space_tag_t t,
    215  1.9   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset, int sz);
    216  1.1   thorpej  *
    217  1.1   thorpej  * Probe the bus at t/bsh/offset, using sz as the size of the load.
    218  1.1   thorpej  *
    219  1.1   thorpej  * This is a machine-dependent extension, and is not to be used by
    220  1.1   thorpej  * machine-independent code.
    221  1.1   thorpej  */
    222  1.1   thorpej 
    223  1.9   thorpej int	hp300_bus_space_probe(bus_space_tag_t t,
    224  1.9   thorpej 	    bus_space_handle_t bsh, bus_size_t offset, int sz);
    225  1.1   thorpej 
    226  1.1   thorpej /*
    227  1.9   thorpej  *	u_intN_t bus_space_read_N(bus_space_tag_t tag,
    228  1.9   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset);
    229  1.1   thorpej  *
    230  1.1   thorpej  * Read a 1, 2, 4, or 8 byte quantity from bus space
    231  1.1   thorpej  * described by tag/handle/offset.
    232  1.1   thorpej  */
    233  1.1   thorpej 
    234  1.1   thorpej #define	bus_space_read_1(t, h, o)					\
    235  1.7   tsutsui     (((t)->bsr1 != NULL) ? ((t)->bsr1)(t, h, o) :			\
    236  1.7   tsutsui     (*(volatile u_int8_t *)((h) + (o))))
    237  1.1   thorpej 
    238  1.1   thorpej #define	bus_space_read_2(t, h, o)					\
    239  1.7   tsutsui     (((t)->bsr2 != NULL) ? ((t)->bsr2)(t, h, o) :			\
    240  1.7   tsutsui     (*(volatile u_int16_t *)((h) + (o))))
    241  1.1   thorpej 
    242  1.1   thorpej #define	bus_space_read_4(t, h, o)					\
    243  1.7   tsutsui     (((t)->bsr4 != NULL) ? ((t)->bsr4)(t, h, o) :			\
    244  1.7   tsutsui     (*(volatile u_int32_t *)((h) + (o))))
    245  1.1   thorpej 
    246  1.1   thorpej #if 0	/* Cause a link error for bus_space_read_8 */
    247  1.1   thorpej #define	bus_space_read_8(t, h, o)	!!! bus_space_read_8 unimplemented !!!
    248  1.1   thorpej #endif
    249  1.1   thorpej 
    250  1.1   thorpej /*
    251  1.9   thorpej  *	void bus_space_read_multi_N(bus_space_tag_t tag,
    252  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset,
    253  1.9   thorpej  *	    u_intN_t *addr, size_t count);
    254  1.1   thorpej  *
    255  1.1   thorpej  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
    256  1.1   thorpej  * described by tag/handle/offset and copy into buffer provided.
    257  1.1   thorpej  */
    258  1.1   thorpej 
    259  1.7   tsutsui #define	bus_space_read_multi_1(t, h, o, a, c)				\
    260  1.7   tsutsui do {									\
    261  1.7   tsutsui 	if ((t)->bsrm1 != NULL)						\
    262  1.7   tsutsui 		((t)->bsrm1)(t, h, o, a, c);				\
    263  1.7   tsutsui 	else {								\
    264  1.7   tsutsui 		__asm __volatile ("					\
    265  1.7   tsutsui 			movl	%0,%%a0				;	\
    266  1.7   tsutsui 			movl	%1,%%a1				;	\
    267  1.7   tsutsui 			movl	%2,%%d0				;	\
    268  1.7   tsutsui 		1:	movb	%%a0@,%%a1@+			;	\
    269  1.7   tsutsui 			subql	#1,%%d0				;	\
    270  1.7   tsutsui 			jne	1b"				:	\
    271  1.7   tsutsui 								:	\
    272  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    273  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    274  1.7   tsutsui 	}								\
    275  1.7   tsutsui } while (/* CONSTCOND */ 0)
    276  1.7   tsutsui 
    277  1.7   tsutsui #define	bus_space_read_multi_2(t, h, o, a, c)				\
    278  1.7   tsutsui do {									\
    279  1.7   tsutsui 	if ((t)->bsrm2 != NULL)						\
    280  1.7   tsutsui 		((t)->bsrm2)(t, h, o, a, c);				\
    281  1.7   tsutsui 	else {								\
    282  1.7   tsutsui 		__asm __volatile ("					\
    283  1.7   tsutsui 			movl	%0,%%a0				;	\
    284  1.7   tsutsui 			movl	%1,%%a1				;	\
    285  1.7   tsutsui 			movl	%2,%%d0				;	\
    286  1.7   tsutsui 		1:	movw	%%a0@,%%a1@+			;	\
    287  1.7   tsutsui 			subql	#1,%%d0				;	\
    288  1.7   tsutsui 			jne	1b"				:	\
    289  1.7   tsutsui 								:	\
    290  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    291  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    292  1.7   tsutsui 	}								\
    293  1.7   tsutsui } while (/* CONSTCOND */ 0)
    294  1.1   thorpej 
    295  1.1   thorpej #define	bus_space_read_multi_4(t, h, o, a, c) do {			\
    296  1.7   tsutsui 	if ((t)->bsrm4 != NULL)						\
    297  1.7   tsutsui 		((t)->bsrm4)(t, h, o, a, c);				\
    298  1.7   tsutsui 	else {								\
    299  1.7   tsutsui 		__asm __volatile ("					\
    300  1.7   tsutsui 			movl	%0,%%a0				;	\
    301  1.7   tsutsui 			movl	%1,%%a1				;	\
    302  1.7   tsutsui 			movl	%2,%%d0				;	\
    303  1.7   tsutsui 		1:	movl	%%a0@,%%a1@+			;	\
    304  1.7   tsutsui 			subql	#1,%%d0				;	\
    305  1.7   tsutsui 			jne	1b"				:	\
    306  1.7   tsutsui 								:	\
    307  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    308  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    309  1.7   tsutsui 	}								\
    310  1.7   tsutsui } while (/* CONSTCOND */ 0)
    311  1.1   thorpej 
    312  1.1   thorpej #if 0	/* Cause a link error for bus_space_read_multi_8 */
    313  1.1   thorpej #define	bus_space_read_multi_8	!!! bus_space_read_multi_8 unimplemented !!!
    314  1.1   thorpej #endif
    315  1.1   thorpej 
    316  1.1   thorpej /*
    317  1.9   thorpej  *	void bus_space_read_region_N(bus_space_tag_t tag,
    318  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset,
    319  1.9   thorpej  *	    u_intN_t *addr, size_t count);
    320  1.1   thorpej  *
    321  1.1   thorpej  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
    322  1.1   thorpej  * described by tag/handle and starting at `offset' and copy into
    323  1.1   thorpej  * buffer provided.
    324  1.1   thorpej  */
    325  1.1   thorpej 
    326  1.7   tsutsui #define	bus_space_read_region_1(t, h, o, a, c)				\
    327  1.7   tsutsui do {									\
    328  1.7   tsutsui 	if ((t)->bsrr1 != NULL)						\
    329  1.7   tsutsui 		((t)->bsrr1)(t, h, o, a, c);				\
    330  1.7   tsutsui 	else {								\
    331  1.7   tsutsui 		__asm __volatile ("					\
    332  1.7   tsutsui 			movl	%0,%%a0				;	\
    333  1.7   tsutsui 			movl	%1,%%a1				;	\
    334  1.7   tsutsui 			movl	%2,%%d0				;	\
    335  1.7   tsutsui 		1:	movb	%%a0@+,%%a1@+			;	\
    336  1.7   tsutsui 			subql	#1,%%d0				;	\
    337  1.7   tsutsui 			jne	1b"				:	\
    338  1.7   tsutsui 								:	\
    339  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    340  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    341  1.7   tsutsui 	}								\
    342  1.7   tsutsui } while (/* CONSTCOND */ 0)
    343  1.7   tsutsui 
    344  1.7   tsutsui #define	bus_space_read_region_2(t, h, o, a, c)				\
    345  1.7   tsutsui do {									\
    346  1.7   tsutsui 	if ((t)->bsrr2 != NULL)						\
    347  1.7   tsutsui 		((t)->bsrr2)(t, h, o, a, c);				\
    348  1.7   tsutsui 	else {								\
    349  1.7   tsutsui 		__asm __volatile ("					\
    350  1.7   tsutsui 			movl	%0,%%a0				;	\
    351  1.7   tsutsui 			movl	%1,%%a1				;	\
    352  1.7   tsutsui 			movl	%2,%%d0				;	\
    353  1.7   tsutsui 		1:	movw	%%a0@+,%%a1@+			;	\
    354  1.7   tsutsui 			subql	#1,%%d0				;	\
    355  1.7   tsutsui 			jne	1b"				:	\
    356  1.7   tsutsui 								:	\
    357  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    358  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    359  1.7   tsutsui 	}								\
    360  1.7   tsutsui } while (/* CONSTCOND */ 0)
    361  1.7   tsutsui 
    362  1.7   tsutsui #define	bus_space_read_region_4(t, h, o, a, c)				\
    363  1.7   tsutsui do {									\
    364  1.7   tsutsui 	if ((t)->bsrr4 != NULL)						\
    365  1.7   tsutsui 		((t)->bsrr4)(t, h, o, a, c);				\
    366  1.7   tsutsui 	else {								\
    367  1.7   tsutsui 		__asm __volatile ("					\
    368  1.7   tsutsui 			movl	%0,%%a0				;	\
    369  1.7   tsutsui 			movl	%1,%%a1				;	\
    370  1.7   tsutsui 			movl	%2,%%d0				;	\
    371  1.7   tsutsui 		1:	movl	%%a0@+,%%a1@+			;	\
    372  1.7   tsutsui 			subql	#1,%%d0				;	\
    373  1.7   tsutsui 			jne	1b"				:	\
    374  1.7   tsutsui 								:	\
    375  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    376  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    377  1.7   tsutsui 	}								\
    378  1.7   tsutsui } while (/* CONSTCOND */ 0)
    379  1.1   thorpej 
    380  1.1   thorpej #if 0	/* Cause a link error for bus_space_read_region_8 */
    381  1.1   thorpej #define	bus_space_read_region_8	!!! bus_space_read_region_8 unimplemented !!!
    382  1.1   thorpej #endif
    383  1.1   thorpej 
    384  1.1   thorpej /*
    385  1.9   thorpej  *	void bus_space_write_N(bus_space_tag_t tag,
    386  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset,
    387  1.9   thorpej  *	    u_intN_t value);
    388  1.1   thorpej  *
    389  1.1   thorpej  * Write the 1, 2, 4, or 8 byte value `value' to bus space
    390  1.1   thorpej  * described by tag/handle/offset.
    391  1.1   thorpej  */
    392  1.1   thorpej 
    393  1.1   thorpej #define	bus_space_write_1(t, h, o, v)					\
    394  1.7   tsutsui do {									\
    395  1.7   tsutsui 	if ((t)->bsw1 != NULL)						\
    396  1.7   tsutsui 		((t)->bsw1)(t, h, o, v);				\
    397  1.7   tsutsui 	else								\
    398  1.7   tsutsui 		((void)(*(volatile u_int8_t *)((h) + (o)) = (v)));	\
    399  1.7   tsutsui } while (/* CONSTCOND */ 0)
    400  1.1   thorpej 
    401  1.1   thorpej #define	bus_space_write_2(t, h, o, v)					\
    402  1.7   tsutsui do {									\
    403  1.7   tsutsui 	if ((t)->bsw2 != NULL)						\
    404  1.7   tsutsui 		((t)->bsw2)(t, h, o, v);				\
    405  1.7   tsutsui 	else								\
    406  1.7   tsutsui 		((void)(*(volatile u_int16_t *)((h) + (o)) = (v)));	\
    407  1.7   tsutsui } while (/* CONSTCOND */ 0)
    408  1.1   thorpej 
    409  1.1   thorpej #define	bus_space_write_4(t, h, o, v)					\
    410  1.7   tsutsui do {									\
    411  1.7   tsutsui 	if ((t)->bsw4 != NULL)						\
    412  1.7   tsutsui 		((t)->bsw4)(t, h, o, v);				\
    413  1.7   tsutsui 	else								\
    414  1.7   tsutsui 		((void)(*(volatile u_int32_t *)((h) + (o)) = (v)));	\
    415  1.7   tsutsui } while (/* CONSTCOND */ 0)
    416  1.1   thorpej 
    417  1.1   thorpej #if 0	/* Cause a link error for bus_space_write_8 */
    418  1.1   thorpej #define	bus_space_write_8	!!! bus_space_write_8 not implemented !!!
    419  1.1   thorpej #endif
    420  1.1   thorpej 
    421  1.1   thorpej /*
    422  1.9   thorpej  *	void bus_space_write_multi_N(bus_space_tag_t tag,
    423  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset,
    424  1.9   thorpej  *	    const u_intN_t *addr, size_t count);
    425  1.1   thorpej  *
    426  1.1   thorpej  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
    427  1.1   thorpej  * provided to bus space described by tag/handle/offset.
    428  1.1   thorpej  */
    429  1.1   thorpej 
    430  1.7   tsutsui #define	bus_space_write_multi_1(t, h, o, a, c)				\
    431  1.7   tsutsui do {									\
    432  1.7   tsutsui 	if ((t)->bswm1 != NULL)						\
    433  1.7   tsutsui 		((t)->bswm1)(t, h, o, a, c);				\
    434  1.7   tsutsui 	else {								\
    435  1.7   tsutsui 		__asm __volatile ("					\
    436  1.7   tsutsui 			movl	%0,%%a0				;	\
    437  1.7   tsutsui 			movl	%1,%%a1				;	\
    438  1.7   tsutsui 			movl	%2,%%d0				;	\
    439  1.7   tsutsui 		1:	movb	%%a1@+,%%a0@			;	\
    440  1.7   tsutsui 			subql	#1,%%d0				;	\
    441  1.7   tsutsui 			jne	1b"				:	\
    442  1.7   tsutsui 								:	\
    443  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    444  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    445  1.7   tsutsui 	}								\
    446  1.7   tsutsui } while (/* CONSTCOND */ 0)
    447  1.7   tsutsui 
    448  1.7   tsutsui #define	bus_space_write_multi_2(t, h, o, a, c)				\
    449  1.7   tsutsui do {									\
    450  1.7   tsutsui 	if ((t)->bswm2 != NULL)						\
    451  1.7   tsutsui 		((t)->bswm2)(t, h, o, a, c);				\
    452  1.7   tsutsui 	else {								\
    453  1.7   tsutsui 		__asm __volatile ("					\
    454  1.7   tsutsui 			movl	%0,%%a0				;	\
    455  1.7   tsutsui 			movl	%1,%%a1				;	\
    456  1.7   tsutsui 			movl	%2,%%d0				;	\
    457  1.7   tsutsui 		1:	movw	%%a1@+,%%a0@			;	\
    458  1.7   tsutsui 			subql	#1,%%d0				;	\
    459  1.7   tsutsui 			jne	1b"				:	\
    460  1.7   tsutsui 								:	\
    461  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    462  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    463  1.7   tsutsui 	}								\
    464  1.7   tsutsui } while (/* CONSTCOND */ 0)
    465  1.7   tsutsui 
    466  1.7   tsutsui #define	bus_space_write_multi_4(t, h, o, a, c)				\
    467  1.7   tsutsui do {									\
    468  1.7   tsutsui 	(void) t;							\
    469  1.7   tsutsui 	if ((t)->bswm4 != NULL)					\
    470  1.7   tsutsui 		((t)->bswm4)(t, h, o, a, c);				\
    471  1.7   tsutsui 	else {								\
    472  1.7   tsutsui 		__asm __volatile ("					\
    473  1.7   tsutsui 			movl	%0,%%a0				;	\
    474  1.7   tsutsui 			movl	%1,%%a1				;	\
    475  1.7   tsutsui 			movl	%2,%%d0				;	\
    476  1.7   tsutsui 		1:	movl	%%a1@+,%%a0@			;	\
    477  1.7   tsutsui 			subql	#1,%%d0				;	\
    478  1.7   tsutsui 			jne	1b"				:	\
    479  1.7   tsutsui 								:	\
    480  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    481  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    482  1.7   tsutsui 	}								\
    483  1.7   tsutsui } while (/* CONSTCOND */ 0)
    484  1.1   thorpej 
    485  1.1   thorpej #if 0	/* Cause a link error for bus_space_write_8 */
    486  1.1   thorpej #define	bus_space_write_multi_8(t, h, o, a, c)				\
    487  1.1   thorpej 			!!! bus_space_write_multi_8 unimplimented !!!
    488  1.1   thorpej #endif
    489  1.1   thorpej 
    490  1.1   thorpej /*
    491  1.9   thorpej  *	void bus_space_write_region_N(bus_space_tag_t tag,
    492  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset,
    493  1.9   thorpej  *	    const u_intN_t *addr, size_t count);
    494  1.1   thorpej  *
    495  1.1   thorpej  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
    496  1.1   thorpej  * to bus space described by tag/handle starting at `offset'.
    497  1.1   thorpej  */
    498  1.1   thorpej 
    499  1.7   tsutsui #define	bus_space_write_region_1(t, h, o, a, c)				\
    500  1.7   tsutsui do {									\
    501  1.7   tsutsui 	if ((t)->bswr1 != NULL)					\
    502  1.7   tsutsui 		((t)->bswr1)(t, h, o, a, c);				\
    503  1.7   tsutsui 	else {								\
    504  1.7   tsutsui 		__asm __volatile ("					\
    505  1.7   tsutsui 			movl	%0,%%a0				;	\
    506  1.7   tsutsui 			movl	%1,%%a1				;	\
    507  1.7   tsutsui 			movl	%2,%%d0				;	\
    508  1.7   tsutsui 		1:	movb	%%a1@+,%%a0@+			;	\
    509  1.7   tsutsui 			subql	#1,%%d0				;	\
    510  1.7   tsutsui 			jne	1b"				:	\
    511  1.7   tsutsui 								:	\
    512  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    513  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    514  1.7   tsutsui 	}								\
    515  1.7   tsutsui } while (/* CONSTCOND */ 0)
    516  1.7   tsutsui 
    517  1.7   tsutsui #define	bus_space_write_region_2(t, h, o, a, c)				\
    518  1.7   tsutsui do {									\
    519  1.7   tsutsui 	if ((t)->bswr2) != NULL)					\
    520  1.7   tsutsui 		((t)->bswr2)(t, h, o, a, c);				\
    521  1.7   tsutsui 	else {								\
    522  1.7   tsutsui 		__asm __volatile ("					\
    523  1.7   tsutsui 			movl	%0,%%a0				;	\
    524  1.7   tsutsui 			movl	%1,%%a1				;	\
    525  1.7   tsutsui 			movl	%2,%%d0				;	\
    526  1.7   tsutsui 		1:	movw	%%a1@+,%%a0@+			;	\
    527  1.7   tsutsui 			subql	#1,%%d0				;	\
    528  1.7   tsutsui 			jne	1b"				:	\
    529  1.7   tsutsui 								:	\
    530  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    531  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    532  1.7   tsutsui 	}								\
    533  1.7   tsutsui } while (/* CONSTCOND */ 0)
    534  1.7   tsutsui 
    535  1.7   tsutsui #define	bus_space_write_region_4(t, h, o, a, c)				\
    536  1.7   tsutsui do {									\
    537  1.7   tsutsui 	if ((t)->bswr4) != NULL)					\
    538  1.7   tsutsui 		((t)->bswr4)(t, h, o, a, c);				\
    539  1.7   tsutsui 	else {								\
    540  1.7   tsutsui 		__asm __volatile ("					\
    541  1.7   tsutsui 			movl	%0,%%a0				;	\
    542  1.7   tsutsui 			movl	%1,%%a1				;	\
    543  1.7   tsutsui 			movl	%2,%%d0				;	\
    544  1.7   tsutsui 		1:	movl	%%a1@+,%%a0@+			;	\
    545  1.7   tsutsui 			subql	#1,%%d0				;	\
    546  1.7   tsutsui 			jne	1b"				:	\
    547  1.7   tsutsui 								:	\
    548  1.7   tsutsui 			    "r" ((h) + (o)), "g" (a), "g" (c)	:	\
    549  1.7   tsutsui 			    "%a0","%a1","%d0");				\
    550  1.7   tsutsui 	}								\
    551  1.7   tsutsui } while (/* CONSTCOND */ 0)
    552  1.1   thorpej 
    553  1.1   thorpej #if 0	/* Cause a link error for bus_space_write_region_8 */
    554  1.1   thorpej #define	bus_space_write_region_8					\
    555  1.1   thorpej 			!!! bus_space_write_region_8 unimplemented !!!
    556  1.1   thorpej #endif
    557  1.1   thorpej 
    558  1.1   thorpej /*
    559  1.9   thorpej  *	void bus_space_set_multi_N(bus_space_tag_t tag,
    560  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
    561  1.9   thorpej  *	    size_t count);
    562  1.1   thorpej  *
    563  1.1   thorpej  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
    564  1.1   thorpej  * by tag/handle/offset `count' times.
    565  1.1   thorpej  */
    566  1.1   thorpej 
    567  1.7   tsutsui #define	bus_space_set_multi_1(t, h, o, val, c)				\
    568  1.7   tsutsui do {									\
    569  1.7   tsutsui 	if ((t)->bssm1 != NULL)						\
    570  1.7   tsutsui 		((t)->bssm1)(t, h, o, val, c);				\
    571  1.7   tsutsui 	else {								\
    572  1.7   tsutsui 		__asm __volatile ("					\
    573  1.7   tsutsui 			movl	%0,%%a0				;	\
    574  1.7   tsutsui 			movl	%1,%%d1				;	\
    575  1.7   tsutsui 			movl	%2,%%d0				;	\
    576  1.7   tsutsui 		1:	movb	%%d1,%%a0@			;	\
    577  1.7   tsutsui 			subql	#1,%%d0				;	\
    578  1.7   tsutsui 			jne	1b"				:	\
    579  1.7   tsutsui 								:	\
    580  1.7   tsutsui 			    "r" ((h) + (o)), "g" (val), "g" (c)	:	\
    581  1.7   tsutsui 			    "%a0","%d0","%d1");				\
    582  1.7   tsutsui 	}								\
    583  1.7   tsutsui } while (/* CONSTCOND */ 0)
    584  1.7   tsutsui 
    585  1.7   tsutsui #define	bus_space_set_multi_2(t, h, o, val, c)				\
    586  1.7   tsutsui do {									\
    587  1.7   tsutsui 	if ((t)->bssm2 != NULL)						\
    588  1.7   tsutsui 		((t)->bssm2)(t, h, o, val, c);				\
    589  1.7   tsutsui 	else {								\
    590  1.7   tsutsui 		__asm __volatile ("					\
    591  1.7   tsutsui 			movl	%0,%%a0				;	\
    592  1.7   tsutsui 			movl	%1,%%d1				;	\
    593  1.7   tsutsui 			movl	%2,%%d0				;	\
    594  1.7   tsutsui 		1:	movw	%%d1,%%a0@			;	\
    595  1.7   tsutsui 			subql	#1,%%d0				;	\
    596  1.7   tsutsui 			jne	1b"				:	\
    597  1.7   tsutsui 								:	\
    598  1.7   tsutsui 			    "r" ((h) + (o)), "g" (val), "g" (c)	:	\
    599  1.7   tsutsui 			    "%a0","%d0","%d1");				\
    600  1.7   tsutsui 	}								\
    601  1.7   tsutsui } while (/* CONSTCOND */ 0)
    602  1.7   tsutsui 
    603  1.7   tsutsui #define	bus_space_set_multi_4(t, h, o, val, c)				\
    604  1.7   tsutsui do {									\
    605  1.7   tsutsui 	if ((t)->bssm4 != NULL)						\
    606  1.7   tsutsui 		((t)->bssm4)(t, h, o, val, c);				\
    607  1.7   tsutsui 	else {								\
    608  1.7   tsutsui 		__asm __volatile ("					\
    609  1.7   tsutsui 			movl	%0,%%a0				;	\
    610  1.7   tsutsui 			movl	%1,%%d1				;	\
    611  1.7   tsutsui 			movl	%2,%%d0				;	\
    612  1.7   tsutsui 		1:	movl	%%d1,%%a0@			;	\
    613  1.7   tsutsui 			subql	#1,%%d0				;	\
    614  1.7   tsutsui 			jne	1b"				:	\
    615  1.7   tsutsui 								:	\
    616  1.7   tsutsui 			    "r" ((h) + (o)), "g" (val), "g" (c)	:	\
    617  1.7   tsutsui 			    "%a0","%d0","%d1");				\
    618  1.7   tsutsui 	}								\
    619  1.7   tsutsui } while (/* CONSTCOND */ 0)
    620  1.1   thorpej 
    621  1.1   thorpej #if 0	/* Cause a link error for bus_space_set_multi_8 */
    622  1.1   thorpej #define	bus_space_set_multi_8						\
    623  1.1   thorpej 			!!! bus_space_set_multi_8 unimplemented !!!
    624  1.1   thorpej #endif
    625  1.1   thorpej 
    626  1.1   thorpej /*
    627  1.9   thorpej  *	void bus_space_set_region_N(bus_space_tag_t tag,
    628  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
    629  1.9   thorpej  *	    size_t count);
    630  1.1   thorpej  *
    631  1.1   thorpej  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
    632  1.1   thorpej  * by tag/handle starting at `offset'.
    633  1.1   thorpej  */
    634  1.1   thorpej 
    635  1.7   tsutsui #define	bus_space_set_region_1(t, h, o, val, c)				\
    636  1.7   tsutsui do {									\
    637  1.7   tsutsui 	if ((t)->bssr1 != NULL)						\
    638  1.7   tsutsui 		((t)->bssr1)(t, h, o, val, c);				\
    639  1.7   tsutsui 	else {								\
    640  1.7   tsutsui 		__asm __volatile ("					\
    641  1.7   tsutsui 			movl	%0,%%a0				;	\
    642  1.7   tsutsui 			movl	%1,%%d1				;	\
    643  1.7   tsutsui 			movl	%2,%%d0				;	\
    644  1.7   tsutsui 		1:	movb	%%d1,%%a0@+			;	\
    645  1.7   tsutsui 			subql	#1,%%d0				;	\
    646  1.7   tsutsui 			jne	1b"				:	\
    647  1.7   tsutsui 								:	\
    648  1.7   tsutsui 			    "r" ((h) + (o)), "g" (val), "g" (c)	:	\
    649  1.7   tsutsui 			    "%a0","%d0","%d1");				\
    650  1.7   tsutsui 	}								\
    651  1.7   tsutsui } while (/* CONSTCOND */ 0)
    652  1.7   tsutsui 
    653  1.7   tsutsui #define	bus_space_set_region_2(t, h, o, val, c)				\
    654  1.7   tsutsui do {									\
    655  1.7   tsutsui 	if ((t)->bssr2 != NULL)						\
    656  1.7   tsutsui 		((t)->bssr2)(t, h, o, val, c);				\
    657  1.7   tsutsui 	else {								\
    658  1.7   tsutsui 		__asm __volatile ("					\
    659  1.7   tsutsui 			movl	%0,%%a0				;	\
    660  1.7   tsutsui 			movl	%1,%%d1				;	\
    661  1.7   tsutsui 			movl	%2,%%d0				;	\
    662  1.7   tsutsui 		1:	movw	%%d1,%%a0@+			;	\
    663  1.7   tsutsui 			subql	#1,%%d0				;	\
    664  1.7   tsutsui 			jne	1b"				:	\
    665  1.7   tsutsui 								:	\
    666  1.7   tsutsui 			    "r" ((h) + (o)), "g" (val), "g" (c)	:	\
    667  1.7   tsutsui 			    "%a0","%d0","%d1");				\
    668  1.7   tsutsui 	}								\
    669  1.7   tsutsui } while (/* CONSTCOND */ 0)
    670  1.7   tsutsui 
    671  1.7   tsutsui #define	bus_space_set_region_4(t, h, o, val, c)				\
    672  1.7   tsutsui do {									\
    673  1.7   tsutsui 	(void) t;							\
    674  1.7   tsutsui 	if ((t)->bssr4 != NULL)						\
    675  1.7   tsutsui 		((t)->bssr4)(t, h, o, val, c);				\
    676  1.7   tsutsui 	else {								\
    677  1.7   tsutsui 		__asm __volatile ("					\
    678  1.7   tsutsui 			movl	%0,%%a0				;	\
    679  1.7   tsutsui 			movl	%1,%%d1				;	\
    680  1.7   tsutsui 			movl	%2,%%d0				;	\
    681  1.7   tsutsui 		1:	movl	%%d1,%%a0@+			;	\
    682  1.7   tsutsui 			subql	#1,%%d0				;	\
    683  1.7   tsutsui 			jne	1b"				:	\
    684  1.7   tsutsui 								:	\
    685  1.7   tsutsui 			    "r" ((h) + (o)), "g" (val), "g" (c)	:	\
    686  1.7   tsutsui 			    "%a0","%d0","%d1");				\
    687  1.7   tsutsui 	}								\
    688  1.7   tsutsui } while (/* CONSTCOND */ 0)
    689  1.1   thorpej 
    690  1.1   thorpej #if 0	/* Cause a link error for bus_space_set_region_8 */
    691  1.1   thorpej #define	bus_space_set_region_8						\
    692  1.1   thorpej 			!!! bus_space_set_region_8 unimplemented !!!
    693  1.1   thorpej #endif
    694  1.1   thorpej 
    695  1.1   thorpej /*
    696  1.9   thorpej  *	void bus_space_copy_region_N(bus_space_tag_t tag,
    697  1.1   thorpej  *	    bus_space_handle_t bsh1, bus_size_t off1,
    698  1.1   thorpej  *	    bus_space_handle_t bsh2, bus_size_t off2,
    699  1.9   thorpej  *	    bus_size_t count);
    700  1.1   thorpej  *
    701  1.1   thorpej  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
    702  1.1   thorpej  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
    703  1.1   thorpej  */
    704  1.1   thorpej 
    705  1.1   thorpej #define	__HP300_copy_region_N(BYTES)					\
    706  1.9   thorpej static __inline void __unused						\
    707  1.9   thorpej __CONCAT(bus_space_copy_region_,BYTES)(bus_space_tag_t t,		\
    708  1.9   thorpej     bus_space_handle_t h1, bus_size_t o1, bus_space_handle_t h2,	\
    709  1.9   thorpej     bus_size_t o2, bus_size_t c)					\
    710  1.1   thorpej {									\
    711  1.1   thorpej 	bus_size_t o;							\
    712  1.1   thorpej 									\
    713  1.1   thorpej 	if ((h1 + o1) >= (h2 + o2)) {					\
    714  1.1   thorpej 		/* src after dest: copy forward */			\
    715  1.1   thorpej 		for (o = 0; c != 0; c--, o += BYTES)			\
    716  1.1   thorpej 			__CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o,	\
    717  1.1   thorpej 			    __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
    718  1.1   thorpej 	} else {							\
    719  1.1   thorpej 		/* dest after src: copy backwards */			\
    720  1.1   thorpej 		for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES)	\
    721  1.1   thorpej 			__CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o,	\
    722  1.1   thorpej 			    __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
    723  1.1   thorpej 	}								\
    724  1.1   thorpej }
    725  1.1   thorpej __HP300_copy_region_N(1)
    726  1.1   thorpej __HP300_copy_region_N(2)
    727  1.1   thorpej __HP300_copy_region_N(4)
    728  1.1   thorpej #if 0	/* Cause a link error for bus_space_copy_region_8 */
    729  1.1   thorpej #define	bus_space_copy_region_8						\
    730  1.1   thorpej 			!!! bus_space_copy_region_8 unimplemented !!!
    731  1.1   thorpej #endif
    732  1.1   thorpej 
    733  1.1   thorpej #undef __HP300_copy_region_N
    734  1.1   thorpej 
    735  1.1   thorpej /*
    736  1.1   thorpej  * Bus read/write barrier methods.
    737  1.1   thorpej  *
    738  1.9   thorpej  *	void bus_space_barrier(bus_space_tag_t tag,
    739  1.1   thorpej  *	    bus_space_handle_t bsh, bus_size_t offset,
    740  1.9   thorpej  *	    bus_size_t len, int flags);
    741  1.1   thorpej  *
    742  1.1   thorpej  * Note: the 680x0 does not currently require barriers, but we must
    743  1.1   thorpej  * provide the flags to MI code.
    744  1.1   thorpej  */
    745  1.1   thorpej #define	bus_space_barrier(t, h, o, l, f)	\
    746  1.1   thorpej 	((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
    747  1.1   thorpej #define	BUS_SPACE_BARRIER_READ	0x01		/* force read barrier */
    748  1.1   thorpej #define	BUS_SPACE_BARRIER_WRITE	0x02		/* force write barrier */
    749  1.2  drochner 
    750  1.2  drochner #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
    751  1.1   thorpej 
    752  1.1   thorpej #endif /* _HP300_BUS_H_ */
    753