Home | History | Annotate | Line # | Download | only in include
bus.h revision 1.1.2.2
      1  1.1.2.2  thorpej /*	$NetBSD: bus.h,v 1.1.2.2 1997/09/01 20:06:44 thorpej Exp $	*/
      2  1.1.2.2  thorpej 
      3  1.1.2.2  thorpej /*
      4  1.1.2.2  thorpej  * Copyright (c) 1996 Leo Weppelman.  All rights reserved.
      5  1.1.2.2  thorpej  *
      6  1.1.2.2  thorpej  * Redistribution and use in source and binary forms, with or without
      7  1.1.2.2  thorpej  * modification, are permitted provided that the following conditions
      8  1.1.2.2  thorpej  * are met:
      9  1.1.2.2  thorpej  * 1. Redistributions of source code must retain the above copyright
     10  1.1.2.2  thorpej  *    notice, this list of conditions and the following disclaimer.
     11  1.1.2.2  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1.2.2  thorpej  *    notice, this list of conditions and the following disclaimer in the
     13  1.1.2.2  thorpej  *    documentation and/or other materials provided with the distribution.
     14  1.1.2.2  thorpej  * 3. All advertising materials mentioning features or use of this software
     15  1.1.2.2  thorpej  *    must display the following acknowledgement:
     16  1.1.2.2  thorpej  *      This product includes software developed by Leo Weppelman for the
     17  1.1.2.2  thorpej  *	NetBSD Project.
     18  1.1.2.2  thorpej  * 4. The name of the author may not be used to endorse or promote products
     19  1.1.2.2  thorpej  *    derived from this software without specific prior written permission
     20  1.1.2.2  thorpej  *
     21  1.1.2.2  thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1.2.2  thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1.2.2  thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1.2.2  thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1.2.2  thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1.2.2  thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1.2.2  thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1.2.2  thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1.2.2  thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1.2.2  thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1.2.2  thorpej  */
     32  1.1.2.2  thorpej 
     33  1.1.2.2  thorpej #ifndef _AMIGA_BUS_H_
     34  1.1.2.2  thorpej #define _AMIGA_BUS_H_
     35  1.1.2.2  thorpej 
     36  1.1.2.2  thorpej /*
     37  1.1.2.2  thorpej  * Memory addresses (in bus space)
     38  1.1.2.2  thorpej  */
     39  1.1.2.2  thorpej typedef u_long	bus_addr_t;
     40  1.1.2.2  thorpej typedef u_long	bus_size_t;
     41  1.1.2.2  thorpej 
     42  1.1.2.2  thorpej /*
     43  1.1.2.2  thorpej  * Access methods for bus resources and address space.
     44  1.1.2.2  thorpej  */
     45  1.1.2.2  thorpej typedef struct bus_space_tag {
     46  1.1.2.2  thorpej 	bus_addr_t	base;
     47  1.1.2.2  thorpej 	u_char		stride;
     48  1.1.2.2  thorpej } *bus_space_tag_t;
     49  1.1.2.2  thorpej 
     50  1.1.2.2  thorpej typedef u_long	bus_space_handle_t;
     51  1.1.2.2  thorpej 
     52  1.1.2.2  thorpej void	bus_space_read_multi_1 __P((bus_space_tag_t, bus_space_handle_t,
     53  1.1.2.2  thorpej 				int, caddr_t, int));
     54  1.1.2.2  thorpej void	bus_space_read_multi_2 __P((bus_space_tag_t, bus_space_handle_t,
     55  1.1.2.2  thorpej 				int, caddr_t, int));
     56  1.1.2.2  thorpej void	bus_space_read_multi_4 __P((bus_space_tag_t, bus_space_handle_t,
     57  1.1.2.2  thorpej 				int, caddr_t, int));
     58  1.1.2.2  thorpej void	bus_space_read_multi_8 __P((bus_space_tag_t, bus_space_handle_t,
     59  1.1.2.2  thorpej 				int, caddr_t, int));
     60  1.1.2.2  thorpej void	bus_space_write_multi_1 __P((bus_space_tag_t, bus_space_handle_t,
     61  1.1.2.2  thorpej 				int, caddr_t, int));
     62  1.1.2.2  thorpej void	bus_space_write_multi_2 __P((bus_space_tag_t, bus_space_handle_t,
     63  1.1.2.2  thorpej 				int, caddr_t, int));
     64  1.1.2.2  thorpej void	bus_space_write_multi_4 __P((bus_space_tag_t, bus_space_handle_t,
     65  1.1.2.2  thorpej 				int, caddr_t, int));
     66  1.1.2.2  thorpej void	bus_space_write_multi_8 __P((bus_space_tag_t, bus_space_handle_t,
     67  1.1.2.2  thorpej 				int, caddr_t, int));
     68  1.1.2.2  thorpej 
     69  1.1.2.2  thorpej #if 0
     70  1.1.2.2  thorpej int	bus_space_map __P((bus_space_tag_t, bus_addr_t, bus_size_t,
     71  1.1.2.2  thorpej 				int, bus_space_handle_t *));
     72  1.1.2.2  thorpej void	bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t,
     73  1.1.2.2  thorpej 				bus_size_t));
     74  1.1.2.2  thorpej #endif
     75  1.1.2.2  thorpej 
     76  1.1.2.2  thorpej #define bus_space_map(tag,off,size,cache,handle) 			\
     77  1.1.2.2  thorpej 	(*(handle) = (tag)->base + ((off)<<(tag)->stride), 0)
     78  1.1.2.2  thorpej 
     79  1.1.2.2  thorpej #define bus_space_unmap(tag,handle,size)	(void)0
     80  1.1.2.2  thorpej 
     81  1.1.2.2  thorpej #define	bus_space_read_1(t, h, o) \
     82  1.1.2.2  thorpej     ((void) t, (*(volatile u_int8_t *)((h) + ((o)<<(t)->stride))))
     83  1.1.2.2  thorpej 
     84  1.1.2.2  thorpej #define	bus_space_write_1(t, h, o, v) \
     85  1.1.2.2  thorpej     ((void) t, ((void)(*(volatile u_int8_t *)((h) + ((o)<<(t)->stride)) = (v))))
     86  1.1.2.2  thorpej 
     87  1.1.2.2  thorpej extern __inline__ void
     88  1.1.2.2  thorpej bus_space_read_multi_1(t, h, o, a, c)
     89  1.1.2.2  thorpej 	bus_space_tag_t		t;
     90  1.1.2.2  thorpej 	bus_space_handle_t	h;
     91  1.1.2.2  thorpej 	int			o, c;
     92  1.1.2.2  thorpej 	caddr_t			a;
     93  1.1.2.2  thorpej {
     94  1.1.2.2  thorpej 	for (; c; a++, c--)
     95  1.1.2.2  thorpej 		*(u_int8_t *)a = bus_space_read_1(t, h, o);
     96  1.1.2.2  thorpej }
     97  1.1.2.2  thorpej #ifdef notyet
     98  1.1.2.2  thorpej extern __inline__ void
     99  1.1.2.2  thorpej bus_space_read_multi_2(t, h, o, a, c)
    100  1.1.2.2  thorpej 	bus_space_tag_t		t;
    101  1.1.2.2  thorpej 	bus_space_handle_t	h;
    102  1.1.2.2  thorpej 	int			o, c;
    103  1.1.2.2  thorpej 	caddr_t			a;
    104  1.1.2.2  thorpej {
    105  1.1.2.2  thorpej 	for (; c; a += 2, c--)
    106  1.1.2.2  thorpej 		*(u_int16_t *)a = bus_space_read_2(t, h, o);
    107  1.1.2.2  thorpej }
    108  1.1.2.2  thorpej 
    109  1.1.2.2  thorpej extern __inline__ void
    110  1.1.2.2  thorpej bus_space_read_multi_4(t, h, o, a, c)
    111  1.1.2.2  thorpej 	bus_space_tag_t		t;
    112  1.1.2.2  thorpej 	bus_space_handle_t	h;
    113  1.1.2.2  thorpej 	int			o, c;
    114  1.1.2.2  thorpej 	caddr_t			a;
    115  1.1.2.2  thorpej {
    116  1.1.2.2  thorpej 	for (; c; a += 4, c--)
    117  1.1.2.2  thorpej 		*(u_int32_t *)a = bus_space_read_4(t, h, o);
    118  1.1.2.2  thorpej }
    119  1.1.2.2  thorpej 
    120  1.1.2.2  thorpej extern __inline__ void
    121  1.1.2.2  thorpej bus_space_read_multi_8(t, h, o, a, c)
    122  1.1.2.2  thorpej 	bus_space_tag_t		t;
    123  1.1.2.2  thorpej 	bus_space_handle_t	h;
    124  1.1.2.2  thorpej 	int			o, c;
    125  1.1.2.2  thorpej 	caddr_t			a;
    126  1.1.2.2  thorpej {
    127  1.1.2.2  thorpej 	for (; c; a += 8, c--)
    128  1.1.2.2  thorpej 		*(u_int64_t *)a = bus_space_read_8(t, h, o);
    129  1.1.2.2  thorpej }
    130  1.1.2.2  thorpej #endif
    131  1.1.2.2  thorpej 
    132  1.1.2.2  thorpej extern __inline__ void
    133  1.1.2.2  thorpej bus_space_write_multi_1(t, h, o, a, c)
    134  1.1.2.2  thorpej 	bus_space_tag_t		t;
    135  1.1.2.2  thorpej 	bus_space_handle_t	h;
    136  1.1.2.2  thorpej 	int			o, c;
    137  1.1.2.2  thorpej 	caddr_t			a;
    138  1.1.2.2  thorpej {
    139  1.1.2.2  thorpej 	for (; c; a++, c--)
    140  1.1.2.2  thorpej 		bus_space_write_1(t, h, o, *(u_int8_t *)a);
    141  1.1.2.2  thorpej }
    142  1.1.2.2  thorpej 
    143  1.1.2.2  thorpej #ifdef notyet
    144  1.1.2.2  thorpej extern __inline__ void
    145  1.1.2.2  thorpej bus_space_write_multi_2(t, h, o, a, c)
    146  1.1.2.2  thorpej 	bus_space_tag_t		t;
    147  1.1.2.2  thorpej 	bus_space_handle_t	h;
    148  1.1.2.2  thorpej 	int			o, c;
    149  1.1.2.2  thorpej 	caddr_t			a;
    150  1.1.2.2  thorpej {
    151  1.1.2.2  thorpej 	for (; c; a += 2, c--)
    152  1.1.2.2  thorpej 		bus_space_write_2(t, h, o, *(u_int16_t *)a);
    153  1.1.2.2  thorpej }
    154  1.1.2.2  thorpej 
    155  1.1.2.2  thorpej extern __inline__ void
    156  1.1.2.2  thorpej bus_space_write_multi_4(t, h, o, a, c)
    157  1.1.2.2  thorpej 	bus_space_tag_t		t;
    158  1.1.2.2  thorpej 	bus_space_handle_t	h;
    159  1.1.2.2  thorpej 	int			o, c;
    160  1.1.2.2  thorpej 	caddr_t			a;
    161  1.1.2.2  thorpej {
    162  1.1.2.2  thorpej 	for (; c; a += 4, c--)
    163  1.1.2.2  thorpej 		bus_space_write_4(t, h, o, *(u_int32_t *)a);
    164  1.1.2.2  thorpej }
    165  1.1.2.2  thorpej 
    166  1.1.2.2  thorpej extern __inline__ void
    167  1.1.2.2  thorpej bus_space_write_multi_8(t, h, o, a, c)
    168  1.1.2.2  thorpej 	bus_space_tag_t		t;
    169  1.1.2.2  thorpej 	bus_space_handle_t	h;
    170  1.1.2.2  thorpej 	int			o, c;
    171  1.1.2.2  thorpej 	caddr_t			a;
    172  1.1.2.2  thorpej {
    173  1.1.2.2  thorpej 	for (; c; a += 8, c--)
    174  1.1.2.2  thorpej 		bus_space_write_8(t, h, o, *(u_int64_t *)a);
    175  1.1.2.2  thorpej }
    176  1.1.2.2  thorpej #endif
    177  1.1.2.2  thorpej 
    178  1.1.2.2  thorpej #endif /* _AMIGA_BUS_H_ */
    179