bus.h revision 1.21 1 /* $NetBSD: bus.h,v 1.21 2007/03/04 05:59:53 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1997, 1998, 2001 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 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
42 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
43 *
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by Christopher G. Demetriou
55 * for the NetBSD Project.
56 * 4. The name of the author may not be used to endorse or promote products
57 * derived from this software without specific prior written permission
58 *
59 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
60 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
61 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
62 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
63 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
65 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
66 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
68 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69 */
70
71 /*
72 * derived from arch/arm/include/bus.h Rev. 1.3
73 */
74
75 #ifndef _SYS_BUS_H_
76 #define _SYS_BUS_H_
77
78 #include <machine/bus_types.h>
79
80 #ifndef BUS_SPACE_MD_CALLS
81
82 #define BUS_SPACE_MAP_CACHEABLE 0x01
83 #define BUS_SPACE_MAP_LINEAR 0x02
84 #define BUS_SPACE_MAP_PREFETCHABLE 0x04
85
86 #define BUS_SPACE_BARRIER_READ 0x01
87 #define BUS_SPACE_BARRIER_WRITE 0x02
88
89 #ifndef BUS_SPACE_MD_TYPES
90 typedef struct bus_space_tag *bus_space_tag_t;
91 #endif
92
93 /*
94 * bus space operaion table
95 */
96 struct bus_space_ops {
97 /* mapping/unmapping */
98 int (*bs_map)(bus_space_tag_t, bus_addr_t, bus_size_t,
99 int, bus_space_handle_t *);
100 void (*bs_unmap)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
101 int (*bs_subregion)(bus_space_tag_t, bus_space_handle_t,
102 bus_size_t, bus_size_t, bus_space_handle_t *);
103
104 /* allocation/deallocation */
105 int (*bs_alloc)(bus_space_tag_t, bus_addr_t,
106 bus_addr_t, bus_size_t, bus_size_t, bus_size_t,
107 int, bus_addr_t *, bus_space_handle_t *);
108 void (*bs_free)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
109
110 /* get kernel virtual address */
111 void * (*bs_vaddr)(bus_space_tag_t, bus_space_handle_t);
112
113 /* mmap bus space for user */
114 paddr_t (*bs_mmap)(bus_space_tag_t, bus_addr_t, off_t, int, int);
115
116 /* barrier */
117 void (*bs_barrier)(bus_space_tag_t, bus_space_handle_t,
118 bus_size_t, bus_size_t, int);
119
120 /* probe */
121 int (*bs_peek)(bus_space_tag_t, bus_space_handle_t,
122 bus_size_t, size_t, void *);
123 int (*bs_poke)(bus_space_tag_t, bus_space_handle_t,
124 bus_size_t, size_t, u_int32_t);
125
126 /* read (single) */
127 u_int8_t (*bs_r_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
128 u_int16_t (*bs_r_2)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
129 u_int32_t (*bs_r_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
130 u_int64_t (*bs_r_8)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
131
132 /* read multiple */
133 void (*bs_rm_1)(bus_space_tag_t, bus_space_handle_t,
134 bus_size_t, u_int8_t *, bus_size_t);
135 void (*bs_rm_2)(bus_space_tag_t, bus_space_handle_t,
136 bus_size_t, u_int16_t *, bus_size_t);
137 void (*bs_rm_4)(bus_space_tag_t, bus_space_handle_t,
138 bus_size_t, u_int32_t *, bus_size_t);
139 void (*bs_rm_8)(bus_space_tag_t, bus_space_handle_t,
140 bus_size_t, u_int64_t *, bus_size_t);
141
142 /* read region */
143 void (*bs_rr_1)(bus_space_tag_t, bus_space_handle_t,
144 bus_size_t, u_int8_t *, bus_size_t);
145 void (*bs_rr_2)(bus_space_tag_t, bus_space_handle_t,
146 bus_size_t, u_int16_t *, bus_size_t);
147 void (*bs_rr_4)(bus_space_tag_t, bus_space_handle_t,
148 bus_size_t, u_int32_t *, bus_size_t);
149 void (*bs_rr_8)(bus_space_tag_t, bus_space_handle_t,
150 bus_size_t, u_int64_t *, bus_size_t);
151
152 /* write (single) */
153 void (*bs_w_1)(bus_space_tag_t, bus_space_handle_t,
154 bus_size_t, u_int8_t);
155 void (*bs_w_2)(bus_space_tag_t, bus_space_handle_t,
156 bus_size_t, u_int16_t);
157 void (*bs_w_4)(bus_space_tag_t, bus_space_handle_t,
158 bus_size_t, u_int32_t);
159 void (*bs_w_8)(bus_space_tag_t, bus_space_handle_t,
160 bus_size_t, u_int64_t);
161
162 /* write multiple */
163 void (*bs_wm_1)(bus_space_tag_t, bus_space_handle_t,
164 bus_size_t, const u_int8_t *, bus_size_t);
165 void (*bs_wm_2)(bus_space_tag_t, bus_space_handle_t,
166 bus_size_t, const u_int16_t *, bus_size_t);
167 void (*bs_wm_4)(bus_space_tag_t, bus_space_handle_t,
168 bus_size_t, const u_int32_t *, bus_size_t);
169 void (*bs_wm_8)(bus_space_tag_t, bus_space_handle_t,
170 bus_size_t, const u_int64_t *, bus_size_t);
171
172 /* write region */
173 void (*bs_wr_1)(bus_space_tag_t, bus_space_handle_t,
174 bus_size_t, const u_int8_t *, bus_size_t);
175 void (*bs_wr_2)(bus_space_tag_t, bus_space_handle_t,
176 bus_size_t, const u_int16_t *, bus_size_t);
177 void (*bs_wr_4)(bus_space_tag_t, bus_space_handle_t,
178 bus_size_t, const u_int32_t *, bus_size_t);
179 void (*bs_wr_8)(bus_space_tag_t, bus_space_handle_t,
180 bus_size_t, const u_int64_t *, bus_size_t);
181
182 #ifdef BUS_SPACE_HAS_REAL_STREAM_METHODS
183 /* read (single) stream */
184 u_int8_t (*bs_rs_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
185 u_int16_t (*bs_rs_2)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
186 u_int32_t (*bs_rs_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
187 u_int64_t (*bs_rs_8)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
188
189 /* read multiple stream */
190 void (*bs_rms_1)(bus_space_tag_t, bus_space_handle_t,
191 bus_size_t, u_int8_t *, bus_size_t);
192 void (*bs_rms_2)(bus_space_tag_t, bus_space_handle_t,
193 bus_size_t, u_int16_t *, bus_size_t);
194 void (*bs_rms_4)(bus_space_tag_t, bus_space_handle_t,
195 bus_size_t, u_int32_t *, bus_size_t);
196 void (*bs_rms_8)(bus_space_tag_t, bus_space_handle_t,
197 bus_size_t, u_int64_t *, bus_size_t);
198
199 /* read region stream */
200 void (*bs_rrs_1)(bus_space_tag_t, bus_space_handle_t,
201 bus_size_t, u_int8_t *, bus_size_t);
202 void (*bs_rrs_2)(bus_space_tag_t, bus_space_handle_t,
203 bus_size_t, u_int16_t *, bus_size_t);
204 void (*bs_rrs_4)(bus_space_tag_t, bus_space_handle_t,
205 bus_size_t, u_int32_t *, bus_size_t);
206 void (*bs_rrs_8)(bus_space_tag_t, bus_space_handle_t,
207 bus_size_t, u_int64_t *, bus_size_t);
208
209 /* write (single) stream */
210 void (*bs_ws_1)(bus_space_tag_t, bus_space_handle_t,
211 bus_size_t, u_int8_t);
212 void (*bs_ws_2)(bus_space_tag_t, bus_space_handle_t,
213 bus_size_t, u_int16_t);
214 void (*bs_ws_4)(bus_space_tag_t, bus_space_handle_t,
215 bus_size_t, u_int32_t);
216 void (*bs_ws_8)(bus_space_tag_t, bus_space_handle_t,
217 bus_size_t, u_int64_t);
218
219 /* write multiple stream */
220 void (*bs_wms_1)(bus_space_tag_t, bus_space_handle_t,
221 bus_size_t, const u_int8_t *, bus_size_t);
222 void (*bs_wms_2)(bus_space_tag_t, bus_space_handle_t,
223 bus_size_t, const u_int16_t *, bus_size_t);
224 void (*bs_wms_4)(bus_space_tag_t, bus_space_handle_t,
225 bus_size_t, const u_int32_t *, bus_size_t);
226 void (*bs_wms_8)(bus_space_tag_t, bus_space_handle_t,
227 bus_size_t, const u_int64_t *, bus_size_t);
228
229 /* write region stream */
230 void (*bs_wrs_1)(bus_space_tag_t, bus_space_handle_t,
231 bus_size_t, const u_int8_t *, bus_size_t);
232 void (*bs_wrs_2)(bus_space_tag_t, bus_space_handle_t,
233 bus_size_t, const u_int16_t *, bus_size_t);
234 void (*bs_wrs_4)(bus_space_tag_t, bus_space_handle_t,
235 bus_size_t, const u_int32_t *, bus_size_t);
236 void (*bs_wrs_8)(bus_space_tag_t, bus_space_handle_t,
237 bus_size_t, const u_int64_t *, bus_size_t);
238 #endif /* BUS_SPACE_HAS_REAL_STREAM_METHODS */
239
240 /* set multiple */
241 void (*bs_sm_1)(bus_space_tag_t, bus_space_handle_t,
242 bus_size_t, u_int8_t, bus_size_t);
243 void (*bs_sm_2)(bus_space_tag_t, bus_space_handle_t,
244 bus_size_t, u_int16_t, bus_size_t);
245 void (*bs_sm_4)(bus_space_tag_t, bus_space_handle_t,
246 bus_size_t, u_int32_t, bus_size_t);
247 void (*bs_sm_8)(bus_space_tag_t, bus_space_handle_t,
248 bus_size_t, u_int64_t, bus_size_t);
249
250 /* set region */
251 void (*bs_sr_1)(bus_space_tag_t, bus_space_handle_t,
252 bus_size_t, u_int8_t, bus_size_t);
253 void (*bs_sr_2)(bus_space_tag_t, bus_space_handle_t,
254 bus_size_t, u_int16_t, bus_size_t);
255 void (*bs_sr_4)(bus_space_tag_t, bus_space_handle_t,
256 bus_size_t, u_int32_t, bus_size_t);
257 void (*bs_sr_8)(bus_space_tag_t, bus_space_handle_t,
258 bus_size_t, u_int64_t, bus_size_t);
259
260 /* copy */
261 void (*bs_c_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
262 bus_space_handle_t, bus_size_t, bus_size_t);
263 void (*bs_c_2)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
264 bus_space_handle_t, bus_size_t, bus_size_t);
265 void (*bs_c_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
266 bus_space_handle_t, bus_size_t, bus_size_t);
267 void (*bs_c_8)(bus_space_tag_t, bus_space_handle_t, bus_size_t,
268 bus_space_handle_t, bus_size_t, bus_size_t);
269 };
270
271
272 /*
273 * Utility macros; INTERNAL USE ONLY.
274 */
275 #define __bs_c(a,b) __CONCAT(a,b)
276 #define __bs_opname(op,s) __bs_c(__bs_c(__bs_c(bs_,op),_),s)
277 #define __bs_popname(pfx,op,s) __bs_c(pfx,__bs_c(_,__bs_opname(op,s)))
278 #define __bs_ops(t) (((bus_space_tag_t)(t))->bs_ops)
279
280 #define __bs_rs(sz, t, h, o) \
281 (*__bs_ops(t).__bs_opname(r,sz))(t, h, o)
282 #define __bs_ws(sz, t, h, o, v) \
283 (*__bs_ops(t).__bs_opname(w,sz))(t, h, o, v)
284 #ifdef BUS_SPACE_HAS_REAL_STREAM_METHODS
285 #define __bs_rss(sz, t, h, o) \
286 (*__bs_ops(t).__bs_opname(rs,sz))(t, h, o)
287 #define __bs_wss(sz, t, h, o, v) \
288 (*__bs_ops(t).__bs_opname(ws,sz))(t, h, o, v)
289 #endif /* BUS_SPACE_HAS_REAL_STREAM_METHODS */
290 #define __bs_nonsingle(type, sz, t, h, o, a, c) \
291 (*__bs_ops(t).__bs_opname(type,sz))(t, h, o, a, c)
292 #define __bs_set(type, sz, t, h, o, v, c) \
293 (*__bs_ops(t).__bs_opname(type,sz))(t, h, o, v, c)
294 #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \
295 (*__bs_ops(t).__bs_opname(c,sz))(t, h1, o1, h2, o2, cnt)
296
297
298 /*
299 * Mapping and unmapping operations.
300 */
301 #define bus_space_map(t, a, s, c, hp) \
302 (*__bs_ops(t).bs_map)(t, (a), (s), (c), (hp))
303 #define bus_space_unmap(t, h, s) \
304 (*__bs_ops(t).bs_unmap)(t, (h), (s))
305 #define bus_space_subregion(t, h, o, s, hp) \
306 (*__bs_ops(t).bs_subregion)(t, (h), (o), (s), (hp))
307
308
309 /*
310 * Allocation and deallocation operations.
311 */
312 #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \
313 (*__bs_ops(t).bs_alloc)(t, (rs), (re), (s), (a), (b), (c), (ap), (hp))
314 #define bus_space_free(t, h, s) \
315 (*__bs_ops(t).bs_free)(t, (h), (s))
316
317
318 /*
319 * Get kernel virtual address for ranges mapped BUS_SPACE_MAP_LINEAR.
320 */
321 #define bus_space_vaddr(t, h) \
322 (*__bs_ops(t).bs_vaddr)(t, (h))
323
324
325 /*
326 * MMap bus space for a user application.
327 */
328 #define bus_space_mmap(t, a, o, p, f) \
329 (*__bs_ops(t).bs_mmap)(t, (a), (o), (p), (f))
330
331
332 /*
333 * Bus barrier operations.
334 */
335 #define bus_space_barrier(t, h, o, l, f) \
336 (*__bs_ops(t).bs_barrier)(t, (h), (o), (l), (f))
337
338
339 /*
340 * Bus probe operations.
341 */
342 #define bus_space_peek(t, h, o, s, p) \
343 (*__bs_ops(t).bs_peek)(t, (h), (o), (s), (p))
344 #define bus_space_poke(t, h, o, s, v) \
345 (*__bs_ops(t).bs_poke)(t, (h), (o), (s), (v))
346
347
348 /*
349 * Bus read (single) operations.
350 */
351 #define bus_space_read_1(t, h, o) __bs_rs(1,(t),(h),(o))
352 #define bus_space_read_2(t, h, o) __bs_rs(2,(t),(h),(o))
353 #define bus_space_read_4(t, h, o) __bs_rs(4,(t),(h),(o))
354 #define bus_space_read_8(t, h, o) __bs_rs(8,(t),(h),(o))
355
356
357 /*
358 * Bus read multiple operations.
359 */
360 #define bus_space_read_multi_1(t, h, o, a, c) \
361 __bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
362 #define bus_space_read_multi_2(t, h, o, a, c) \
363 __bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
364 #define bus_space_read_multi_4(t, h, o, a, c) \
365 __bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
366 #define bus_space_read_multi_8(t, h, o, a, c) \
367 __bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
368
369
370 /*
371 * Bus read region operations.
372 */
373 #define bus_space_read_region_1(t, h, o, a, c) \
374 __bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
375 #define bus_space_read_region_2(t, h, o, a, c) \
376 __bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
377 #define bus_space_read_region_4(t, h, o, a, c) \
378 __bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
379 #define bus_space_read_region_8(t, h, o, a, c) \
380 __bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
381
382
383 /*
384 * Bus write (single) operations.
385 */
386 #define bus_space_write_1(t, h, o, v) __bs_ws(1,(t),(h),(o),(v))
387 #define bus_space_write_2(t, h, o, v) __bs_ws(2,(t),(h),(o),(v))
388 #define bus_space_write_4(t, h, o, v) __bs_ws(4,(t),(h),(o),(v))
389 #define bus_space_write_8(t, h, o, v) __bs_ws(8,(t),(h),(o),(v))
390
391
392 /*
393 * Bus write multiple operations.
394 */
395 #define bus_space_write_multi_1(t, h, o, a, c) \
396 __bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
397 #define bus_space_write_multi_2(t, h, o, a, c) \
398 __bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
399 #define bus_space_write_multi_4(t, h, o, a, c) \
400 __bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
401 #define bus_space_write_multi_8(t, h, o, a, c) \
402 __bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
403
404
405 /*
406 * Bus write region operations.
407 */
408 #define bus_space_write_region_1(t, h, o, a, c) \
409 __bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
410 #define bus_space_write_region_2(t, h, o, a, c) \
411 __bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
412 #define bus_space_write_region_4(t, h, o, a, c) \
413 __bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
414 #define bus_space_write_region_8(t, h, o, a, c) \
415 __bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
416
417
418 #ifdef BUS_SPACE_HAS_REAL_STREAM_METHODS
419 /*
420 * Bus read (single) stream operations.
421 */
422 #define bus_space_read_stream_1(t, h, o) __bs_rss(1,(t),(h),(o))
423 #define bus_space_read_stream_2(t, h, o) __bs_rss(2,(t),(h),(o))
424 #define bus_space_read_stream_4(t, h, o) __bs_rss(4,(t),(h),(o))
425 #define bus_space_read_stream_8(t, h, o) __bs_rss(8,(t),(h),(o))
426
427
428 /*
429 * Bus read multiple operations.
430 */
431 #define bus_space_read_multi_stream_1(t, h, o, a, c) \
432 __bs_nonsingle(rms,1,(t),(h),(o),(a),(c))
433 #define bus_space_read_multi_stream_2(t, h, o, a, c) \
434 __bs_nonsingle(rms,2,(t),(h),(o),(a),(c))
435 #define bus_space_read_multi_stream_4(t, h, o, a, c) \
436 __bs_nonsingle(rms,4,(t),(h),(o),(a),(c))
437 #define bus_space_read_multi_stream_8(t, h, o, a, c) \
438 __bs_nonsingle(rms,8,(t),(h),(o),(a),(c))
439
440
441 /*
442 * Bus read region operations.
443 */
444 #define bus_space_read_region_stream_1(t, h, o, a, c) \
445 __bs_nonsingle(rrs,1,(t),(h),(o),(a),(c))
446 #define bus_space_read_region_stream_2(t, h, o, a, c) \
447 __bs_nonsingle(rrs,2,(t),(h),(o),(a),(c))
448 #define bus_space_read_region_stream_4(t, h, o, a, c) \
449 __bs_nonsingle(rrs,4,(t),(h),(o),(a),(c))
450 #define bus_space_read_region_stream_8(t, h, o, a, c) \
451 __bs_nonsingle(rrs,8,(t),(h),(o),(a),(c))
452
453
454 /*
455 * Bus write (single) operations.
456 */
457 #define bus_space_write_stream_1(t, h, o, v) __bs_wss(1,(t),(h),(o),(v))
458 #define bus_space_write_stream_2(t, h, o, v) __bs_wss(2,(t),(h),(o),(v))
459 #define bus_space_write_stream_4(t, h, o, v) __bs_wss(4,(t),(h),(o),(v))
460 #define bus_space_write_stream_8(t, h, o, v) __bs_wss(8,(t),(h),(o),(v))
461
462
463 /*
464 * Bus write multiple operations.
465 */
466 #define bus_space_write_multi_stream_1(t, h, o, a, c) \
467 __bs_nonsingle(wms,1,(t),(h),(o),(a),(c))
468 #define bus_space_write_multi_stream_2(t, h, o, a, c) \
469 __bs_nonsingle(wms,2,(t),(h),(o),(a),(c))
470 #define bus_space_write_multi_stream_4(t, h, o, a, c) \
471 __bs_nonsingle(wms,4,(t),(h),(o),(a),(c))
472 #define bus_space_write_multi_stream_8(t, h, o, a, c) \
473 __bs_nonsingle(wms,8,(t),(h),(o),(a),(c))
474
475
476 /*
477 * Bus write region operations.
478 */
479 #define bus_space_write_region_stream_1(t, h, o, a, c) \
480 __bs_nonsingle(wrs,1,(t),(h),(o),(a),(c))
481 #define bus_space_write_region_stream_2(t, h, o, a, c) \
482 __bs_nonsingle(wrs,2,(t),(h),(o),(a),(c))
483 #define bus_space_write_region_stream_4(t, h, o, a, c) \
484 __bs_nonsingle(wrs,4,(t),(h),(o),(a),(c))
485 #define bus_space_write_region_stream_8(t, h, o, a, c) \
486 __bs_nonsingle(wrs,8,(t),(h),(o),(a),(c))
487 #else
488 #ifdef __BUS_SPACE_HAS_STREAM_METHODS
489 #define bus_space_read_stream_1 bus_space_read_1
490 #define bus_space_read_stream_2 bus_space_read_2
491 #define bus_space_read_stream_4 bus_space_read_4
492 #define bus_space_read_stream_8 bus_space_read_8
493 #define bus_space_read_multi_stream_1 bus_space_read_multi_1
494 #define bus_space_read_multi_stream_2 bus_space_read_multi_2
495 #define bus_space_read_multi_stream_4 bus_space_read_multi_4
496 #define bus_space_read_multi_stream_8 bus_space_read_multi_8
497 #define bus_space_read_region_stream_1 bus_space_read_region_1
498 #define bus_space_read_region_stream_2 bus_space_read_region_2
499 #define bus_space_read_region_stream_4 bus_space_read_region_4
500 #define bus_space_read_region_stream_8 bus_space_read_region_8
501 #define bus_space_write_stream_1 bus_space_write_1
502 #define bus_space_write_stream_2 bus_space_write_2
503 #define bus_space_write_stream_4 bus_space_write_4
504 #define bus_space_write_stream_8 bus_space_write_8
505 #define bus_space_write_multi_stream_1 bus_space_write_multi_1
506 #define bus_space_write_multi_stream_2 bus_space_write_multi_2
507 #define bus_space_write_multi_stream_4 bus_space_write_multi_4
508 #define bus_space_write_multi_stream_8 bus_space_write_multi_8
509 #define bus_space_write_region_stream_1 bus_space_write_region_1
510 #define bus_space_write_region_stream_2 bus_space_write_region_2
511 #define bus_space_write_region_stream_4 bus_space_write_region_4
512 #define bus_space_write_region_stream_8 bus_space_write_region_8
513 #endif /* __BUS_SPACE_HAS_STREAM_METHODS */
514 #endif /* BUS_SPACE_HAS_REAL_STREAM_METHODS */
515
516
517 /*
518 * Set multiple operations.
519 */
520 #define bus_space_set_multi_1(t, h, o, v, c) \
521 __bs_set(sm,1,(t),(h),(o),(v),(c))
522 #define bus_space_set_multi_2(t, h, o, v, c) \
523 __bs_set(sm,2,(t),(h),(o),(v),(c))
524 #define bus_space_set_multi_4(t, h, o, v, c) \
525 __bs_set(sm,4,(t),(h),(o),(v),(c))
526 #define bus_space_set_multi_8(t, h, o, v, c) \
527 __bs_set(sm,8,(t),(h),(o),(v),(c))
528
529
530 /*
531 * Set region operations.
532 */
533 #define bus_space_set_region_1(t, h, o, v, c) \
534 __bs_set(sr,1,(t),(h),(o),(v),(c))
535 #define bus_space_set_region_2(t, h, o, v, c) \
536 __bs_set(sr,2,(t),(h),(o),(v),(c))
537 #define bus_space_set_region_4(t, h, o, v, c) \
538 __bs_set(sr,4,(t),(h),(o),(v),(c))
539 #define bus_space_set_region_8(t, h, o, v, c) \
540 __bs_set(sr,8,(t),(h),(o),(v),(c))
541
542
543 /*
544 * Copy operations.
545 */
546 #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
547 __bs_copy(1, t, h1, o1, h2, o2, c)
548 #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
549 __bs_copy(2, t, h1, o1, h2, o2, c)
550 #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
551 __bs_copy(4, t, h1, o1, h2, o2, c)
552 #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
553 __bs_copy(8, t, h1, o1, h2, o2, c)
554
555
556 /*
557 * Macros to provide prototypes for all the functions used in the
558 * bus_space structure
559 */
560 #define bs_map_proto(f) \
561 int __bs_c(f,_bs_map)(bus_space_tag_t t, bus_addr_t addr, \
562 bus_size_t size, int cacheable, bus_space_handle_t *bshp)
563
564 #define bs_unmap_proto(f) \
565 void __bs_c(f,_bs_unmap)(bus_space_tag_t t, bus_space_handle_t bsh, \
566 bus_size_t size)
567
568 #define bs_subregion_proto(f) \
569 int __bs_c(f,_bs_subregion)(bus_space_tag_t t, \
570 bus_space_handle_t bsh, bus_size_t offset, \
571 bus_size_t size, bus_space_handle_t *nbshp)
572
573 #define bs_alloc_proto(f) \
574 int __bs_c(f,_bs_alloc)(bus_space_tag_t t, bus_addr_t rstart, \
575 bus_addr_t rend, bus_size_t size, bus_size_t align, \
576 bus_size_t boundary, int cacheable, bus_addr_t *addrp, \
577 bus_space_handle_t *bshp)
578
579 #define bs_free_proto(f) \
580 void __bs_c(f,_bs_free)(bus_space_tag_t t, bus_space_handle_t bsh, \
581 bus_size_t size)
582
583 #define bs_vaddr_proto(f) \
584 void * __bs_c(f,_bs_vaddr)(bus_space_tag_t t, bus_space_handle_t bsh)
585
586 #define bs_mmap_proto(f) \
587 paddr_t __bs_c(f,_bs_mmap)(bus_space_tag_t t, bus_addr_t addr, \
588 off_t offset, int prot, int flags)
589
590 #define bs_barrier_proto(f) \
591 void __bs_c(f,_bs_barrier)(bus_space_tag_t t, bus_space_handle_t bsh,\
592 bus_size_t offset, bus_size_t len, int flags)
593
594 #define bs_peek_proto(f) \
595 int __bs_c(f,_bs_peek)(bus_space_tag_t t, bus_space_handle_t bsh, \
596 bus_size_t offset, size_t len, void *ptr)
597 #define bs_poke_proto(f) \
598 int __bs_c(f,_bs_poke)(bus_space_tag_t t, bus_space_handle_t bsh, \
599 bus_size_t offset, size_t len, u_int32_t val)
600
601 #define bs_r_1_proto(f) \
602 u_int8_t __bs_c(f,_bs_r_1)(bus_space_tag_t t, \
603 bus_space_handle_t bsh, bus_size_t offset)
604 #define bs_r_2_proto(f) \
605 u_int16_t __bs_c(f,_bs_r_2)(bus_space_tag_t t, \
606 bus_space_handle_t bsh, bus_size_t offset)
607 #define bs_r_4_proto(f) \
608 u_int32_t __bs_c(f,_bs_r_4)(bus_space_tag_t t, \
609 bus_space_handle_t bsh, bus_size_t offset)
610 #define bs_r_8_proto(f) \
611 u_int64_t __bs_c(f,_bs_r_8)(bus_space_tag_t t, \
612 bus_space_handle_t bsh, bus_size_t offset)
613
614 #define bs_rm_1_proto(f) \
615 void __bs_c(f,_bs_rm_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
616 bus_size_t offset, u_int8_t *addr, bus_size_t count)
617 #define bs_rm_2_proto(f) \
618 void __bs_c(f,_bs_rm_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
619 bus_size_t offset, u_int16_t *addr, bus_size_t count)
620 #define bs_rm_4_proto(f) \
621 void __bs_c(f,_bs_rm_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
622 bus_size_t offset, u_int32_t *addr, bus_size_t count)
623 #define bs_rm_8_proto(f) \
624 void __bs_c(f,_bs_rm_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
625 bus_size_t offset, u_int64_t *addr, bus_size_t count)
626
627 #define bs_rr_1_proto(f) \
628 void __bs_c(f,_bs_rr_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
629 bus_size_t offset, u_int8_t *addr, bus_size_t count)
630 #define bs_rr_2_proto(f) \
631 void __bs_c(f,_bs_rr_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
632 bus_size_t offset, u_int16_t *addr, bus_size_t count)
633 #define bs_rr_4_proto(f) \
634 void __bs_c(f,_bs_rr_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
635 bus_size_t offset, u_int32_t *addr, bus_size_t count)
636 #define bs_rr_8_proto(f) \
637 void __bs_c(f,_bs_rr_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
638 bus_size_t offset, u_int64_t *addr, bus_size_t count)
639
640 #define bs_w_1_proto(f) \
641 void __bs_c(f,_bs_w_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
642 bus_size_t offset, u_int8_t value)
643 #define bs_w_2_proto(f) \
644 void __bs_c(f,_bs_w_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
645 bus_size_t offset, u_int16_t value)
646 #define bs_w_4_proto(f) \
647 void __bs_c(f,_bs_w_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
648 bus_size_t offset, u_int32_t value)
649 #define bs_w_8_proto(f) \
650 void __bs_c(f,_bs_w_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
651 bus_size_t offset, u_int64_t value)
652
653 #define bs_wm_1_proto(f) \
654 void __bs_c(f,_bs_wm_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
655 bus_size_t offset, const u_int8_t *addr, bus_size_t count)
656 #define bs_wm_2_proto(f) \
657 void __bs_c(f,_bs_wm_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
658 bus_size_t offset, const u_int16_t *addr, bus_size_t count)
659 #define bs_wm_4_proto(f) \
660 void __bs_c(f,_bs_wm_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
661 bus_size_t offset, const u_int32_t *addr, bus_size_t count)
662 #define bs_wm_8_proto(f) \
663 void __bs_c(f,_bs_wm_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
664 bus_size_t offset, const u_int64_t *addr, bus_size_t count)
665
666 #define bs_wr_1_proto(f) \
667 void __bs_c(f,_bs_wr_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
668 bus_size_t offset, const u_int8_t *addr, bus_size_t count)
669 #define bs_wr_2_proto(f) \
670 void __bs_c(f,_bs_wr_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
671 bus_size_t offset, const u_int16_t *addr, bus_size_t count)
672 #define bs_wr_4_proto(f) \
673 void __bs_c(f,_bs_wr_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
674 bus_size_t offset, const u_int32_t *addr, bus_size_t count)
675 #define bs_wr_8_proto(f) \
676 void __bs_c(f,_bs_wr_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
677 bus_size_t offset, const u_int64_t *addr, bus_size_t count)
678
679 #ifdef BUS_SPACE_HAS_REAL_STREAM_METHODS
680 #define bs_rs_1_proto(f) \
681 u_int8_t __bs_c(f,_bs_rs_1)(bus_space_tag_t t, \
682 bus_space_handle_t bsh, bus_size_t offset)
683 #define bs_rs_2_proto(f) \
684 u_int16_t __bs_c(f,_bs_rs_2)(bus_space_tag_t t, \
685 bus_space_handle_t bsh, bus_size_t offset)
686 #define bs_rs_4_proto(f) \
687 u_int32_t __bs_c(f,_bs_rs_4)(bus_space_tag_t t, \
688 bus_space_handle_t bsh, bus_size_t offset)
689 #define bs_rs_8_proto(f) \
690 u_int64_t __bs_c(f,_bs_rs_8)(bus_space_tag_t t, \
691 bus_space_handle_t bsh, bus_size_t offset)
692
693 #define bs_rms_1_proto(f) \
694 void __bs_c(f,_bs_rms_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
695 bus_size_t offset, u_int8_t *addr, bus_size_t count)
696 #define bs_rms_2_proto(f) \
697 void __bs_c(f,_bs_rms_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
698 bus_size_t offset, u_int16_t *addr, bus_size_t count)
699 #define bs_rms_4_proto(f) \
700 void __bs_c(f,_bs_rms_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
701 bus_size_t offset, u_int32_t *addr, bus_size_t count)
702 #define bs_rms_8_proto(f) \
703 void __bs_c(f,_bs_rms_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
704 bus_size_t offset, u_int64_t *addr, bus_size_t count)
705
706 #define bs_rrs_1_proto(f) \
707 void __bs_c(f,_bs_rrs_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
708 bus_size_t offset, u_int8_t *addr, bus_size_t count)
709 #define bs_rrs_2_proto(f) \
710 void __bs_c(f,_bs_rrs_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
711 bus_size_t offset, u_int16_t *addr, bus_size_t count)
712 #define bs_rrs_4_proto(f) \
713 void __bs_c(f,_bs_rrs_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
714 bus_size_t offset, u_int32_t *addr, bus_size_t count)
715 #define bs_rrs_8_proto(f) \
716 void __bs_c(f,_bs_rrs_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
717 bus_size_t offset, u_int64_t *addr, bus_size_t count)
718
719 #define bs_ws_1_proto(f) \
720 void __bs_c(f,_bs_ws_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
721 bus_size_t offset, u_int8_t value)
722 #define bs_ws_2_proto(f) \
723 void __bs_c(f,_bs_ws_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
724 bus_size_t offset, u_int16_t value)
725 #define bs_ws_4_proto(f) \
726 void __bs_c(f,_bs_ws_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
727 bus_size_t offset, u_int32_t value)
728 #define bs_ws_8_proto(f) \
729 void __bs_c(f,_bs_ws_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
730 bus_size_t offset, u_int64_t value)
731
732 #define bs_wms_1_proto(f) \
733 void __bs_c(f,_bs_wms_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
734 bus_size_t offset, const u_int8_t *addr, bus_size_t count)
735 #define bs_wms_2_proto(f) \
736 void __bs_c(f,_bs_wms_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
737 bus_size_t offset, const u_int16_t *addr, bus_size_t count)
738 #define bs_wms_4_proto(f) \
739 void __bs_c(f,_bs_wms_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
740 bus_size_t offset, const u_int32_t *addr, bus_size_t count)
741 #define bs_wms_8_proto(f) \
742 void __bs_c(f,_bs_wms_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
743 bus_size_t offset, const u_int64_t *addr, bus_size_t count)
744
745 #define bs_wrs_1_proto(f) \
746 void __bs_c(f,_bs_wrs_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
747 bus_size_t offset, const u_int8_t *addr, bus_size_t count)
748 #define bs_wrs_2_proto(f) \
749 void __bs_c(f,_bs_wrs_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
750 bus_size_t offset, const u_int16_t *addr, bus_size_t count)
751 #define bs_wrs_4_proto(f) \
752 void __bs_c(f,_bs_wrs_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
753 bus_size_t offset, const u_int32_t *addr, bus_size_t count)
754 #define bs_wrs_8_proto(f) \
755 void __bs_c(f,_bs_wrs_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
756 bus_size_t offset, const u_int64_t *addr, bus_size_t count)
757 #else /* BUS_SPACE_HAS_REAL_STREAM_METHODS */
758 #define bs_rs_1_proto(f)
759 #define bs_rs_2_proto(f)
760 #define bs_rs_4_proto(f)
761 #define bs_rs_8_proto(f)
762 #define bs_rms_1_proto(f)
763 #define bs_rms_2_proto(f)
764 #define bs_rms_4_proto(f)
765 #define bs_rms_8_proto(f)
766 #define bs_rrs_1_proto(f)
767 #define bs_rrs_2_proto(f)
768 #define bs_rrs_4_proto(f)
769 #define bs_rrs_8_proto(f)
770 #define bs_ws_1_proto(f)
771 #define bs_ws_2_proto(f)
772 #define bs_ws_4_proto(f)
773 #define bs_ws_8_proto(f)
774 #define bs_wms_1_proto(f)
775 #define bs_wms_2_proto(f)
776 #define bs_wms_4_proto(f)
777 #define bs_wms_8_proto(f)
778 #define bs_wrs_1_proto(f)
779 #define bs_wrs_2_proto(f)
780 #define bs_wrs_4_proto(f)
781 #define bs_wrs_8_proto(f)
782 #endif /* ! BUS_SPACE_HAS_REAL_STREAM_METHODS */
783
784 #define bs_sm_1_proto(f) \
785 void __bs_c(f,_bs_sm_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
786 bus_size_t offset, u_int8_t value, bus_size_t count)
787 #define bs_sm_2_proto(f) \
788 void __bs_c(f,_bs_sm_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
789 bus_size_t offset, u_int16_t value, bus_size_t count)
790 #define bs_sm_4_proto(f) \
791 void __bs_c(f,_bs_sm_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
792 bus_size_t offset, u_int32_t value, bus_size_t count)
793 #define bs_sm_8_proto(f) \
794 void __bs_c(f,_bs_sm_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
795 bus_size_t offset, u_int64_t value, bus_size_t count)
796
797 #define bs_sr_1_proto(f) \
798 void __bs_c(f,_bs_sr_1)(bus_space_tag_t t, bus_space_handle_t bsh, \
799 bus_size_t offset, u_int8_t value, bus_size_t count)
800 #define bs_sr_2_proto(f) \
801 void __bs_c(f,_bs_sr_2)(bus_space_tag_t t, bus_space_handle_t bsh, \
802 bus_size_t offset, u_int16_t value, bus_size_t count)
803 #define bs_sr_4_proto(f) \
804 void __bs_c(f,_bs_sr_4)(bus_space_tag_t t, bus_space_handle_t bsh, \
805 bus_size_t offset, u_int32_t value, bus_size_t count)
806 #define bs_sr_8_proto(f) \
807 void __bs_c(f,_bs_sr_8)(bus_space_tag_t t, bus_space_handle_t bsh, \
808 bus_size_t offset, u_int64_t value, bus_size_t count)
809
810 #define bs_c_1_proto(f) \
811 void __bs_c(f,_bs_c_1)(bus_space_tag_t t, bus_space_handle_t bsh1, \
812 bus_size_t offset1, bus_space_handle_t bsh2, \
813 bus_size_t offset2, bus_size_t count)
814 #define bs_c_2_proto(f) \
815 void __bs_c(f,_bs_c_2)(bus_space_tag_t t, bus_space_handle_t bsh1, \
816 bus_size_t offset1, bus_space_handle_t bsh2, \
817 bus_size_t offset2, bus_size_t count)
818 #define bs_c_4_proto(f) \
819 void __bs_c(f,_bs_c_4)(bus_space_tag_t t, bus_space_handle_t bsh1, \
820 bus_size_t offset1, bus_space_handle_t bsh2, \
821 bus_size_t offset2, bus_size_t count)
822 #define bs_c_8_proto(f) \
823 void __bs_c(f,_bs_c_8)(bus_space_tag_t t, bus_space_handle_t bsh1, \
824 bus_size_t offset1, bus_space_handle_t bsh2, \
825 bus_size_t offset2, bus_size_t count)
826
827
828 #define bus_space_protos(f) \
829 bs_map_proto(f); \
830 bs_unmap_proto(f); \
831 bs_subregion_proto(f); \
832 bs_alloc_proto(f); \
833 bs_free_proto(f); \
834 bs_vaddr_proto(f); \
835 bs_mmap_proto(f); \
836 bs_barrier_proto(f); \
837 bs_peek_proto(f); \
838 bs_poke_proto(f); \
839 bs_r_1_proto(f); \
840 bs_r_2_proto(f); \
841 bs_r_4_proto(f); \
842 bs_r_8_proto(f); \
843 bs_rm_1_proto(f); \
844 bs_rm_2_proto(f); \
845 bs_rm_4_proto(f); \
846 bs_rm_8_proto(f); \
847 bs_rr_1_proto(f); \
848 bs_rr_2_proto(f); \
849 bs_rr_4_proto(f); \
850 bs_rr_8_proto(f); \
851 bs_w_1_proto(f); \
852 bs_w_2_proto(f); \
853 bs_w_4_proto(f); \
854 bs_w_8_proto(f); \
855 bs_wm_1_proto(f); \
856 bs_wm_2_proto(f); \
857 bs_wm_4_proto(f); \
858 bs_wm_8_proto(f); \
859 bs_wr_1_proto(f); \
860 bs_wr_2_proto(f); \
861 bs_wr_4_proto(f); \
862 bs_wr_8_proto(f); \
863 bs_rs_1_proto(f); \
864 bs_rs_2_proto(f); \
865 bs_rs_4_proto(f); \
866 bs_rs_8_proto(f); \
867 bs_rms_1_proto(f); \
868 bs_rms_2_proto(f); \
869 bs_rms_4_proto(f); \
870 bs_rms_8_proto(f); \
871 bs_rrs_1_proto(f); \
872 bs_rrs_2_proto(f); \
873 bs_rrs_4_proto(f); \
874 bs_rrs_8_proto(f); \
875 bs_ws_1_proto(f); \
876 bs_ws_2_proto(f); \
877 bs_ws_4_proto(f); \
878 bs_ws_8_proto(f); \
879 bs_wms_1_proto(f); \
880 bs_wms_2_proto(f); \
881 bs_wms_4_proto(f); \
882 bs_wms_8_proto(f); \
883 bs_wrs_1_proto(f); \
884 bs_wrs_2_proto(f); \
885 bs_wrs_4_proto(f); \
886 bs_wrs_8_proto(f); \
887 bs_sm_1_proto(f); \
888 bs_sm_2_proto(f); \
889 bs_sm_4_proto(f); \
890 bs_sm_8_proto(f); \
891 bs_sr_1_proto(f); \
892 bs_sr_2_proto(f); \
893 bs_sr_4_proto(f); \
894 bs_sr_8_proto(f); \
895 bs_c_1_proto(f); \
896 bs_c_2_proto(f); \
897 bs_c_4_proto(f); \
898 bs_c_8_proto(f);
899
900 #endif /* ! BUS_SPACE_MD_CALLS */
901
902 #ifndef BUS_SPACE_MD_TYPES
903 #ifdef BUS_SPACE_MD_CALLS
904 typedef struct bus_space *bus_space_tag_t;
905 #endif /* BUS_SPACE_MD_CALLS */
906
907 /*
908 * bus_space_tag_t
909 *
910 * bus space tag structure
911 */
912 struct bus_space_tag {
913 bus_space_tag_t bs_base;
914 struct bus_space_ops bs_ops;
915 };
916 #endif /* ! BUS_SPACE_MD_TYPES */
917
918 #ifndef BUS_DMA_MD_CALLS
919
920 /*
921 * Flags used in various bus DMA methods.
922 */
923 #define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
924 #define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
925 #define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
926 #define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
927 #define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
928 #define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
929 #define BUS_DMA_BUS2 0x020
930 #define BUS_DMA_BUS3 0x040
931 #define BUS_DMA_BUS4 0x080
932 #define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
933 #define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
934 #define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
935
936 /*
937 * Operations performed by bus_dmamap_sync().
938 */
939 #define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
940 #define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
941 #define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
942 #define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
943
944 /* Forwards needed by prototypes below. */
945 struct mbuf;
946 struct uio;
947
948 #ifndef BUS_DMA_MD_TYPES
949 typedef struct bus_dma_tag *bus_dma_tag_t;
950 typedef struct bus_dma_segment bus_dma_segment_t;
951 typedef struct bus_dmamap *bus_dmamap_t;
952 #endif /* ! BUS_DMA_MD_TYPES */
953
954 #define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0)
955
956 /*
957 * bus DMA operaion table
958 */
959 struct bus_dma_ops {
960 /*
961 * DMA mapping methods.
962 */
963 int (*bd_map_create)(bus_dma_tag_t, bus_size_t, int,
964 bus_size_t, bus_size_t, int, bus_dmamap_t *);
965 void (*bd_map_destroy)(bus_dma_tag_t, bus_dmamap_t);
966 int (*bd_map_load)(bus_dma_tag_t, bus_dmamap_t, void *,
967 bus_size_t, struct proc *, int);
968 int (*bd_map_load_mbuf)(bus_dma_tag_t, bus_dmamap_t,
969 struct mbuf *, int);
970 int (*bd_map_load_uio)(bus_dma_tag_t, bus_dmamap_t,
971 struct uio *, int);
972 int (*bd_map_load_raw)(bus_dma_tag_t, bus_dmamap_t,
973 bus_dma_segment_t *, int, bus_size_t, int);
974 void (*bd_map_unload)(bus_dma_tag_t, bus_dmamap_t);
975 void (*bd_map_sync)(bus_dma_tag_t, bus_dmamap_t,
976 bus_addr_t, bus_size_t, int);
977
978 /*
979 * DMA memory utility functions.
980 */
981 int (*bd_mem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t,
982 bus_size_t, bus_dma_segment_t *, int, int *, int);
983 void (*bd_mem_free)(bus_dma_tag_t,
984 bus_dma_segment_t *, int);
985 int (*bd_mem_map)(bus_dma_tag_t, bus_dma_segment_t *,
986 int, size_t, void **, int);
987 void (*bd_mem_unmap)(bus_dma_tag_t, void *, size_t);
988 paddr_t (*bd_mem_mmap)(bus_dma_tag_t, bus_dma_segment_t *,
989 int, off_t, int, int);
990 };
991
992
993 /*
994 * bus DMA methods
995 */
996 #define __bd_ops(t) (((bus_dma_tag_t)(t))->bd_ops)
997 #define bus_dmamap_create(t, s, n, m, b, f, p) \
998 (*__bd_ops(t).bd_map_create)((t), (s), (n), (m), (b), (f), (p))
999 #define bus_dmamap_destroy(t, p) \
1000 (*__bd_ops(t).bd_map_destroy)((t), (p))
1001 #define bus_dmamap_load(t, m, b, s, p, f) \
1002 (*__bd_ops(t).bd_map_load)((t), (m), (b), (s), (p), (f))
1003 #define bus_dmamap_load_mbuf(t, m, b, f) \
1004 (*__bd_ops(t).bd_map_load_mbuf)((t), (m), (b), (f))
1005 #define bus_dmamap_load_uio(t, m, u, f) \
1006 (*__bd_ops(t).bd_map_load_uio)((t), (m), (u), (f))
1007 #define bus_dmamap_load_raw(t, m, sg, n, s, f) \
1008 (*__bd_ops(t).bd_map_load_raw)((t), (m), (sg), (n), (s), (f))
1009 #define bus_dmamap_unload(t, p) \
1010 (*__bd_ops(t).bd_map_unload)((t), (p))
1011 #define bus_dmamap_sync(t, p, o, l, ops) \
1012 (void)(__bd_ops(t).bd_map_sync ? \
1013 (*__bd_ops(t).bd_map_sync)((t), (p), (o), (l), (ops)) : (void)0)
1014
1015 #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
1016 (*__bd_ops(t).bd_mem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
1017 #define bus_dmamem_free(t, sg, n) \
1018 (*__bd_ops(t).bd_mem_free)((t), (sg), (n))
1019 #define bus_dmamem_map(t, sg, n, s, k, f) \
1020 (*__bd_ops(t).bd_mem_map)((t), (sg), (n), (s), (k), (f))
1021 #define bus_dmamem_unmap(t, k, s) \
1022 (*__bd_ops(t).bd_mem_unmap)((t), (k), (s))
1023 #define bus_dmamem_mmap(t, sg, n, o, p, f) \
1024 (*__bd_ops(t).bd_mem_mmap)((t), (sg), (n), (o), (p), (f))
1025
1026 #define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP
1027 #define bus_dmatag_destroy(t)
1028
1029 /*
1030 * Macros to provide prototypes for all the functions used in the
1031 * bus_dma structure
1032 */
1033 #define bus_dma_protos(f) \
1034 int __bs_c(f,_bd_map_create)(bus_dma_tag_t, bus_size_t, int, \
1035 bus_size_t, bus_size_t, int, bus_dmamap_t *); \
1036 void __bs_c(f,_bd_map_destroy)(bus_dma_tag_t, bus_dmamap_t); \
1037 int __bs_c(f,_bd_map_load)(bus_dma_tag_t, bus_dmamap_t, void *, \
1038 bus_size_t, struct proc *, int); \
1039 int __bs_c(f,_bd_map_load_mbuf)(bus_dma_tag_t, bus_dmamap_t, \
1040 struct mbuf *, int); \
1041 int __bs_c(f,_bd_map_load_uio)(bus_dma_tag_t, bus_dmamap_t, \
1042 struct uio *, int); \
1043 int __bs_c(f,_bd_map_load_raw)(bus_dma_tag_t, bus_dmamap_t, \
1044 bus_dma_segment_t *, int, bus_size_t, int); \
1045 void __bs_c(f,_bd_map_unload)(bus_dma_tag_t, bus_dmamap_t); \
1046 void __bs_c(f,_bd_map_sync)(bus_dma_tag_t, bus_dmamap_t, \
1047 bus_addr_t, bus_size_t, int); \
1048 int __bs_c(f,_bd_mem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t, \
1049 bus_size_t, bus_dma_segment_t *, int, int *, int); \
1050 void __bs_c(f,_bd_mem_free)(bus_dma_tag_t, bus_dma_segment_t *, int);\
1051 int __bs_c(f,_bd_mem_map)(bus_dma_tag_t, bus_dma_segment_t *, \
1052 int, size_t, void **, int); \
1053 void __bs_c(f,_bd_mem_unmap)(bus_dma_tag_t, void *, size_t); \
1054 paddr_t __bs_c(f,_bd_mem_mmap)(bus_dma_tag_t, bus_dma_segment_t *, \
1055 int, off_t, int, int);
1056
1057 #endif /* ! BUS_DMA_MD_CALLS */
1058
1059 #ifndef BUS_DMA_MD_TYPES
1060 #ifdef BUS_DMA_MD_CALLS
1061 typedef struct bus_dma_tag *bus_dma_tag_t;
1062 typedef struct bus_dma_segment bus_dma_segment_t;
1063 typedef struct bus_dmamap *bus_dmamap_t;
1064 #endif /* ! BUS_DMA_MD_CALLS */
1065
1066 /*
1067 * bus_dma_tag
1068 *
1069 * Describes a implementation of DMA for a given bus.
1070 */
1071 struct bus_dma_tag {
1072 bus_dma_tag_t bd_base;
1073 struct bus_dma_ops bd_ops;
1074 };
1075
1076 /*
1077 * bus_dma_segment
1078 *
1079 * Describes a single contiguous DMA transaction.
1080 */
1081 struct bus_dma_segment {
1082 bus_addr_t ds_addr; /* DMA address */
1083 bus_size_t ds_len; /* length of transfer */
1084 };
1085
1086 /*
1087 * bus_dmamap
1088 *
1089 * Describes a DMA mapping.
1090 */
1091 struct bus_dmamap {
1092 bus_size_t dm_maxsegsz; /* largest possible segment */
1093 bus_size_t dm_mapsize; /* size of the mapping */
1094 int dm_nsegs; /* # valid segments in mapping */
1095 bus_dma_segment_t *dm_segs; /* segments; variable length */
1096 };
1097
1098 #endif /* ! BUS_DMA_MD_TYPES */
1099
1100 #include <machine/bus_machdep.h>
1101
1102 #endif /* _SYS_BUS_H_ */
1103