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