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