Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / amigappc / include / bus.h
blob82c5e721bc3a5cc80b56da165f84b7d28299d1f7
1 /* $NetBSD: bus.h,v 1.5 2009/07/21 09:49:15 phx Exp $ */
3 /*
4 * Copyright (c) 1996 Leo Weppelman. All rights reserved.
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.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #ifndef _AMIGA_BUS_H_
28 #define _AMIGA_BUS_H_
30 #include <sys/types.h>
32 /* for public use: */
35 * Memory addresses (in bus space)
38 typedef u_int32_t bus_addr_t;
39 typedef u_int32_t bus_size_t;
42 * Access methods for bus resources and address space.
44 typedef struct bus_space_tag *bus_space_tag_t;
45 typedef u_long bus_space_handle_t;
47 /* unpublic, but needed by method implementors */
50 * Lazyness macros for function declarations.
53 #define bsr(what, typ) \
54 typ (what)(bus_space_handle_t, bus_addr_t)
56 #define bsw(what, typ) \
57 void (what)(bus_space_handle_t, bus_addr_t, unsigned)
59 #define bsrm(what, typ) \
60 void (what)(bus_space_handle_t, bus_size_t, typ *, bus_size_t)
62 #define bswm(what, typ) \
63 void (what)(bus_space_handle_t, bus_size_t, const typ *, bus_size_t)
65 #define bssr(what, typ) \
66 void (what)(bus_space_handle_t, bus_size_t, unsigned, bus_size_t)
68 #define bscr(what, typ) \
69 void (what)(bus_space_handle_t, bus_size_t, \
70 bus_space_handle_t, bus_size_t, bus_size_t)
73 * Implementation specific structures.
74 * XXX Don't use outside of bus_space definitions!
75 * XXX maybe this should be encapsuled in a non-global .h file?
76 */
78 struct bus_space_tag {
79 bus_addr_t base;
80 const struct amiga_bus_space_methods *absm;
83 struct amiga_bus_space_methods {
85 /* map, unmap, etc */
87 int (*bsm)(bus_space_tag_t,
88 bus_addr_t, bus_size_t, int, bus_space_handle_t *);
90 int (*bsms)(bus_space_handle_t,
91 bus_size_t, bus_size_t, bus_space_handle_t *);
93 void (*bsu)(bus_space_handle_t, bus_size_t);
95 /* placeholders for currently not implemented alloc and free */
97 void *bsa;
98 void *bsf;
100 /* 8 bit methods */
102 bsr(*bsr1, u_int8_t);
103 bsw(*bsw1, u_int8_t);
104 bsrm(*bsrm1, u_int8_t);
105 bswm(*bswm1, u_int8_t);
106 bsrm(*bsrr1, u_int8_t);
107 bswm(*bswr1, u_int8_t);
108 bssr(*bssr1, u_int8_t);
109 bscr(*bscr1, u_int8_t);
111 /* 16bit methods */
113 bsr(*bsr2, u_int16_t);
114 bsw(*bsw2, u_int16_t);
115 bsr(*bsrs2, u_int16_t);
116 bsw(*bsws2, u_int16_t);
117 bsrm(*bsrm2, u_int16_t);
118 bswm(*bswm2, u_int16_t);
119 bsrm(*bsrms2, u_int16_t);
120 bswm(*bswms2, u_int16_t);
121 bsrm(*bsrr2, u_int16_t);
122 bswm(*bswr2, u_int16_t);
123 bsrm(*bsrrs2, u_int16_t);
124 bswm(*bswrs2, u_int16_t);
125 bssr(*bssr2, u_int16_t);
126 bscr(*bscr2, u_int16_t);
128 /* add 32bit methods here */
132 * Macro definition of map, unmap, etc.
135 #define bus_space_map(t, o, s, f, hp) \
136 ((t)->absm->bsm)((t), (o), (s), (f), (hp))
138 #define bus_space_subregion(t, h, o, s, hp) \
139 ((t)->absm->bsms)((h), (o), (s), (hp))
141 #define bus_space_unmap(t, h, s) \
142 ((t)->absm->bsu)((h), (s))
145 * Macro definition of _2 functions as indirect method array calls
148 /* 0: Helper macros */
150 #define dbsdr(n, t, h, o) ((t)->absm->n)((h), (o))
151 #define dbsdw(n, t, h, o, v) ((t)->absm->n)((h), (o), (v))
152 #define dbsm(n, t, h, o, p, c) ((t)->absm->n)((h), (o), (p), (c))
153 #define dbss(n, t, h, o, v, c) ((t)->absm->n)((h), (o), (v), (c))
154 #define dbsc(n, t, h, o, v, c) ((t)->absm->n)((h), (o), (v), (c))
156 /* 1: byte-wide "functions" */
158 #define bus_space_read_1(t, h, o) dbsdr(bsr1, t, h, o)
159 #define bus_space_write_1(t, h, o, v) dbsdw(bsw1, t, h, o, v)
161 #define bus_space_read_multi_1(t, h, o, p, c) dbsm(bsrm1, t, h, o, p, c)
162 #define bus_space_write_multi_1(t, h, o, p, c) dbsm(bswm1, t, h, o, p, c)
164 #define bus_space_read_region_1(t, h, o, p, c) dbsm(bsrr1, t, h, o, p, c)
165 #define bus_space_write_region_1(t, h, o, p, c) dbsm(bswr1, t, h, o, p, c)
167 #define bus_space_set_region_1(t, h, o, v, c) dbss(bssr1, t, h, o, v, c)
168 #define bus_space_copy_region_1(t, h, o, g, q, c) dbss(bscr1, t, h, o, g, q, c)
171 /* 2: word-wide "functions" */
173 #define bus_space_read_2(t, h, o) dbsdr(bsr2, t, h, o)
174 #define bus_space_write_2(t, h, o, v) dbsdw(bsw2, t, h, o, v)
175 #define bus_space_read_stream_2(t, h, o) dbsdr(bsrs2, t, h, o)
176 #define bus_space_write_stream_2(t, h, o, v) dbsdw(bsws2, t, h, o, v)
178 #define bus_space_read_multi_2(t, h, o, p, c) dbsm(bsrm2, t, h, o, p, c)
179 #define bus_space_write_multi_2(t, h, o, p, c) dbsm(bswm2, t, h, o, p, c)
181 #define bus_space_read_multi_stream_2(t, h, o, p, c) \
182 dbsm(bsrms2, t, h, o, p, c)
184 #define bus_space_write_multi_stream_2(t, h, o, p, c) \
185 dbsm(bswms2, t, h, o, p, c)
187 #define bus_space_read_region_2(t, h, o, p, c) dbsm(bsrr2, t, h, o, p, c)
188 #define bus_space_write_region_2(t, h, o, p, c) dbsm(bswr2, t, h, o, p, c)
190 #define bus_space_read_region_stream_2(t, h, o, p, c) \
191 dbsm(bsrrs2, t, h, o, p, c)
193 #define bus_space_write_region_stream_2(t, h, o, p, c) \
194 dbsm(bswrs2, t, h, o, p, c)
196 #define bus_space_set_region_2(t, h, o, v, c) dbss(bssr2, t, h, o, v, c)
197 #define bus_space_copy_region_2(t, h, o, g, q, c) dbss(bscr2, t, h, o, g, q, c)
199 /* 4: Fake 32-bit macros */
201 #define bus_space_read_4(t, h, o) \
202 (panic("bus_space_read_4 not implemented"), 0)
204 #define bus_space_write_4(t, h, o, v) \
205 panic("bus_space_write_4 not implemented")
207 #define bus_space_read_stream_4(t, h, o) \
208 (panic("bus_space_read_stream_4 not implemented"), 0)
210 #define bus_space_write_stream_4(t, h, o, v) \
211 panic("bus_space_read_stream_4 not implemented")
213 #define bus_space_read_multi_4(t, h, o, p, c) \
214 panic("bus_space_read_multi_4 not implemented")
216 #define bus_space_write_multi_4(t, h, o, p, c) \
217 panic("bus_space_write_multi_4 not implemented")
219 #define bus_space_read_multi_stream_4(t, h, o, p, c) \
220 panic("bus_space_read_multi_stream_4 not implemented")
222 #define bus_space_write_multi_stream_4(t, h, o, p, c) \
223 panic("bus_space_write_multi_stream_4 not implemented")
225 #define bus_space_read_region_stream_4(t, h, o, p, c) \
226 panic("bus_space_read_region_stream_4 not implemented")
228 #define bus_space_write_region_stream_4(t, h, o, p, c) \
229 panic("bus_space_write_region_stream_4 not implemented")
232 * Bus read/write barrier methods.
234 * void bus_space_barrier __P((bus_space_tag_t tag,
235 * bus_space_handle_t bsh, bus_size_t offset,
236 * bus_size_t len, int flags));
238 * Note: the 680x0 does not currently require barriers, but we must
239 * provide the flags to MI code.
241 #define bus_space_barrier(t, h, o, l, f) \
242 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
243 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
244 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
246 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
248 #define __BUS_SPACE_HAS_STREAM_METHODS
250 extern const struct amiga_bus_space_methods amiga_bus_stride_1;
251 extern const struct amiga_bus_space_methods amiga_bus_stride_2;
252 extern const struct amiga_bus_space_methods amiga_bus_stride_4;
253 extern const struct amiga_bus_space_methods amiga_bus_stride_4swap;
254 extern const struct amiga_bus_space_methods amiga_bus_stride_16;
256 #endif /* _AMIGA_BUS_H_ */