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