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