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