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