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