1 /* $NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej Exp $ */
4 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
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.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
34 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
35 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by Christopher G. Demetriou
48 * for the NetBSD Project.
49 * 4. The name of the author may not be used to endorse or promote products
50 * derived from this software without specific prior written permission
52 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
53 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
54 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
57 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
61 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 #ifndef _MACHINE_BUS_H_
67 #define _MACHINE_BUS_H_
69 #include <machine/_bus.h>
72 * int bus_space_map (bus_space_tag_t t, bus_addr_t addr,
73 * bus_size_t size, int flags, bus_space_handle_t *bshp);
75 * Map a region of bus space.
78 #define BUS_SPACE_MAP_CACHEABLE 0x01
79 #define BUS_SPACE_MAP_LINEAR 0x02
80 #define BUS_SPACE_MAP_PREFETCHABLE 0x04
85 * The functions used most often are grouped together at the beginning to ensure
86 * that all the data fits into a single cache line. The inline implementations
87 * of single read/write access these values a lot.
90 /* Read/write single and barrier: the most commonly used functions. */
91 uint8_t (*bs_r_1)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
92 uint32_t (*bs_r_4)(bus_space_tag_t, bus_space_handle_t, bus_size_t);
93 void (*bs_w_1)(bus_space_tag_t, bus_space_handle_t,
95 void (*bs_w_4)(bus_space_tag_t, bus_space_handle_t,
96 bus_size_t, uint32_t);
97 void (*bs_barrier)(bus_space_tag_t, bus_space_handle_t,
98 bus_size_t, bus_size_t, int);
100 /* Backlink to parent (if copied), and implementation private data. */
101 struct bus_space *bs_parent;
104 /* mapping/unmapping */
105 int (*bs_map) (bus_space_tag_t, bus_addr_t, bus_size_t,
106 int, bus_space_handle_t *);
107 void (*bs_unmap) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
108 int (*bs_subregion) (bus_space_tag_t, bus_space_handle_t,
109 bus_size_t, bus_size_t, bus_space_handle_t *);
111 /* allocation/deallocation */
112 int (*bs_alloc) (bus_space_tag_t, bus_addr_t, bus_addr_t,
113 bus_size_t, bus_size_t, bus_size_t, int,
114 bus_addr_t *, bus_space_handle_t *);
115 void (*bs_free) (bus_space_tag_t, bus_space_handle_t,
118 /* Read single, the less commonly used functions. */
119 uint16_t (*bs_r_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
120 uint64_t (*bs_r_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
123 void (*bs_rm_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
124 uint8_t *, bus_size_t);
125 void (*bs_rm_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
126 uint16_t *, bus_size_t);
127 void (*bs_rm_4) (bus_space_tag_t, bus_space_handle_t,
128 bus_size_t, uint32_t *, bus_size_t);
129 void (*bs_rm_8) (bus_space_tag_t, bus_space_handle_t,
130 bus_size_t, uint64_t *, bus_size_t);
133 void (*bs_rr_1) (bus_space_tag_t, bus_space_handle_t,
134 bus_size_t, uint8_t *, bus_size_t);
135 void (*bs_rr_2) (bus_space_tag_t, bus_space_handle_t,
136 bus_size_t, uint16_t *, bus_size_t);
137 void (*bs_rr_4) (bus_space_tag_t, bus_space_handle_t,
138 bus_size_t, uint32_t *, bus_size_t);
139 void (*bs_rr_8) (bus_space_tag_t, bus_space_handle_t,
140 bus_size_t, uint64_t *, bus_size_t);
142 /* Write single, the less commonly used functions. */
143 void (*bs_w_2) (bus_space_tag_t, bus_space_handle_t,
144 bus_size_t, uint16_t);
145 void (*bs_w_8) (bus_space_tag_t, bus_space_handle_t,
146 bus_size_t, uint64_t);
149 void (*bs_wm_1) (bus_space_tag_t, bus_space_handle_t,
150 bus_size_t, const uint8_t *, bus_size_t);
151 void (*bs_wm_2) (bus_space_tag_t, bus_space_handle_t,
152 bus_size_t, const uint16_t *, bus_size_t);
153 void (*bs_wm_4) (bus_space_tag_t, bus_space_handle_t,
154 bus_size_t, const uint32_t *, bus_size_t);
155 void (*bs_wm_8) (bus_space_tag_t, bus_space_handle_t,
156 bus_size_t, const uint64_t *, bus_size_t);
159 void (*bs_wr_1) (bus_space_tag_t, bus_space_handle_t,
160 bus_size_t, const uint8_t *, bus_size_t);
161 void (*bs_wr_2) (bus_space_tag_t, bus_space_handle_t,
162 bus_size_t, const uint16_t *, bus_size_t);
163 void (*bs_wr_4) (bus_space_tag_t, bus_space_handle_t,
164 bus_size_t, const uint32_t *, bus_size_t);
165 void (*bs_wr_8) (bus_space_tag_t, bus_space_handle_t,
166 bus_size_t, const uint64_t *, bus_size_t);
169 void (*bs_sm_1) (bus_space_tag_t, bus_space_handle_t,
170 bus_size_t, uint8_t, bus_size_t);
171 void (*bs_sm_2) (bus_space_tag_t, bus_space_handle_t,
172 bus_size_t, uint16_t, bus_size_t);
173 void (*bs_sm_4) (bus_space_tag_t, bus_space_handle_t,
174 bus_size_t, uint32_t, bus_size_t);
175 void (*bs_sm_8) (bus_space_tag_t, bus_space_handle_t,
176 bus_size_t, uint64_t, bus_size_t);
179 void (*bs_sr_1) (bus_space_tag_t, bus_space_handle_t,
180 bus_size_t, uint8_t, bus_size_t);
181 void (*bs_sr_2) (bus_space_tag_t, bus_space_handle_t,
182 bus_size_t, uint16_t, bus_size_t);
183 void (*bs_sr_4) (bus_space_tag_t, bus_space_handle_t,
184 bus_size_t, uint32_t, bus_size_t);
185 void (*bs_sr_8) (bus_space_tag_t, bus_space_handle_t,
186 bus_size_t, uint64_t, bus_size_t);
189 void (*bs_c_1) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
190 bus_space_handle_t, bus_size_t, bus_size_t);
191 void (*bs_c_2) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
192 bus_space_handle_t, bus_size_t, bus_size_t);
193 void (*bs_c_4) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
194 bus_space_handle_t, bus_size_t, bus_size_t);
195 void (*bs_c_8) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
196 bus_space_handle_t, bus_size_t, bus_size_t);
198 /* read stream (single) */
199 uint8_t (*bs_r_1_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
200 uint16_t (*bs_r_2_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
201 uint32_t (*bs_r_4_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
202 uint64_t (*bs_r_8_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t);
204 /* read multiple stream */
205 void (*bs_rm_1_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
206 uint8_t *, bus_size_t);
207 void (*bs_rm_2_s) (bus_space_tag_t, bus_space_handle_t, bus_size_t,
208 uint16_t *, bus_size_t);
209 void (*bs_rm_4_s) (bus_space_tag_t, bus_space_handle_t,
210 bus_size_t, uint32_t *, bus_size_t);
211 void (*bs_rm_8_s) (bus_space_tag_t, bus_space_handle_t,
212 bus_size_t, uint64_t *, bus_size_t);
214 /* read region stream */
215 void (*bs_rr_1_s) (bus_space_tag_t, bus_space_handle_t,
216 bus_size_t, uint8_t *, bus_size_t);
217 void (*bs_rr_2_s) (bus_space_tag_t, bus_space_handle_t,
218 bus_size_t, uint16_t *, bus_size_t);
219 void (*bs_rr_4_s) (bus_space_tag_t, bus_space_handle_t,
220 bus_size_t, uint32_t *, bus_size_t);
221 void (*bs_rr_8_s) (bus_space_tag_t, bus_space_handle_t,
222 bus_size_t, uint64_t *, bus_size_t);
224 /* write stream (single) */
225 void (*bs_w_1_s) (bus_space_tag_t, bus_space_handle_t,
226 bus_size_t, uint8_t);
227 void (*bs_w_2_s) (bus_space_tag_t, bus_space_handle_t,
228 bus_size_t, uint16_t);
229 void (*bs_w_4_s) (bus_space_tag_t, bus_space_handle_t,
230 bus_size_t, uint32_t);
231 void (*bs_w_8_s) (bus_space_tag_t, bus_space_handle_t,
232 bus_size_t, uint64_t);
234 /* write multiple stream */
235 void (*bs_wm_1_s) (bus_space_tag_t, bus_space_handle_t,
236 bus_size_t, const uint8_t *, bus_size_t);
237 void (*bs_wm_2_s) (bus_space_tag_t, bus_space_handle_t,
238 bus_size_t, const uint16_t *, bus_size_t);
239 void (*bs_wm_4_s) (bus_space_tag_t, bus_space_handle_t,
240 bus_size_t, const uint32_t *, bus_size_t);
241 void (*bs_wm_8_s) (bus_space_tag_t, bus_space_handle_t,
242 bus_size_t, const uint64_t *, bus_size_t);
244 /* write region stream */
245 void (*bs_wr_1_s) (bus_space_tag_t, bus_space_handle_t,
246 bus_size_t, const uint8_t *, bus_size_t);
247 void (*bs_wr_2_s) (bus_space_tag_t, bus_space_handle_t,
248 bus_size_t, const uint16_t *, bus_size_t);
249 void (*bs_wr_4_s) (bus_space_tag_t, bus_space_handle_t,
250 bus_size_t, const uint32_t *, bus_size_t);
251 void (*bs_wr_8_s) (bus_space_tag_t, bus_space_handle_t,
252 bus_size_t, const uint64_t *, bus_size_t);
255 extern bus_space_tag_t arm_base_bs_tag;
258 * Utility macros; INTERNAL USE ONLY.
260 #define __bs_c(a,b) __CONCAT(a,b)
261 #define __bs_opname(op,size) __bs_c(__bs_c(__bs_c(bs_,op),_),size)
263 #define __bs_nonsingle(type, sz, t, h, o, a, c) \
264 (*(t)->__bs_opname(type,sz))((t), h, o, a, c)
265 #define __bs_set(type, sz, t, h, o, v, c) \
266 (*(t)->__bs_opname(type,sz))((t), h, o, v, c)
267 #define __bs_copy(sz, t, h1, o1, h2, o2, cnt) \
268 (*(t)->__bs_opname(c,sz))((t), h1, o1, h2, o2, cnt)
270 #define __bs_opname_s(op,size) __bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s)
271 #define __bs_rs_s(sz, t, h, o) \
272 (*(t)->__bs_opname_s(r,sz))((t), h, o)
273 #define __bs_ws_s(sz, t, h, o, v) \
274 (*(t)->__bs_opname_s(w,sz))((t), h, o, v)
275 #define __bs_nonsingle_s(type, sz, t, h, o, a, c) \
276 (*(t)->__bs_opname_s(type,sz))((t), h, o, a, c)
279 #define __generate_inline_bs_rs(IFN, MBR, TYP) \
281 IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o) \
284 if (__predict_true(t->MBR == NULL)) \
285 return (*(volatile TYP *)(h + o)); \
287 return (t->MBR(t, h, o)); \
290 #define __generate_inline_bs_ws(IFN, MBR, TYP) \
292 IFN(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, TYP v)\
295 if (__predict_true(t->MBR == NULL)) \
296 *(volatile TYP *)(h + o) = v; \
298 t->MBR(t, h, o, v); \
302 * Mapping and unmapping operations.
304 #define bus_space_map(t, a, s, c, hp) \
305 (*(t)->bs_map)((t), (a), (s), (c), (hp))
306 #define bus_space_unmap(t, h, s) \
307 (*(t)->bs_unmap)((t), (h), (s))
308 #define bus_space_subregion(t, h, o, s, hp) \
309 (*(t)->bs_subregion)((t), (h), (o), (s), (hp))
313 * Allocation and deallocation operations.
315 #define bus_space_alloc(t, rs, re, s, a, b, c, ap, hp) \
316 (*(t)->bs_alloc)((t), (rs), (re), (s), (a), (b), \
318 #define bus_space_free(t, h, s) \
319 (*(t)->bs_free)((t), (h), (s))
322 * Bus barrier operations.
324 #define bus_space_barrier(t, h, o, l, f) \
325 (*(t)->bs_barrier)((t), (h), (o), (l), (f))
327 #define BUS_SPACE_BARRIER_READ 0x01
328 #define BUS_SPACE_BARRIER_WRITE 0x02
331 * Bus read (single) operations.
333 __generate_inline_bs_rs(bus_space_read_1, bs_r_1, uint8_t);
334 __generate_inline_bs_rs(bus_space_read_2, bs_r_2, uint16_t);
335 __generate_inline_bs_rs(bus_space_read_4, bs_r_4, uint32_t);
336 __generate_inline_bs_rs(bus_space_read_8, bs_r_8, uint64_t);
338 __generate_inline_bs_rs(bus_space_read_stream_1, bs_r_1_s, uint8_t);
339 __generate_inline_bs_rs(bus_space_read_stream_2, bs_r_2_s, uint16_t);
340 __generate_inline_bs_rs(bus_space_read_stream_4, bs_r_4_s, uint32_t);
341 __generate_inline_bs_rs(bus_space_read_stream_8, bs_r_8_s, uint64_t);
344 * Bus read multiple operations.
346 #define bus_space_read_multi_1(t, h, o, a, c) \
347 __bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
348 #define bus_space_read_multi_2(t, h, o, a, c) \
349 __bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
350 #define bus_space_read_multi_4(t, h, o, a, c) \
351 __bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
352 #define bus_space_read_multi_8(t, h, o, a, c) \
353 __bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
355 #define bus_space_read_multi_stream_1(t, h, o, a, c) \
356 __bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c))
357 #define bus_space_read_multi_stream_2(t, h, o, a, c) \
358 __bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c))
359 #define bus_space_read_multi_stream_4(t, h, o, a, c) \
360 __bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c))
361 #define bus_space_read_multi_stream_8(t, h, o, a, c) \
362 __bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c))
366 * Bus read region operations.
368 #define bus_space_read_region_1(t, h, o, a, c) \
369 __bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
370 #define bus_space_read_region_2(t, h, o, a, c) \
371 __bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
372 #define bus_space_read_region_4(t, h, o, a, c) \
373 __bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
374 #define bus_space_read_region_8(t, h, o, a, c) \
375 __bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
377 #define bus_space_read_region_stream_1(t, h, o, a, c) \
378 __bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c))
379 #define bus_space_read_region_stream_2(t, h, o, a, c) \
380 __bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c))
381 #define bus_space_read_region_stream_4(t, h, o, a, c) \
382 __bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c))
383 #define bus_space_read_region_stream_8(t, h, o, a, c) \
384 __bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c))
388 * Bus write (single) operations.
390 __generate_inline_bs_ws(bus_space_write_1, bs_w_1, uint8_t);
391 __generate_inline_bs_ws(bus_space_write_2, bs_w_2, uint16_t);
392 __generate_inline_bs_ws(bus_space_write_4, bs_w_4, uint32_t);
393 __generate_inline_bs_ws(bus_space_write_8, bs_w_8, uint64_t);
395 __generate_inline_bs_ws(bus_space_write_stream_1, bs_w_1_s, uint8_t);
396 __generate_inline_bs_ws(bus_space_write_stream_2, bs_w_2_s, uint16_t);
397 __generate_inline_bs_ws(bus_space_write_stream_4, bs_w_4_s, uint32_t);
398 __generate_inline_bs_ws(bus_space_write_stream_8, bs_w_8_s, uint64_t);
402 * Bus write multiple operations.
404 #define bus_space_write_multi_1(t, h, o, a, c) \
405 __bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
406 #define bus_space_write_multi_2(t, h, o, a, c) \
407 __bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
408 #define bus_space_write_multi_4(t, h, o, a, c) \
409 __bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
410 #define bus_space_write_multi_8(t, h, o, a, c) \
411 __bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
413 #define bus_space_write_multi_stream_1(t, h, o, a, c) \
414 __bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c))
415 #define bus_space_write_multi_stream_2(t, h, o, a, c) \
416 __bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c))
417 #define bus_space_write_multi_stream_4(t, h, o, a, c) \
418 __bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c))
419 #define bus_space_write_multi_stream_8(t, h, o, a, c) \
420 __bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c))
424 * Bus write region operations.
426 #define bus_space_write_region_1(t, h, o, a, c) \
427 __bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
428 #define bus_space_write_region_2(t, h, o, a, c) \
429 __bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
430 #define bus_space_write_region_4(t, h, o, a, c) \
431 __bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
432 #define bus_space_write_region_8(t, h, o, a, c) \
433 __bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
435 #define bus_space_write_region_stream_1(t, h, o, a, c) \
436 __bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c))
437 #define bus_space_write_region_stream_2(t, h, o, a, c) \
438 __bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c))
439 #define bus_space_write_region_stream_4(t, h, o, a, c) \
440 __bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c))
441 #define bus_space_write_region_stream_8(t, h, o, a, c) \
442 __bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c))
446 * Set multiple operations.
448 #define bus_space_set_multi_1(t, h, o, v, c) \
449 __bs_set(sm,1,(t),(h),(o),(v),(c))
450 #define bus_space_set_multi_2(t, h, o, v, c) \
451 __bs_set(sm,2,(t),(h),(o),(v),(c))
452 #define bus_space_set_multi_4(t, h, o, v, c) \
453 __bs_set(sm,4,(t),(h),(o),(v),(c))
454 #define bus_space_set_multi_8(t, h, o, v, c) \
455 __bs_set(sm,8,(t),(h),(o),(v),(c))
459 * Set region operations.
461 #define bus_space_set_region_1(t, h, o, v, c) \
462 __bs_set(sr,1,(t),(h),(o),(v),(c))
463 #define bus_space_set_region_2(t, h, o, v, c) \
464 __bs_set(sr,2,(t),(h),(o),(v),(c))
465 #define bus_space_set_region_4(t, h, o, v, c) \
466 __bs_set(sr,4,(t),(h),(o),(v),(c))
467 #define bus_space_set_region_8(t, h, o, v, c) \
468 __bs_set(sr,8,(t),(h),(o),(v),(c))
474 #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
475 __bs_copy(1, t, h1, o1, h2, o2, c)
476 #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
477 __bs_copy(2, t, h1, o1, h2, o2, c)
478 #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
479 __bs_copy(4, t, h1, o1, h2, o2, c)
480 #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
481 __bs_copy(8, t, h1, o1, h2, o2, c)
484 * Macros to provide prototypes for all the functions used in the
485 * bus_space structure
488 #define bs_map_proto(f) \
489 int __bs_c(f,_bs_map) (bus_space_tag_t t, bus_addr_t addr, \
490 bus_size_t size, int cacheable, bus_space_handle_t *bshp);
492 #define bs_unmap_proto(f) \
493 void __bs_c(f,_bs_unmap) (bus_space_tag_t t, bus_space_handle_t bsh, \
496 #define bs_subregion_proto(f) \
497 int __bs_c(f,_bs_subregion) (bus_space_tag_t t, bus_space_handle_t bsh, \
498 bus_size_t offset, bus_size_t size, \
499 bus_space_handle_t *nbshp);
501 #define bs_alloc_proto(f) \
502 int __bs_c(f,_bs_alloc) (bus_space_tag_t t, bus_addr_t rstart, \
503 bus_addr_t rend, bus_size_t size, bus_size_t align, \
504 bus_size_t boundary, int cacheable, bus_addr_t *addrp, \
505 bus_space_handle_t *bshp);
507 #define bs_free_proto(f) \
508 void __bs_c(f,_bs_free) (bus_space_tag_t t, bus_space_handle_t bsh, \
511 #define bs_mmap_proto(f) \
512 int __bs_c(f,_bs_mmap) (struct cdev *, vm_offset_t, vm_paddr_t *, int);
514 #define bs_barrier_proto(f) \
515 void __bs_c(f,_bs_barrier) (bus_space_tag_t t, bus_space_handle_t bsh, \
516 bus_size_t offset, bus_size_t len, int flags);
518 #define bs_r_1_proto(f) \
519 uint8_t __bs_c(f,_bs_r_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
522 #define bs_r_2_proto(f) \
523 uint16_t __bs_c(f,_bs_r_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
526 #define bs_r_4_proto(f) \
527 uint32_t __bs_c(f,_bs_r_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
530 #define bs_r_8_proto(f) \
531 uint64_t __bs_c(f,_bs_r_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
534 #define bs_r_1_s_proto(f) \
535 uint8_t __bs_c(f,_bs_r_1_s) (bus_space_tag_t t, bus_space_handle_t bsh, \
538 #define bs_r_2_s_proto(f) \
539 uint16_t __bs_c(f,_bs_r_2_s) (bus_space_tag_t t, bus_space_handle_t bsh, \
542 #define bs_r_4_s_proto(f) \
543 uint32_t __bs_c(f,_bs_r_4_s) (bus_space_tag_t t, bus_space_handle_t bsh, \
546 #define bs_w_1_proto(f) \
547 void __bs_c(f,_bs_w_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
548 bus_size_t offset, uint8_t value);
550 #define bs_w_2_proto(f) \
551 void __bs_c(f,_bs_w_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
552 bus_size_t offset, uint16_t value);
554 #define bs_w_4_proto(f) \
555 void __bs_c(f,_bs_w_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
556 bus_size_t offset, uint32_t value);
558 #define bs_w_8_proto(f) \
559 void __bs_c(f,_bs_w_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
560 bus_size_t offset, uint64_t value);
562 #define bs_w_1_s_proto(f) \
563 void __bs_c(f,_bs_w_1_s) (bus_space_tag_t t, bus_space_handle_t bsh, \
564 bus_size_t offset, uint8_t value);
566 #define bs_w_2_s_proto(f) \
567 void __bs_c(f,_bs_w_2_s) (bus_space_tag_t t, bus_space_handle_t bsh, \
568 bus_size_t offset, uint16_t value);
570 #define bs_w_4_s_proto(f) \
571 void __bs_c(f,_bs_w_4_s) (bus_space_tag_t t, bus_space_handle_t bsh, \
572 bus_size_t offset, uint32_t value);
574 #define bs_rm_1_proto(f) \
575 void __bs_c(f,_bs_rm_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
576 bus_size_t offset, uint8_t *addr, bus_size_t count);
578 #define bs_rm_2_proto(f) \
579 void __bs_c(f,_bs_rm_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
580 bus_size_t offset, uint16_t *addr, bus_size_t count);
582 #define bs_rm_4_proto(f) \
583 void __bs_c(f,_bs_rm_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
584 bus_size_t offset, uint32_t *addr, bus_size_t count);
586 #define bs_rm_8_proto(f) \
587 void __bs_c(f,_bs_rm_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
588 bus_size_t offset, uint64_t *addr, bus_size_t count);
590 #define bs_wm_1_proto(f) \
591 void __bs_c(f,_bs_wm_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
592 bus_size_t offset, const uint8_t *addr, bus_size_t count);
594 #define bs_wm_2_proto(f) \
595 void __bs_c(f,_bs_wm_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
596 bus_size_t offset, const uint16_t *addr, bus_size_t count);
598 #define bs_wm_4_proto(f) \
599 void __bs_c(f,_bs_wm_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
600 bus_size_t offset, const uint32_t *addr, bus_size_t count);
602 #define bs_wm_8_proto(f) \
603 void __bs_c(f,_bs_wm_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
604 bus_size_t offset, const uint64_t *addr, bus_size_t count);
606 #define bs_rr_1_proto(f) \
607 void __bs_c(f, _bs_rr_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
608 bus_size_t offset, uint8_t *addr, bus_size_t count);
610 #define bs_rr_2_proto(f) \
611 void __bs_c(f, _bs_rr_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
612 bus_size_t offset, uint16_t *addr, bus_size_t count);
614 #define bs_rr_4_proto(f) \
615 void __bs_c(f, _bs_rr_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
616 bus_size_t offset, uint32_t *addr, bus_size_t count);
618 #define bs_rr_8_proto(f) \
619 void __bs_c(f, _bs_rr_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
620 bus_size_t offset, uint64_t *addr, bus_size_t count);
622 #define bs_wr_1_proto(f) \
623 void __bs_c(f, _bs_wr_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
624 bus_size_t offset, const uint8_t *addr, bus_size_t count);
626 #define bs_wr_2_proto(f) \
627 void __bs_c(f, _bs_wr_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
628 bus_size_t offset, const uint16_t *addr, bus_size_t count);
630 #define bs_wr_4_proto(f) \
631 void __bs_c(f, _bs_wr_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
632 bus_size_t offset, const uint32_t *addr, bus_size_t count);
634 #define bs_wr_8_proto(f) \
635 void __bs_c(f, _bs_wr_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
636 bus_size_t offset, const uint64_t *addr, bus_size_t count);
638 #define bs_sm_1_proto(f) \
639 void __bs_c(f,_bs_sm_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
640 bus_size_t offset, uint8_t value, bus_size_t count);
642 #define bs_sm_2_proto(f) \
643 void __bs_c(f,_bs_sm_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
644 bus_size_t offset, uint16_t value, bus_size_t count);
646 #define bs_sm_4_proto(f) \
647 void __bs_c(f,_bs_sm_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
648 bus_size_t offset, uint32_t value, bus_size_t count);
650 #define bs_sm_8_proto(f) \
651 void __bs_c(f,_bs_sm_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
652 bus_size_t offset, uint64_t value, bus_size_t count);
654 #define bs_sr_1_proto(f) \
655 void __bs_c(f,_bs_sr_1) (bus_space_tag_t t, bus_space_handle_t bsh, \
656 bus_size_t offset, uint8_t value, bus_size_t count);
658 #define bs_sr_2_proto(f) \
659 void __bs_c(f,_bs_sr_2) (bus_space_tag_t t, bus_space_handle_t bsh, \
660 bus_size_t offset, uint16_t value, bus_size_t count);
662 #define bs_sr_4_proto(f) \
663 void __bs_c(f,_bs_sr_4) (bus_space_tag_t t, bus_space_handle_t bsh, \
664 bus_size_t offset, uint32_t value, bus_size_t count);
666 #define bs_sr_8_proto(f) \
667 void __bs_c(f,_bs_sr_8) (bus_space_tag_t t, bus_space_handle_t bsh, \
668 bus_size_t offset, uint64_t value, bus_size_t count);
670 #define bs_c_1_proto(f) \
671 void __bs_c(f,_bs_c_1) (bus_space_tag_t t, bus_space_handle_t bsh1, \
672 bus_size_t offset1, bus_space_handle_t bsh2, \
673 bus_size_t offset2, bus_size_t count);
675 #define bs_c_2_proto(f) \
676 void __bs_c(f,_bs_c_2) (bus_space_tag_t t, bus_space_handle_t bsh1, \
677 bus_size_t offset1, bus_space_handle_t bsh2, \
678 bus_size_t offset2, bus_size_t count);
680 #define bs_c_4_proto(f) \
681 void __bs_c(f,_bs_c_4) (bus_space_tag_t t, bus_space_handle_t bsh1, \
682 bus_size_t offset1, bus_space_handle_t bsh2, \
683 bus_size_t offset2, bus_size_t count);
685 #define bs_c_8_proto(f) \
686 void __bs_c(f,_bs_c_8) (bus_space_tag_t t, bus_space_handle_t bsh1, \
687 bus_size_t offset1, bus_space_handle_t bsh2, \
688 bus_size_t offset2, bus_size_t count);
690 #define bs_protos(f) \
693 bs_subregion_proto(f); \
697 bs_barrier_proto(f); \
741 void generic_bs_unimplemented(void);
742 #define BS_UNIMPLEMENTED (void *)generic_bs_unimplemented
744 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
746 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
747 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
748 #define BUS_SPACE_MAXADDR 0xFFFFFFFF
749 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
750 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
751 #define BUS_SPACE_MAXSIZE 0xFFFFFFFF
753 #define BUS_SPACE_UNRESTRICTED (~0)
755 #include <machine/bus_dma.h>
758 * Get the physical address of a bus space memory-mapped resource.
759 * Doing this as a macro is a temporary solution until a more robust fix is
760 * designed. It also serves to mark the locations needing that fix.
762 #define BUS_SPACE_PHYSADDR(res, offs) \
763 ((u_int)(rman_get_start(res)+(offs)))
765 #endif /* _MACHINE_BUS_H_ */