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