xref: /freebsd/sys/arm/include/bus.h (revision 9336e0699bda8a301cd2bfa37106b6ec5e32012e)
1 /*	$NetBSD: bus.h,v 1.11 2003/07/28 17:35:54 thorpej 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  * $FreeBSD$
71  */
72 
73 #ifndef _MACHINE_BUS_H_
74 #define _MACHINE_BUS_H_
75 
76 #include <machine/_bus.h>
77 
78 /*
79  *	int bus_space_map  (bus_space_tag_t t, bus_addr_t addr,
80  *	    bus_size_t size, int flags, bus_space_handle_t *bshp);
81  *
82  * Map a region of bus space.
83  */
84 
85 #define	BUS_SPACE_MAP_CACHEABLE		0x01
86 #define	BUS_SPACE_MAP_LINEAR		0x02
87 #define	BUS_SPACE_MAP_PREFETCHABLE     	0x04
88 
89 struct bus_space {
90 	/* cookie */
91 	void		*bs_cookie;
92 
93 	/* mapping/unmapping */
94 	int		(*bs_map) (void *, bus_addr_t, bus_size_t,
95 			    int, bus_space_handle_t *);
96 	void		(*bs_unmap) (void *, bus_space_handle_t, bus_size_t);
97 	int		(*bs_subregion) (void *, bus_space_handle_t,
98 			    bus_size_t, bus_size_t, bus_space_handle_t *);
99 
100 	/* allocation/deallocation */
101 	int		(*bs_alloc) (void *, bus_addr_t, bus_addr_t,
102 			    bus_size_t, bus_size_t, bus_size_t, int,
103 			    bus_addr_t *, bus_space_handle_t *);
104 	void		(*bs_free) (void *, bus_space_handle_t,
105 			    bus_size_t);
106 
107 	/* get kernel virtual address */
108 	/* barrier */
109 	void		(*bs_barrier) (void *, bus_space_handle_t,
110 			    bus_size_t, bus_size_t, int);
111 
112 	/* read (single) */
113 	u_int8_t	(*bs_r_1) (void *, bus_space_handle_t, bus_size_t);
114 	u_int16_t	(*bs_r_2) (void *, bus_space_handle_t, bus_size_t);
115 	u_int32_t	(*bs_r_4) (void *, bus_space_handle_t, bus_size_t);
116 	u_int64_t	(*bs_r_8) (void *, bus_space_handle_t, bus_size_t);
117 
118 	/* read multiple */
119 	void		(*bs_rm_1) (void *, bus_space_handle_t, bus_size_t,
120 	    u_int8_t *, bus_size_t);
121 	void		(*bs_rm_2) (void *, bus_space_handle_t, bus_size_t,
122 	    u_int16_t *, bus_size_t);
123 	void		(*bs_rm_4) (void *, bus_space_handle_t,
124 			    bus_size_t, u_int32_t *, bus_size_t);
125 	void		(*bs_rm_8) (void *, bus_space_handle_t,
126 			    bus_size_t, u_int64_t *, bus_size_t);
127 
128 	/* read region */
129 	void		(*bs_rr_1) (void *, bus_space_handle_t,
130 			    bus_size_t, u_int8_t *, bus_size_t);
131 	void		(*bs_rr_2) (void *, bus_space_handle_t,
132 			    bus_size_t, u_int16_t *, bus_size_t);
133 	void		(*bs_rr_4) (void *, bus_space_handle_t,
134 			    bus_size_t, u_int32_t *, bus_size_t);
135 	void		(*bs_rr_8) (void *, bus_space_handle_t,
136 			    bus_size_t, u_int64_t *, bus_size_t);
137 
138 	/* write (single) */
139 	void		(*bs_w_1) (void *, bus_space_handle_t,
140 			    bus_size_t, u_int8_t);
141 	void		(*bs_w_2) (void *, bus_space_handle_t,
142 			    bus_size_t, u_int16_t);
143 	void		(*bs_w_4) (void *, bus_space_handle_t,
144 			    bus_size_t, u_int32_t);
145 	void		(*bs_w_8) (void *, bus_space_handle_t,
146 			    bus_size_t, u_int64_t);
147 
148 	/* write multiple */
149 	void		(*bs_wm_1) (void *, bus_space_handle_t,
150 			    bus_size_t, const u_int8_t *, bus_size_t);
151 	void		(*bs_wm_2) (void *, bus_space_handle_t,
152 			    bus_size_t, const u_int16_t *, bus_size_t);
153 	void		(*bs_wm_4) (void *, bus_space_handle_t,
154 			    bus_size_t, const u_int32_t *, bus_size_t);
155 	void		(*bs_wm_8) (void *, bus_space_handle_t,
156 			    bus_size_t, const u_int64_t *, bus_size_t);
157 
158 	/* write region */
159 	void		(*bs_wr_1) (void *, bus_space_handle_t,
160 			    bus_size_t, const u_int8_t *, bus_size_t);
161 	void		(*bs_wr_2) (void *, bus_space_handle_t,
162 			    bus_size_t, const u_int16_t *, bus_size_t);
163 	void		(*bs_wr_4) (void *, bus_space_handle_t,
164 			    bus_size_t, const u_int32_t *, bus_size_t);
165 	void		(*bs_wr_8) (void *, bus_space_handle_t,
166 			    bus_size_t, const u_int64_t *, bus_size_t);
167 
168 	/* set multiple */
169 	void		(*bs_sm_1) (void *, bus_space_handle_t,
170 			    bus_size_t, u_int8_t, bus_size_t);
171 	void		(*bs_sm_2) (void *, bus_space_handle_t,
172 			    bus_size_t, u_int16_t, bus_size_t);
173 	void		(*bs_sm_4) (void *, bus_space_handle_t,
174 			    bus_size_t, u_int32_t, bus_size_t);
175 	void		(*bs_sm_8) (void *, bus_space_handle_t,
176 			    bus_size_t, u_int64_t, bus_size_t);
177 
178 	/* set region */
179 	void		(*bs_sr_1) (void *, bus_space_handle_t,
180 			    bus_size_t, u_int8_t, bus_size_t);
181 	void		(*bs_sr_2) (void *, bus_space_handle_t,
182 			    bus_size_t, u_int16_t, bus_size_t);
183 	void		(*bs_sr_4) (void *, bus_space_handle_t,
184 			    bus_size_t, u_int32_t, bus_size_t);
185 	void		(*bs_sr_8) (void *, bus_space_handle_t,
186 			    bus_size_t, u_int64_t, bus_size_t);
187 
188 	/* copy */
189 	void		(*bs_c_1) (void *, bus_space_handle_t, bus_size_t,
190 			    bus_space_handle_t, bus_size_t, bus_size_t);
191 	void		(*bs_c_2) (void *, bus_space_handle_t, bus_size_t,
192 			    bus_space_handle_t, bus_size_t, bus_size_t);
193 	void		(*bs_c_4) (void *, bus_space_handle_t, bus_size_t,
194 			    bus_space_handle_t, bus_size_t, bus_size_t);
195 	void		(*bs_c_8) (void *, bus_space_handle_t, bus_size_t,
196 			    bus_space_handle_t, bus_size_t, bus_size_t);
197 
198 	/* read stream (single) */
199 	u_int8_t	(*bs_r_1_s) (void *, bus_space_handle_t, bus_size_t);
200 	u_int16_t	(*bs_r_2_s) (void *, bus_space_handle_t, bus_size_t);
201 	u_int32_t	(*bs_r_4_s) (void *, bus_space_handle_t, bus_size_t);
202 	u_int64_t	(*bs_r_8_s) (void *, bus_space_handle_t, bus_size_t);
203 
204 	/* read multiple stream */
205 	void		(*bs_rm_1_s) (void *, bus_space_handle_t, bus_size_t,
206 	    u_int8_t *, bus_size_t);
207 	void		(*bs_rm_2_s) (void *, bus_space_handle_t, bus_size_t,
208 	    u_int16_t *, bus_size_t);
209 	void		(*bs_rm_4_s) (void *, bus_space_handle_t,
210 			    bus_size_t, u_int32_t *, bus_size_t);
211 	void		(*bs_rm_8_s) (void *, bus_space_handle_t,
212 			    bus_size_t, u_int64_t *, bus_size_t);
213 
214 	/* read region stream */
215 	void		(*bs_rr_1_s) (void *, bus_space_handle_t,
216 			    bus_size_t, u_int8_t *, bus_size_t);
217 	void		(*bs_rr_2_s) (void *, bus_space_handle_t,
218 			    bus_size_t, u_int16_t *, bus_size_t);
219 	void		(*bs_rr_4_s) (void *, bus_space_handle_t,
220 			    bus_size_t, u_int32_t *, bus_size_t);
221 	void		(*bs_rr_8_s) (void *, bus_space_handle_t,
222 			    bus_size_t, u_int64_t *, bus_size_t);
223 
224 	/* write stream (single) */
225 	void		(*bs_w_1_s) (void *, bus_space_handle_t,
226 			    bus_size_t, u_int8_t);
227 	void		(*bs_w_2_s) (void *, bus_space_handle_t,
228 			    bus_size_t, u_int16_t);
229 	void		(*bs_w_4_s) (void *, bus_space_handle_t,
230 			    bus_size_t, u_int32_t);
231 	void		(*bs_w_8_s) (void *, bus_space_handle_t,
232 			    bus_size_t, u_int64_t);
233 
234 	/* write multiple stream */
235 	void		(*bs_wm_1_s) (void *, bus_space_handle_t,
236 			    bus_size_t, const u_int8_t *, bus_size_t);
237 	void		(*bs_wm_2_s) (void *, bus_space_handle_t,
238 			    bus_size_t, const u_int16_t *, bus_size_t);
239 	void		(*bs_wm_4_s) (void *, bus_space_handle_t,
240 			    bus_size_t, const u_int32_t *, bus_size_t);
241 	void		(*bs_wm_8_s) (void *, bus_space_handle_t,
242 			    bus_size_t, const u_int64_t *, bus_size_t);
243 
244 	/* write region stream */
245 	void		(*bs_wr_1_s) (void *, bus_space_handle_t,
246 			    bus_size_t, const u_int8_t *, bus_size_t);
247 	void		(*bs_wr_2_s) (void *, bus_space_handle_t,
248 			    bus_size_t, const u_int16_t *, bus_size_t);
249 	void		(*bs_wr_4_s) (void *, bus_space_handle_t,
250 			    bus_size_t, const u_int32_t *, bus_size_t);
251 	void		(*bs_wr_8_s) (void *, bus_space_handle_t,
252 			    bus_size_t, const u_int64_t *, bus_size_t);
253 };
254 
255 
256 /*
257  * Utility macros; INTERNAL USE ONLY.
258  */
259 #define	__bs_c(a,b)		__CONCAT(a,b)
260 #define	__bs_opname(op,size)	__bs_c(__bs_c(__bs_c(bs_,op),_),size)
261 
262 #define	__bs_rs(sz, t, h, o)						\
263 	(*(t)->__bs_opname(r,sz))((t)->bs_cookie, h, o)
264 #define	__bs_ws(sz, t, h, o, v)						\
265 	(*(t)->__bs_opname(w,sz))((t)->bs_cookie, h, o, v)
266 #define	__bs_nonsingle(type, sz, t, h, o, a, c)				\
267 	(*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, a, c)
268 #define	__bs_set(type, sz, t, h, o, v, c)				\
269 	(*(t)->__bs_opname(type,sz))((t)->bs_cookie, h, o, v, c)
270 #define	__bs_copy(sz, t, h1, o1, h2, o2, cnt)				\
271 	(*(t)->__bs_opname(c,sz))((t)->bs_cookie, h1, o1, h2, o2, cnt)
272 
273 #define	__bs_opname_s(op,size)	__bs_c(__bs_c(__bs_c(__bs_c(bs_,op),_),size),_s)
274 #define	__bs_rs_s(sz, t, h, o)						\
275 	(*(t)->__bs_opname_s(r,sz))((t)->bs_cookie, h, o)
276 #define	__bs_ws_s(sz, t, h, o, v)					\
277 	(*(t)->__bs_opname_s(w,sz))((t)->bs_cookie, h, o, v)
278 #define	__bs_nonsingle_s(type, sz, t, h, o, a, c)			\
279 	(*(t)->__bs_opname_s(type,sz))((t)->bs_cookie, h, o, a, c)
280 
281 
282 /*
283  * Mapping and unmapping operations.
284  */
285 #define	bus_space_map(t, a, s, c, hp)					\
286 	(*(t)->bs_map)((t)->bs_cookie, (a), (s), (c), (hp))
287 #define	bus_space_unmap(t, h, s)					\
288 	(*(t)->bs_unmap)((t)->bs_cookie, (h), (s))
289 #define	bus_space_subregion(t, h, o, s, hp)				\
290 	(*(t)->bs_subregion)((t)->bs_cookie, (h), (o), (s), (hp))
291 
292 
293 /*
294  * Allocation and deallocation operations.
295  */
296 #define	bus_space_alloc(t, rs, re, s, a, b, c, ap, hp)			\
297 	(*(t)->bs_alloc)((t)->bs_cookie, (rs), (re), (s), (a), (b),	\
298 	    (c), (ap), (hp))
299 #define	bus_space_free(t, h, s)						\
300 	(*(t)->bs_free)((t)->bs_cookie, (h), (s))
301 
302 /*
303  * Bus barrier operations.
304  */
305 #define	bus_space_barrier(t, h, o, l, f)				\
306 	(*(t)->bs_barrier)((t)->bs_cookie, (h), (o), (l), (f))
307 
308 #define	BUS_SPACE_BARRIER_READ	0x01
309 #define	BUS_SPACE_BARRIER_WRITE	0x02
310 
311 /*
312  * Bus read (single) operations.
313  */
314 #define	bus_space_read_1(t, h, o)	__bs_rs(1,(t),(h),(o))
315 #define	bus_space_read_2(t, h, o)	__bs_rs(2,(t),(h),(o))
316 #define	bus_space_read_4(t, h, o)	__bs_rs(4,(t),(h),(o))
317 #define	bus_space_read_8(t, h, o)	__bs_rs(8,(t),(h),(o))
318 
319 #define bus_space_read_stream_1(t, h, o)        __bs_rs_s(1,(t), (h), (o))
320 #define bus_space_read_stream_2(t, h, o)        __bs_rs_s(2,(t), (h), (o))
321 #define bus_space_read_stream_4(t, h, o)        __bs_rs_s(4,(t), (h), (o))
322 #define	bus_space_read_stream_8(t, h, o)	__bs_rs_s(8,8,(t),(h),(o))
323 
324 /*
325  * Bus read multiple operations.
326  */
327 #define	bus_space_read_multi_1(t, h, o, a, c)				\
328 	__bs_nonsingle(rm,1,(t),(h),(o),(a),(c))
329 #define	bus_space_read_multi_2(t, h, o, a, c)				\
330 	__bs_nonsingle(rm,2,(t),(h),(o),(a),(c))
331 #define	bus_space_read_multi_4(t, h, o, a, c)				\
332 	__bs_nonsingle(rm,4,(t),(h),(o),(a),(c))
333 #define	bus_space_read_multi_8(t, h, o, a, c)				\
334 	__bs_nonsingle(rm,8,(t),(h),(o),(a),(c))
335 
336 #define	bus_space_read_multi_stream_1(t, h, o, a, c)			\
337 	__bs_nonsingle_s(rm,1,(t),(h),(o),(a),(c))
338 #define	bus_space_read_multi_stream_2(t, h, o, a, c)			\
339 	__bs_nonsingle_s(rm,2,(t),(h),(o),(a),(c))
340 #define	bus_space_read_multi_stream_4(t, h, o, a, c)			\
341 	__bs_nonsingle_s(rm,4,(t),(h),(o),(a),(c))
342 #define	bus_space_read_multi_stream_8(t, h, o, a, c)			\
343 	__bs_nonsingle_s(rm,8,(t),(h),(o),(a),(c))
344 
345 
346 /*
347  * Bus read region operations.
348  */
349 #define	bus_space_read_region_1(t, h, o, a, c)				\
350 	__bs_nonsingle(rr,1,(t),(h),(o),(a),(c))
351 #define	bus_space_read_region_2(t, h, o, a, c)				\
352 	__bs_nonsingle(rr,2,(t),(h),(o),(a),(c))
353 #define	bus_space_read_region_4(t, h, o, a, c)				\
354 	__bs_nonsingle(rr,4,(t),(h),(o),(a),(c))
355 #define	bus_space_read_region_8(t, h, o, a, c)				\
356 	__bs_nonsingle(rr,8,(t),(h),(o),(a),(c))
357 
358 #define	bus_space_read_region_stream_1(t, h, o, a, c)			\
359 	__bs_nonsingle_s(rr,1,(t),(h),(o),(a),(c))
360 #define	bus_space_read_region_stream_2(t, h, o, a, c)			\
361 	__bs_nonsingle_s(rr,2,(t),(h),(o),(a),(c))
362 #define	bus_space_read_region_stream_4(t, h, o, a, c)			\
363 	__bs_nonsingle_s(rr,4,(t),(h),(o),(a),(c))
364 #define	bus_space_read_region_stream_8(t, h, o, a, c)			\
365 	__bs_nonsingle_s(rr,8,(t),(h),(o),(a),(c))
366 
367 
368 /*
369  * Bus write (single) operations.
370  */
371 #define	bus_space_write_1(t, h, o, v)	__bs_ws(1,(t),(h),(o),(v))
372 #define	bus_space_write_2(t, h, o, v)	__bs_ws(2,(t),(h),(o),(v))
373 #define	bus_space_write_4(t, h, o, v)	__bs_ws(4,(t),(h),(o),(v))
374 #define	bus_space_write_8(t, h, o, v)	__bs_ws(8,(t),(h),(o),(v))
375 
376 #define	bus_space_write_stream_1(t, h, o, v)	__bs_ws_s(1,(t),(h),(o),(v))
377 #define	bus_space_write_stream_2(t, h, o, v)	__bs_ws_s(2,(t),(h),(o),(v))
378 #define	bus_space_write_stream_4(t, h, o, v)	__bs_ws_s(4,(t),(h),(o),(v))
379 #define	bus_space_write_stream_8(t, h, o, v)	__bs_ws_s(8,(t),(h),(o),(v))
380 
381 
382 /*
383  * Bus write multiple operations.
384  */
385 #define	bus_space_write_multi_1(t, h, o, a, c)				\
386 	__bs_nonsingle(wm,1,(t),(h),(o),(a),(c))
387 #define	bus_space_write_multi_2(t, h, o, a, c)				\
388 	__bs_nonsingle(wm,2,(t),(h),(o),(a),(c))
389 #define	bus_space_write_multi_4(t, h, o, a, c)				\
390 	__bs_nonsingle(wm,4,(t),(h),(o),(a),(c))
391 #define	bus_space_write_multi_8(t, h, o, a, c)				\
392 	__bs_nonsingle(wm,8,(t),(h),(o),(a),(c))
393 
394 #define	bus_space_write_multi_stream_1(t, h, o, a, c)			\
395 	__bs_nonsingle_s(wm,1,(t),(h),(o),(a),(c))
396 #define	bus_space_write_multi_stream_2(t, h, o, a, c)			\
397 	__bs_nonsingle_s(wm,2,(t),(h),(o),(a),(c))
398 #define	bus_space_write_multi_stream_4(t, h, o, a, c)			\
399 	__bs_nonsingle_s(wm,4,(t),(h),(o),(a),(c))
400 #define	bus_space_write_multi_stream_8(t, h, o, a, c)			\
401 	__bs_nonsingle_s(wm,8,(t),(h),(o),(a),(c))
402 
403 
404 /*
405  * Bus write region operations.
406  */
407 #define	bus_space_write_region_1(t, h, o, a, c)				\
408 	__bs_nonsingle(wr,1,(t),(h),(o),(a),(c))
409 #define	bus_space_write_region_2(t, h, o, a, c)				\
410 	__bs_nonsingle(wr,2,(t),(h),(o),(a),(c))
411 #define	bus_space_write_region_4(t, h, o, a, c)				\
412 	__bs_nonsingle(wr,4,(t),(h),(o),(a),(c))
413 #define	bus_space_write_region_8(t, h, o, a, c)				\
414 	__bs_nonsingle(wr,8,(t),(h),(o),(a),(c))
415 
416 #define	bus_space_write_region_stream_1(t, h, o, a, c)			\
417 	__bs_nonsingle_s(wr,1,(t),(h),(o),(a),(c))
418 #define	bus_space_write_region_stream_2(t, h, o, a, c)			\
419 	__bs_nonsingle_s(wr,2,(t),(h),(o),(a),(c))
420 #define	bus_space_write_region_stream_4(t, h, o, a, c)			\
421 	__bs_nonsingle_s(wr,4,(t),(h),(o),(a),(c))
422 #define	bus_space_write_region_stream_8(t, h, o, a, c)			\
423 	__bs_nonsingle_s(wr,8,(t),(h),(o),(a),(c))
424 
425 
426 /*
427  * Set multiple operations.
428  */
429 #define	bus_space_set_multi_1(t, h, o, v, c)				\
430 	__bs_set(sm,1,(t),(h),(o),(v),(c))
431 #define	bus_space_set_multi_2(t, h, o, v, c)				\
432 	__bs_set(sm,2,(t),(h),(o),(v),(c))
433 #define	bus_space_set_multi_4(t, h, o, v, c)				\
434 	__bs_set(sm,4,(t),(h),(o),(v),(c))
435 #define	bus_space_set_multi_8(t, h, o, v, c)				\
436 	__bs_set(sm,8,(t),(h),(o),(v),(c))
437 
438 
439 /*
440  * Set region operations.
441  */
442 #define	bus_space_set_region_1(t, h, o, v, c)				\
443 	__bs_set(sr,1,(t),(h),(o),(v),(c))
444 #define	bus_space_set_region_2(t, h, o, v, c)				\
445 	__bs_set(sr,2,(t),(h),(o),(v),(c))
446 #define	bus_space_set_region_4(t, h, o, v, c)				\
447 	__bs_set(sr,4,(t),(h),(o),(v),(c))
448 #define	bus_space_set_region_8(t, h, o, v, c)				\
449 	__bs_set(sr,8,(t),(h),(o),(v),(c))
450 
451 
452 /*
453  * Copy operations.
454  */
455 #define	bus_space_copy_region_1(t, h1, o1, h2, o2, c)				\
456 	__bs_copy(1, t, h1, o1, h2, o2, c)
457 #define	bus_space_copy_region_2(t, h1, o1, h2, o2, c)				\
458 	__bs_copy(2, t, h1, o1, h2, o2, c)
459 #define	bus_space_copy_region_4(t, h1, o1, h2, o2, c)				\
460 	__bs_copy(4, t, h1, o1, h2, o2, c)
461 #define	bus_space_copy_region_8(t, h1, o1, h2, o2, c)				\
462 	__bs_copy(8, t, h1, o1, h2, o2, c)
463 
464 /*
465  * Macros to provide prototypes for all the functions used in the
466  * bus_space structure
467  */
468 
469 #define bs_map_proto(f)							\
470 int	__bs_c(f,_bs_map) (void *t, bus_addr_t addr,		\
471 	    bus_size_t size, int cacheable, bus_space_handle_t *bshp);
472 
473 #define bs_unmap_proto(f)						\
474 void	__bs_c(f,_bs_unmap) (void *t, bus_space_handle_t bsh,		\
475 	    bus_size_t size);
476 
477 #define bs_subregion_proto(f)						\
478 int	__bs_c(f,_bs_subregion) (void *t, bus_space_handle_t bsh,	\
479 	    bus_size_t offset, bus_size_t size, 			\
480 	    bus_space_handle_t *nbshp);
481 
482 #define bs_alloc_proto(f)						\
483 int	__bs_c(f,_bs_alloc) (void *t, bus_addr_t rstart,		\
484 	    bus_addr_t rend, bus_size_t size, bus_size_t align,		\
485 	    bus_size_t boundary, int cacheable, bus_addr_t *addrp,	\
486 	    bus_space_handle_t *bshp);
487 
488 #define bs_free_proto(f)						\
489 void	__bs_c(f,_bs_free) (void *t, bus_space_handle_t bsh,	\
490 	    bus_size_t size);
491 
492 #define bs_mmap_proto(f)						\
493 int	__bs_c(f,_bs_mmap) (struct cdev *, vm_offset_t, vm_paddr_t *, int);
494 
495 #define bs_barrier_proto(f)						\
496 void	__bs_c(f,_bs_barrier) (void *t, bus_space_handle_t bsh,	\
497 	    bus_size_t offset, bus_size_t len, int flags);
498 
499 #define	bs_r_1_proto(f)							\
500 u_int8_t	__bs_c(f,_bs_r_1) (void *t, bus_space_handle_t bsh,	\
501 		    bus_size_t offset);
502 
503 #define	bs_r_2_proto(f)							\
504 u_int16_t	__bs_c(f,_bs_r_2) (void *t, bus_space_handle_t bsh,	\
505 		    bus_size_t offset);
506 
507 #define	bs_r_4_proto(f)							\
508 u_int32_t	__bs_c(f,_bs_r_4) (void *t, bus_space_handle_t bsh,	\
509 		    bus_size_t offset);
510 
511 #define	bs_r_8_proto(f)							\
512 u_int64_t	__bs_c(f,_bs_r_8) (void *t, bus_space_handle_t bsh,	\
513 		    bus_size_t offset);
514 
515 #define	bs_r_1_s_proto(f)						\
516 u_int8_t	__bs_c(f,_bs_r_1_s) (void *t, bus_space_handle_t bsh,	\
517 		    bus_size_t offset);
518 
519 #define	bs_r_2_s_proto(f)						\
520 u_int16_t	__bs_c(f,_bs_r_2_s) (void *t, bus_space_handle_t bsh,	\
521 		    bus_size_t offset);
522 
523 #define	bs_r_4_s_proto(f)						\
524 u_int32_t	__bs_c(f,_bs_r_4_s) (void *t, bus_space_handle_t bsh,	\
525 		    bus_size_t offset);
526 
527 #define	bs_w_1_proto(f)							\
528 void	__bs_c(f,_bs_w_1) (void *t, bus_space_handle_t bsh,		\
529 	    bus_size_t offset, u_int8_t value);
530 
531 #define	bs_w_2_proto(f)							\
532 void	__bs_c(f,_bs_w_2) (void *t, bus_space_handle_t bsh,		\
533 	    bus_size_t offset, u_int16_t value);
534 
535 #define	bs_w_4_proto(f)							\
536 void	__bs_c(f,_bs_w_4) (void *t, bus_space_handle_t bsh,		\
537 	    bus_size_t offset, u_int32_t value);
538 
539 #define	bs_w_8_proto(f)							\
540 void	__bs_c(f,_bs_w_8) (void *t, bus_space_handle_t bsh,		\
541 	    bus_size_t offset, u_int64_t value);
542 
543 #define	bs_w_1_s_proto(f)						\
544 void	__bs_c(f,_bs_w_1_s) (void *t, bus_space_handle_t bsh,		\
545 	    bus_size_t offset, u_int8_t value);
546 
547 #define	bs_w_2_s_proto(f)						\
548 void	__bs_c(f,_bs_w_2_s) (void *t, bus_space_handle_t bsh,		\
549 	    bus_size_t offset, u_int16_t value);
550 
551 #define	bs_w_4_s_proto(f)						\
552 void	__bs_c(f,_bs_w_4_s) (void *t, bus_space_handle_t bsh,		\
553 	    bus_size_t offset, u_int32_t value);
554 
555 #define	bs_rm_1_proto(f)						\
556 void	__bs_c(f,_bs_rm_1) (void *t, bus_space_handle_t bsh,	\
557 	    bus_size_t offset, u_int8_t *addr, bus_size_t count);
558 
559 #define	bs_rm_2_proto(f)						\
560 void	__bs_c(f,_bs_rm_2) (void *t, bus_space_handle_t bsh,	\
561 	    bus_size_t offset, u_int16_t *addr, bus_size_t count);
562 
563 #define	bs_rm_4_proto(f)						\
564 void	__bs_c(f,_bs_rm_4) (void *t, bus_space_handle_t bsh,	\
565 	    bus_size_t offset, u_int32_t *addr, bus_size_t count);
566 
567 #define	bs_rm_8_proto(f)						\
568 void	__bs_c(f,_bs_rm_8) (void *t, bus_space_handle_t bsh,	\
569 	    bus_size_t offset, u_int64_t *addr, bus_size_t count);
570 
571 #define	bs_wm_1_proto(f)						\
572 void	__bs_c(f,_bs_wm_1) (void *t, bus_space_handle_t bsh,	\
573 	    bus_size_t offset, const u_int8_t *addr, bus_size_t count);
574 
575 #define	bs_wm_2_proto(f)						\
576 void	__bs_c(f,_bs_wm_2) (void *t, bus_space_handle_t bsh,	\
577 	    bus_size_t offset, const u_int16_t *addr, bus_size_t count);
578 
579 #define	bs_wm_4_proto(f)						\
580 void	__bs_c(f,_bs_wm_4) (void *t, bus_space_handle_t bsh,	\
581 	    bus_size_t offset, const u_int32_t *addr, bus_size_t count);
582 
583 #define	bs_wm_8_proto(f)						\
584 void	__bs_c(f,_bs_wm_8) (void *t, bus_space_handle_t bsh,	\
585 	    bus_size_t offset, const u_int64_t *addr, bus_size_t count);
586 
587 #define	bs_rr_1_proto(f)						\
588 void	__bs_c(f, _bs_rr_1) (void *t, bus_space_handle_t bsh,	\
589 	    bus_size_t offset, u_int8_t *addr, bus_size_t count);
590 
591 #define	bs_rr_2_proto(f)						\
592 void	__bs_c(f, _bs_rr_2) (void *t, bus_space_handle_t bsh,	\
593 	    bus_size_t offset, u_int16_t *addr, bus_size_t count);
594 
595 #define	bs_rr_4_proto(f)						\
596 void	__bs_c(f, _bs_rr_4) (void *t, bus_space_handle_t bsh,	\
597 	    bus_size_t offset, u_int32_t *addr, bus_size_t count);
598 
599 #define	bs_rr_8_proto(f)						\
600 void	__bs_c(f, _bs_rr_8) (void *t, bus_space_handle_t bsh,	\
601 	    bus_size_t offset, u_int64_t *addr, bus_size_t count);
602 
603 #define	bs_wr_1_proto(f)						\
604 void	__bs_c(f, _bs_wr_1) (void *t, bus_space_handle_t bsh,	\
605 	    bus_size_t offset, const u_int8_t *addr, bus_size_t count);
606 
607 #define	bs_wr_2_proto(f)						\
608 void	__bs_c(f, _bs_wr_2) (void *t, bus_space_handle_t bsh,	\
609 	    bus_size_t offset, const u_int16_t *addr, bus_size_t count);
610 
611 #define	bs_wr_4_proto(f)						\
612 void	__bs_c(f, _bs_wr_4) (void *t, bus_space_handle_t bsh,	\
613 	    bus_size_t offset, const u_int32_t *addr, bus_size_t count);
614 
615 #define	bs_wr_8_proto(f)						\
616 void	__bs_c(f, _bs_wr_8) (void *t, bus_space_handle_t bsh,	\
617 	    bus_size_t offset, const u_int64_t *addr, bus_size_t count);
618 
619 #define	bs_sm_1_proto(f)						\
620 void	__bs_c(f,_bs_sm_1) (void *t, bus_space_handle_t bsh,	\
621 	    bus_size_t offset, u_int8_t value, bus_size_t count);
622 
623 #define	bs_sm_2_proto(f)						\
624 void	__bs_c(f,_bs_sm_2) (void *t, bus_space_handle_t bsh,	\
625 	    bus_size_t offset, u_int16_t value, bus_size_t count);
626 
627 #define	bs_sm_4_proto(f)						\
628 void	__bs_c(f,_bs_sm_4) (void *t, bus_space_handle_t bsh,	\
629 	    bus_size_t offset, u_int32_t value, bus_size_t count);
630 
631 #define	bs_sm_8_proto(f)						\
632 void	__bs_c(f,_bs_sm_8) (void *t, bus_space_handle_t bsh,	\
633 	    bus_size_t offset, u_int64_t value, bus_size_t count);
634 
635 #define	bs_sr_1_proto(f)						\
636 void	__bs_c(f,_bs_sr_1) (void *t, bus_space_handle_t bsh,	\
637 	    bus_size_t offset, u_int8_t value, bus_size_t count);
638 
639 #define	bs_sr_2_proto(f)						\
640 void	__bs_c(f,_bs_sr_2) (void *t, bus_space_handle_t bsh,	\
641 	    bus_size_t offset, u_int16_t value, bus_size_t count);
642 
643 #define	bs_sr_4_proto(f)						\
644 void	__bs_c(f,_bs_sr_4) (void *t, bus_space_handle_t bsh,	\
645 	    bus_size_t offset, u_int32_t value, bus_size_t count);
646 
647 #define	bs_sr_8_proto(f)						\
648 void	__bs_c(f,_bs_sr_8) (void *t, bus_space_handle_t bsh,	\
649 	    bus_size_t offset, u_int64_t value, bus_size_t count);
650 
651 #define	bs_c_1_proto(f)							\
652 void	__bs_c(f,_bs_c_1) (void *t, bus_space_handle_t bsh1,	\
653 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
654 	    bus_size_t offset2, bus_size_t count);
655 
656 #define	bs_c_2_proto(f)							\
657 void	__bs_c(f,_bs_c_2) (void *t, bus_space_handle_t bsh1,	\
658 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
659 	    bus_size_t offset2, bus_size_t count);
660 
661 #define	bs_c_4_proto(f)							\
662 void	__bs_c(f,_bs_c_4) (void *t, bus_space_handle_t bsh1,	\
663 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
664 	    bus_size_t offset2, bus_size_t count);
665 
666 #define	bs_c_8_proto(f)							\
667 void	__bs_c(f,_bs_c_8) (void *t, bus_space_handle_t bsh1,	\
668 	    bus_size_t offset1, bus_space_handle_t bsh2,		\
669 	    bus_size_t offset2, bus_size_t count);
670 
671 #define bs_protos(f)		\
672 bs_map_proto(f);		\
673 bs_unmap_proto(f);		\
674 bs_subregion_proto(f);		\
675 bs_alloc_proto(f);		\
676 bs_free_proto(f);		\
677 bs_mmap_proto(f);		\
678 bs_barrier_proto(f);		\
679 bs_r_1_proto(f);		\
680 bs_r_2_proto(f);		\
681 bs_r_4_proto(f);		\
682 bs_r_8_proto(f);		\
683 bs_r_1_s_proto(f);		\
684 bs_r_2_s_proto(f);		\
685 bs_r_4_s_proto(f);		\
686 bs_w_1_proto(f);		\
687 bs_w_2_proto(f);		\
688 bs_w_4_proto(f);		\
689 bs_w_8_proto(f);		\
690 bs_w_1_s_proto(f);		\
691 bs_w_2_s_proto(f);		\
692 bs_w_4_s_proto(f);		\
693 bs_rm_1_proto(f);		\
694 bs_rm_2_proto(f);		\
695 bs_rm_4_proto(f);		\
696 bs_rm_8_proto(f);		\
697 bs_wm_1_proto(f);		\
698 bs_wm_2_proto(f);		\
699 bs_wm_4_proto(f);		\
700 bs_wm_8_proto(f);		\
701 bs_rr_1_proto(f);		\
702 bs_rr_2_proto(f);		\
703 bs_rr_4_proto(f);		\
704 bs_rr_8_proto(f);		\
705 bs_wr_1_proto(f);		\
706 bs_wr_2_proto(f);		\
707 bs_wr_4_proto(f);		\
708 bs_wr_8_proto(f);		\
709 bs_sm_1_proto(f);		\
710 bs_sm_2_proto(f);		\
711 bs_sm_4_proto(f);		\
712 bs_sm_8_proto(f);		\
713 bs_sr_1_proto(f);		\
714 bs_sr_2_proto(f);		\
715 bs_sr_4_proto(f);		\
716 bs_sr_8_proto(f);		\
717 bs_c_1_proto(f);		\
718 bs_c_2_proto(f);		\
719 bs_c_4_proto(f);		\
720 bs_c_8_proto(f);
721 
722 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
723 
724 #define BUS_SPACE_MAXADDR_24BIT	0xFFFFFF
725 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
726 #define BUS_SPACE_MAXADDR 	0xFFFFFFFF
727 #define BUS_SPACE_MAXSIZE_24BIT	0xFFFFFF
728 #define BUS_SPACE_MAXSIZE_32BIT	0xFFFFFFFF
729 #define BUS_SPACE_MAXSIZE 	0xFFFFFFFF
730 
731 #include <machine/bus_dma.h>
732 
733 #endif /* _MACHINE_BUS_H_ */
734