xref: /netbsd-src/sys/arch/or1k/include/bus_funcs.h (revision ccd9df534e375a4366c5b55f23782053c7a98d82)
1 /* $NetBSD: bus_funcs.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */
2 /*	$OpenBSD: bus.h,v 1.1 1997/10/13 10:53:42 pefo Exp $	*/
3 
4 /*-
5  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
10  * NASA Ames Research Center.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
36  * Copyright (c) 1996 Jason R. Thorpe.  All rights reserved.
37  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
38  *
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  * 1. Redistributions of source code must retain the above copyright
43  *    notice, this list of conditions and the following disclaimer.
44  * 2. Redistributions in binary form must reproduce the above copyright
45  *    notice, this list of conditions and the following disclaimer in the
46  *    documentation and/or other materials provided with the distribution.
47  * 3. All advertising materials mentioning features or use of this software
48  *    must display the following acknowledgement:
49  *      This product includes software developed by Christopher G. Demetriou
50  *	for the NetBSD Project.
51  * 4. The name of the author may not be used to endorse or promote products
52  *    derived from this software without specific prior written permission
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
55  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
56  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
57  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
58  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
59  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
63  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64  */
65 
66 /*
67  * Copyright (c) 1997 Per Fogelstrom.  All rights reserved.
68  * Copyright (c) 1996 Niklas Hallqvist.  All rights reserved.
69  *
70  * Redistribution and use in source and binary forms, with or without
71  * modification, are permitted provided that the following conditions
72  * are met:
73  * 1. Redistributions of source code must retain the above copyright
74  *    notice, this list of conditions and the following disclaimer.
75  * 2. Redistributions in binary form must reproduce the above copyright
76  *    notice, this list of conditions and the following disclaimer in the
77  *    documentation and/or other materials provided with the distribution.
78  * 3. All advertising materials mentioning features or use of this software
79  *    must display the following acknowledgement:
80  *      This product includes software developed by Christopher G. Demetriou
81  *	for the NetBSD Project.
82  * 4. The name of the author may not be used to endorse or promote products
83  *    derived from this software without specific prior written permission
84  *
85  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
86  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
87  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
88  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
89  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
90  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
91  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
92  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
93  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
94  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
95  */
96 
97 #ifndef _OR1K_BUS_FUNCS_H_
98 #define _OR1K_BUS_FUNCS_H_
99 
100 #define CAT(a,b)	a##b
101 #define CAT3(a,b,c)	a##b##c
102 
103 int bus_space_init(struct or1k_bus_space *, const char *, void *, size_t);
104 void bus_space_mallocok(void);
105 
106 /*
107  * Access methods for bus resources
108  */
109 
110 /*
111  *	void *bus_space_vaddr (bus_space_tag_t, bus_space_handle_t);
112  *
113  * Get the kernel virtual address for the mapped bus space.
114  * Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR.
115  *  (XXX not enforced)
116  */
117 #define bus_space_vaddr(t, h) ((void *)(h))
118 
119 /*
120  *	paddr_t bus_space_mmap  (bus_space_tag_t t, bus_addr_t addr,
121  *	    off_t offset, int prot, int flags);
122  *
123  * Mmap a region of bus space.
124  */
125 
126 #define bus_space_mmap(t, b, o, p, f)					\
127     ((*(t)->pbs_mmap)((t), (b), (o), (p), (f)))
128 
129 /*
130  *	int bus_space_map  (bus_space_tag_t t, bus_addr_t addr,
131  *	    bus_size_t size, int flags, bus_space_handle_t *bshp);
132  *
133  * Map a region of bus space.
134  */
135 
136 #define bus_space_map(t, a, s, f, hp)					\
137     ((*(t)->pbs_map)((t), (a), (s), (f), (hp)))
138 
139 /*
140  *	int bus_space_unmap (bus_space_tag_t t,
141  *	    bus_space_handle_t bsh, bus_size_t size);
142  *
143  * Unmap a region of bus space.
144  */
145 
146 #define bus_space_unmap(t, h, s)					\
147     ((void)(*(t)->pbs_unmap)((t), (h), (s)))
148 
149 /*
150  *	int bus_space_subregion (bus_space_tag_t t,
151  *	    bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
152  *	    bus_space_handle_t *nbshp);
153  *
154  * Get a new handle for a subregion of an already-mapped area of bus space.
155  */
156 
157 #define bus_space_subregion(t, h, o, s, hp)				\
158     ((*(t)->pbs_subregion)((t), (h), (o), (s), (hp)))
159 
160 /*
161  *	int bus_space_alloc (bus_space_tag_t t, bus_addr_t rstart,
162  *	    bus_addr_t rend, bus_size_t size, bus_size_t align,
163  *	    bus_size_t boundary, int flags, bus_addr_t *bpap,
164  *	    bus_space_handle_t *bshp);
165  *
166  * Allocate a region of bus space.
167  */
168 
169 #define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp)			\
170     ((*(t)->pbs_alloc)((t), (rs), (re), (s), (a), (b), (f), (ap), (hp)))
171 
172 /*
173  *	int bus_space_free (bus_space_tag_t t,
174  *	    bus_space_handle_t bsh, bus_size_t size);
175  *
176  * Free a region of bus space.
177  */
178 
179 #define	bus_space_free(t, h, s)						\
180     ((void)(*(t)->pbs_free)((t), (h), (s)))
181 
182 /*
183  *	uintN_t bus_space_read_N (bus_space_tag_t tag,
184  *	    bus_space_handle_t bsh, bus_size_t offset);
185  *
186  * Read a 1, 2, 4, or 8 byte quantity from bus space
187  * described by tag/handle/offset.
188  */
189 
190 #define bus_space_read_1(t, h, o)					\
191 	((*(t)->pbs_scalar.pbss_read_1)((t), (h), (o)))
192 #define bus_space_read_2(t, h, o)					\
193 	((*(t)->pbs_scalar.pbss_read_2)((t), (h), (o)))
194 #define bus_space_read_4(t, h, o)					\
195 	((*(t)->pbs_scalar.pbss_read_4)((t), (h), (o)))
196 #define bus_space_read_8(t, h, o)					\
197 	((*(t)->pbs_scalar.pbss_read_8)((t), (h), (o)))
198 
199 /*
200  *	uintN_t bus_space_read_stream_N (bus_space_tag_t tag,
201  *	    bus_space_handle_t bsh, bus_size_t offset);
202  *
203  * Read a 2, 4, or 8 byte quantity from bus space
204  * described by tag/handle/offset ignoring endianness.
205  */
206 
207 #define bus_space_read_stream_2(t, h, o)				\
208 	((*(t)->pbs_scalar_stream.pbss_read_2)((t), (h), (o)))
209 #define bus_space_read_stream_4(t, h, o)				\
210 	((*(t)->pbs_scalar_stream.pbss_read_4)((t), (h), (o)))
211 #define bus_space_read_stream_8(t, h, o)				\
212 	((*(t)->pbs_scalar_stream.pbss_read_8)((t), (h), (o)))
213 
214 /*
215  *	void bus_space_read_multi_N _P((bus_space_tag_t tag,
216  *	    bus_space_handle_t bsh, bus_size_t offset,
217  *	    uintN_t *addr, size_t count);
218  *
219  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
220  * described by tag/handle/offset and copy into buffer provided.
221  */
222 
223 #define bus_space_read_multi_1(t, h, o, a, c)				\
224 	((*(t)->pbs_multi->pbsg_read_1)((t), (h), (o), (a), (c)))
225 #define bus_space_read_multi_2(t, h, o, a, c)				\
226 	((*(t)->pbs_multi->pbsg_read_2)((t), (h), (o), (a), (c)))
227 #define bus_space_read_multi_4(t, h, o, a, c)				\
228 	((*(t)->pbs_multi->pbsg_read_4)((t), (h), (o), (a), (c)))
229 #define bus_space_read_multi_8(t, h, o, a, c)				\
230 	((*(t)->pbs_multi->pbsg_read_8)((t), (h), (o), (a), (c)))
231 
232 /*
233  *	void bus_space_read_multi_stream_N (bus_space_tag_t tag,
234  *	    bus_space_handle_t bsh, bus_size_t offset,
235  *	    uintN_t *addr, size_t count);
236  *
237  * Read `count' 2, 4, or 8 byte stream quantities from bus space
238  * described by tag/handle/offset and copy into buffer provided.
239  */
240 
241 #define bus_space_read_multi_stream_2(t, h, o, a, c)			\
242 	((*(t)->pbs_multi_stream->pbsg_read_2)((t), (h), (o), (a), (c)))
243 #define bus_space_read_multi_stream_4(t, h, o, a, c)			\
244 	((*(t)->pbs_multi_stream->pbsg_read_4)((t), (h), (o), (a), (c)))
245 #define bus_space_read_multi_stream_8(t, h, o, a, c)			\
246 	((*(t)->pbs_multi_stream->pbsg_read_8)((t), (h), (o), (a), (c)))
247 
248 /*
249  *	void bus_space_write_N (bus_space_tag_t tag,
250  *	    bus_space_handle_t bsh, bus_size_t offset,
251  *	    uintN_t value);
252  *
253  * Write the 1, 2, 4, or 8 byte value `value' to bus space
254  * described by tag/handle/offset.
255  */
256 
257 #define bus_space_write_1(t, h, o, v)					\
258 	((*(t)->pbs_scalar.pbss_write_1)((t), (h), (o), (v)))
259 #define bus_space_write_2(t, h, o, v)					\
260 	((*(t)->pbs_scalar.pbss_write_2)((t), (h), (o), (v)))
261 #define bus_space_write_4(t, h, o, v)					\
262 	((*(t)->pbs_scalar.pbss_write_4)((t), (h), (o), (v)))
263 #define bus_space_write_8(t, h, o, v)					\
264 	((*(t)->pbs_scalar.pbss_write_8)((t), (h), (o), (v)))
265 
266 /*
267  *	void bus_space_write_stream_N (bus_space_tag_t tag,
268  *	    bus_space_handle_t bsh, bus_size_t offset,
269  *	    uintN_t value);
270  *
271  * Write the 2, 4, or 8 byte stream value `value' to bus space
272  * described by tag/handle/offset.
273  */
274 
275 #define bus_space_write_stream_1(t, h, o, v)				\
276 	((*(t)->pbs_scalar_stream.pbss_write_1)((t), (h), (o), (v)))
277 #define bus_space_write_stream_2(t, h, o, v)				\
278 	((*(t)->pbs_scalar_stream.pbss_write_2)((t), (h), (o), (v)))
279 #define bus_space_write_stream_4(t, h, o, v)				\
280 	((*(t)->pbs_scalar_stream.pbss_write_4)((t), (h), (o), (v)))
281 #define bus_space_write_stream_8(t, h, o, v)				\
282 	((*(t)->pbs_scalar_stream.pbss_write_8)((t), (h), (o), (v)))
283 
284 /*
285  *	void bus_space_write_multi_N (bus_space_tag_t tag,
286  *	    bus_space_handle_t bsh, bus_size_t offset,
287  *	    const uintN_t *addr, size_t count);
288  *
289  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
290  * provided to bus space described by tag/handle/offset.
291  */
292 
293 #define bus_space_write_multi_1(t, h, o, a, c)				\
294 	((*(t)->pbs_multi->pbsg_write_1)((t), (h), (o), (a), (c)))
295 #define bus_space_write_multi_2(t, h, o, a, c)				\
296 	((*(t)->pbs_multi->pbsg_write_2)((t), (h), (o), (a), (c)))
297 #define bus_space_write_multi_4(t, h, o, a, c)				\
298 	((*(t)->pbs_multi->pbsg_write_4)((t), (h), (o), (a), (c)))
299 #define bus_space_write_multi_8(t, h, o, a, c)				\
300 	((*(t)->pbs_multi->pbsg_write_8)((t), (h), (o), (a), (c)))
301 
302 /*
303  *	void bus_space_write_multi_stream_N (bus_space_tag_t tag,
304  *	    bus_space_handle_t bsh, bus_size_t offset,
305  *	    const uintN_t *addr, size_t count);
306  *
307  * Write `count' 2, 4, or 8 byte stream quantities from the buffer
308  * provided to bus space described by tag/handle/offset.
309  */
310 
311 #define bus_space_write_multi_stream_1(t, h, o, a, c)			\
312 	((*(t)->pbs_multi_stream->pbsg_write_1)((t), (h), (o), (a), (c)))
313 #define bus_space_write_multi_stream_2(t, h, o, a, c)			\
314 	((*(t)->pbs_multi_stream->pbsg_write_2)((t), (h), (o), (a), (c)))
315 #define bus_space_write_multi_stream_4(t, h, o, a, c)			\
316 	((*(t)->pbs_multi_stream->pbsg_write_4)((t), (h), (o), (a), (c)))
317 #define bus_space_write_multi_stream_8(t, h, o, a, c)			\
318 	((*(t)->pbs_multi_stream->pbsg_write_8)((t), (h), (o), (a), (c)))
319 
320 /*
321  *	void bus_space_read_region_N (bus_space_tag_t tag,
322  *	    bus_space_handle_t bsh, bus_size_t offset,
323  *	    uintN_t *addr, size_t count);
324  *
325  * Read `count' 1, 2, 4, or 8 byte quantities from bus space
326  * described by tag/handle and starting at `offset' and copy into
327  * buffer provided.
328  */
329 #define bus_space_read_region_1(t, h, o, a, c)				\
330 	((*(t)->pbs_region->pbsg_read_1)((t), (h), (o), (a), (c)))
331 #define bus_space_read_region_2(t, h, o, a, c)				\
332 	((*(t)->pbs_region->pbsg_read_2)((t), (h), (o), (a), (c)))
333 #define bus_space_read_region_4(t, h, o, a, c)				\
334 	((*(t)->pbs_region->pbsg_read_4)((t), (h), (o), (a), (c)))
335 #define bus_space_read_region_8(t, h, o, a, c)				\
336 	((*(t)->pbs_region->pbsg_read_8)((t), (h), (o), (a), (c)))
337 
338 /*
339  *	void bus_space_read_region_stream_N (bus_space_tag_t tag,
340  *	    bus_space_handle_t bsh, bus_size_t offset,
341  *	    uintN_t *addr, size_t count);
342  *
343  * Read `count' 2, 4, or 8 byte stream quantities from bus space
344  * described by tag/handle and starting at `offset' and copy into
345  * buffer provided.
346  */
347 #define bus_space_read_region_stream_2(t, h, o, a, c)			\
348 	((*(t)->pbs_region_stream->pbsg_read_2)((t), (h), (o), (a), (c)))
349 #define bus_space_read_region_stream_4(t, h, o, a, c)			\
350 	((*(t)->pbs_region_stream->pbsg_read_4)((t), (h), (o), (a), (c)))
351 #define bus_space_read_region_stream_8(t, h, o, a, c)			\
352 	((*(t)->pbs_region_stream->pbsg_read_8)((t), (h), (o), (a), (c)))
353 
354 /*
355  *	void bus_space_write_region_N (bus_space_tag_t tag,
356  *	    bus_space_handle_t bsh, bus_size_t offset,
357  *	    const uintN_t *addr, size_t count);
358  *
359  * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
360  * to bus space described by tag/handle starting at `offset'.
361  */
362 #define bus_space_write_region_1(t, h, o, a, c)				\
363 	((*(t)->pbs_region->pbsg_write_1)((t), (h), (o), (a), (c)))
364 #define bus_space_write_region_2(t, h, o, a, c)				\
365 	((*(t)->pbs_region->pbsg_write_2)((t), (h), (o), (a), (c)))
366 #define bus_space_write_region_4(t, h, o, a, c)				\
367 	((*(t)->pbs_region->pbsg_write_4)((t), (h), (o), (a), (c)))
368 #define bus_space_write_region_8(t, h, o, a, c)				\
369 	((*(t)->pbs_region->pbsg_write_8)((t), (h), (o), (a), (c)))
370 
371 /*
372  *	void bus_space_write_region_stream_N (bus_space_tag_t tag,
373  *	    bus_space_handle_t bsh, bus_size_t offset,
374  *	    const uintN_t *addr, size_t count);
375  *
376  * Write `count' 2, 4, or 8 byte stream quantities from the buffer provided
377  * to bus space described by tag/handle starting at `offset'.
378  */
379 #define bus_space_write_region_stream_2(t, h, o, a, c)			\
380 	((*(t)->pbs_region_stream->pbsg_write_2)((t), (h), (o), (a), (c)))
381 #define bus_space_write_region_stream_4(t, h, o, a, c)			\
382 	((*(t)->pbs_region_stream->pbsg_write_4)((t), (h), (o), (a), (c)))
383 #define bus_space_write_region_stream_8(t, h, o, a, c)			\
384 	((*(t)->pbs_region_stream->pbsg_write_8)((t), (h), (o), (a), (c)))
385 
386 #if 0
387 /*
388  *	void bus_space_set_multi_N (bus_space_tag_t tag,
389  *	    bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
390  *	    size_t count);
391  *
392  * Write the 1, 2, 4, or 8 byte value `val' to bus space described
393  * by tag/handle/offset `count' times.
394  */
395 #define	bus_space_set_multi_1(t, h, o, v, c)
396 	((*(t)->pbs_set_multi_1)((t), (h), (o), (v), (c)))
397 #define	bus_space_set_multi_2(t, h, o, v, c)
398 	((*(t)->pbs_set_multi_2)((t), (h), (o), (v), (c)))
399 #define	bus_space_set_multi_4(t, h, o, v, c)
400 	((*(t)->pbs_set_multi_4)((t), (h), (o), (v), (c)))
401 #define	bus_space_set_multi_8(t, h, o, v, c)
402 	((*(t)->pbs_set_multi_8)((t), (h), (o), (v), (c)))
403 
404 /*
405  *	void bus_space_set_multi_stream_N (bus_space_tag_t tag,
406  *	    bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
407  *	    size_t count);
408  *
409  * Write the 2, 4, or 8 byte stream value `val' to bus space described
410  * by tag/handle/offset `count' times.
411  */
412 #define	bus_space_set_multi_stream_2(t, h, o, v, c)
413 	((*(t)->pbs_set_multi_stream_2)((t), (h), (o), (v), (c)))
414 #define	bus_space_set_multi_stream_4(t, h, o, v, c)
415 	((*(t)->pbs_set_multi_stream_4)((t), (h), (o), (v), (c)))
416 #define	bus_space_set_multi_stream_8(t, h, o, v, c)
417 	((*(t)->pbs_set_multi_stream_8)((t), (h), (o), (v), (c)))
418 
419 #endif
420 
421 /*
422  *	void bus_space_set_region_N (bus_space_tag_t tag,
423  *	    bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
424  *	    size_t count);
425  *
426  * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
427  * by tag/handle starting at `offset'.
428  */
429 #define bus_space_set_region_1(t, h, o, v, c)				\
430 	((*(t)->pbs_set->pbss_set_1)((t), (h), (o), (v), (c)))
431 #define bus_space_set_region_2(t, h, o, v, c)				\
432 	((*(t)->pbs_set->pbss_set_2)((t), (h), (o), (v), (c)))
433 #define bus_space_set_region_4(t, h, o, v, c)				\
434 	((*(t)->pbs_set->pbss_set_4)((t), (h), (o), (v), (c)))
435 #define bus_space_set_region_8(t, h, o, v, c)				\
436 	((*(t)->pbs_set->pbss_set_8)((t), (h), (o), (v), (c)))
437 
438 /*
439  *	void bus_space_set_region_stream_N (bus_space_tag_t tag,
440  *	    bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
441  *	    size_t count);
442  *
443  * Write `count' 2, 4, or 8 byte stream value `val' to bus space described
444  * by tag/handle starting at `offset'.
445  */
446 #define bus_space_set_region_stream_2(t, h, o, v, c)			\
447 	((*(t)->pbs_set_stream->pbss_set_2)((t), (h), (o), (v), (c)))
448 #define bus_space_set_region_stream_4(t, h, o, v, c)			\
449 	((*(t)->pbs_set_stream->pbss_set_4)((t), (h), (o), (v), (c)))
450 #define bus_space_set_region_stream_8(t, h, o, v, c)			\
451 	((*(t)->pbs_set_stream->pbss_set_8)((t), (h), (o), (v), (c)))
452 
453 
454 /*
455  *	void bus_space_copy_region_N (bus_space_tag_t tag,
456  *	    bus_space_handle_t bsh1, bus_size_t off1,
457  *	    bus_space_handle_t bsh2, bus_size_t off2,
458  *	    size_t count);
459  *
460  * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
461  * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
462  */
463 #define bus_space_copy_region_1(t, h1, o1, h2, o2, c)			\
464 	((*(t)->pbs_copy->pbsc_copy_1)((t), (h1), (o1), (h2), (o2), (c)))
465 #define bus_space_copy_region_2(t, h1, o1, h2, o2, c)			\
466 	((*(t)->pbs_copy->pbsc_copy_2)((t), (h1), (o1), (h2), (o2), (c)))
467 #define bus_space_copy_region_4(t, h1, o1, h2, o2, c)			\
468 	((*(t)->pbs_copy->pbsc_copy_4)((t), (h1), (o1), (h2), (o2), (c)))
469 #define bus_space_copy_region_8(t, h1, o1, h2, o2, c)			\
470 	((*(t)->pbs_copy->pbsc_copy_8)((t), (h1), (o1), (h2), (o2), (c)))
471 
472 /*
473  * Bus read/write barrier methods.
474  *
475  *	void bus_space_barrier (bus_space_tag_t tag,
476  *	    bus_space_handle_t bsh, bus_size_t offset,
477  *	    bus_size_t len, int flags);
478  *
479  */
480 #define	bus_space_barrier(t, h, o, l, f)	\
481 	((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
482 
483 /*
484  * Bus DMA methods.
485  */
486 
487 /* Forwards needed by prototypes below. */
488 struct proc;
489 struct mbuf;
490 struct uio;
491 
492 #define	bus_dmamap_create(t, s, n, m, b, f, p)			\
493 	(*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
494 #define	bus_dmamap_destroy(t, p)				\
495 	(*(t)->_dmamap_destroy)((t), (p))
496 #define	bus_dmamap_load(t, m, b, s, p, f)			\
497 	(*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
498 #define	bus_dmamap_load_mbuf(t, m, b, f)			\
499 	(*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
500 #define	bus_dmamap_load_uio(t, m, u, f)				\
501 	(*(t)->_dmamap_load_uio)((t), (m), (u), (f))
502 #define	bus_dmamap_load_raw(t, m, sg, n, s, f)			\
503 	(*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
504 #define	bus_dmamap_unload(t, p)					\
505 	(*(t)->_dmamap_unload)((t), (p))
506 #define	bus_dmamap_sync(t, p, o, l, ops)			\
507 	(void)((t)->_dmamap_sync ?				\
508 	    (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
509 
510 #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
511 	(*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
512 #define	bus_dmamem_free(t, sg, n)				\
513 	(*(t)->_dmamem_free)((t), (sg), (n))
514 #define	bus_dmamem_map(t, sg, n, s, k, f)			\
515 	(*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
516 #define	bus_dmamem_unmap(t, k, s)				\
517 	(*(t)->_dmamem_unmap)((t), (k), (s))
518 #define	bus_dmamem_mmap(t, sg, n, o, p, f)			\
519 	(*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
520 
521 #define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP
522 #define bus_dmatag_destroy(t)
523 
524 #ifdef _OR1K_BUS_DMA_PRIVATE
525 int	_bus_dmamap_create (bus_dma_tag_t, bus_size_t, int, bus_size_t,
526 	    bus_size_t, int, bus_dmamap_t *);
527 void	_bus_dmamap_destroy (bus_dma_tag_t, bus_dmamap_t);
528 int	_bus_dmamap_load (bus_dma_tag_t, bus_dmamap_t, void *,
529 	    bus_size_t, struct proc *, int);
530 int	_bus_dmamap_load_mbuf (bus_dma_tag_t, bus_dmamap_t,
531 	    struct mbuf *, int);
532 int	_bus_dmamap_load_uio (bus_dma_tag_t, bus_dmamap_t,
533 	    struct uio *, int);
534 int	_bus_dmamap_load_raw (bus_dma_tag_t, bus_dmamap_t,
535 	    bus_dma_segment_t *, int, bus_size_t, int);
536 void	_bus_dmamap_unload (bus_dma_tag_t, bus_dmamap_t);
537 void	_bus_dmamap_sync (bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
538 	    bus_size_t, int);
539 
540 int	_bus_dmamem_alloc (bus_dma_tag_t tag, bus_size_t size,
541 	    bus_size_t alignment, bus_size_t boundary,
542 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
543 void	_bus_dmamem_free (bus_dma_tag_t tag, bus_dma_segment_t *segs,
544 	    int nsegs);
545 int	_bus_dmamem_map (bus_dma_tag_t tag, bus_dma_segment_t *segs,
546 	    int nsegs, size_t size, void **kvap, int flags);
547 void	_bus_dmamem_unmap (bus_dma_tag_t tag, void *kva,
548 	    size_t size);
549 paddr_t	_bus_dmamem_mmap (bus_dma_tag_t tag, bus_dma_segment_t *segs,
550 	    int nsegs, off_t off, int prot, int flags);
551 
552 int	_bus_dmamem_alloc_range (bus_dma_tag_t tag, bus_size_t size,
553 	    bus_size_t alignment, bus_size_t boundary,
554 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
555 	    paddr_t low, paddr_t high);
556 
557 #endif /* _OR1K_BUS_DMA_PRIVATE */
558 
559 #endif /* _OR1K_BUS_FUNCS_H_ */
560