bus_funcs.h revision 1.1 1 1.1 matt /* $NetBSD: bus_funcs.h,v 1.1 2014/08/10 05:47:38 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 _AARCH64_BUS_FUNCS_H_
98 1.1 matt #define _AARCH64_BUS_FUNCS_H_
99 1.1 matt
100 1.1 matt #ifdef __aarch64__
101 1.1 matt
102 1.1 matt #define CAT(a,b) a##b
103 1.1 matt #define CAT3(a,b,c) a##b##c
104 1.1 matt
105 1.1 matt int bus_space_init(struct aarch64_bus_space *, const char *, void *, size_t);
106 1.1 matt void bus_space_mallocok(void);
107 1.1 matt
108 1.1 matt /*
109 1.1 matt * Access methods for bus resources
110 1.1 matt */
111 1.1 matt
112 1.1 matt /*
113 1.1 matt * void *bus_space_vaddr (bus_space_tag_t, bus_space_handle_t);
114 1.1 matt *
115 1.1 matt * Get the kernel virtual address for the mapped bus space.
116 1.1 matt * Only allowed for regions mapped with BUS_SPACE_MAP_LINEAR.
117 1.1 matt * (XXX not enforced)
118 1.1 matt */
119 1.1 matt #define bus_space_vaddr(t, h) ((void *)(h))
120 1.1 matt
121 1.1 matt /*
122 1.1 matt * paddr_t bus_space_mmap (bus_space_tag_t t, bus_addr_t addr,
123 1.1 matt * off_t offset, int prot, int flags);
124 1.1 matt *
125 1.1 matt * Mmap a region of bus space.
126 1.1 matt */
127 1.1 matt
128 1.1 matt #define bus_space_mmap(t, b, o, p, f) \
129 1.1 matt ((*(t)->pbs_mmap)((t), (b), (o), (p), (f)))
130 1.1 matt
131 1.1 matt /*
132 1.1 matt * int bus_space_map (bus_space_tag_t t, bus_addr_t addr,
133 1.1 matt * bus_size_t size, int flags, bus_space_handle_t *bshp);
134 1.1 matt *
135 1.1 matt * Map a region of bus space.
136 1.1 matt */
137 1.1 matt
138 1.1 matt #define bus_space_map(t, a, s, f, hp) \
139 1.1 matt ((*(t)->pbs_map)((t), (a), (s), (f), (hp)))
140 1.1 matt
141 1.1 matt /*
142 1.1 matt * int bus_space_unmap (bus_space_tag_t t,
143 1.1 matt * bus_space_handle_t bsh, bus_size_t size);
144 1.1 matt *
145 1.1 matt * Unmap a region of bus space.
146 1.1 matt */
147 1.1 matt
148 1.1 matt #define bus_space_unmap(t, h, s) \
149 1.1 matt ((void)(*(t)->pbs_unmap)((t), (h), (s)))
150 1.1 matt
151 1.1 matt /*
152 1.1 matt * int bus_space_subregion (bus_space_tag_t t,
153 1.1 matt * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
154 1.1 matt * bus_space_handle_t *nbshp);
155 1.1 matt *
156 1.1 matt * Get a new handle for a subregion of an already-mapped area of bus space.
157 1.1 matt */
158 1.1 matt
159 1.1 matt #define bus_space_subregion(t, h, o, s, hp) \
160 1.1 matt ((*(t)->pbs_subregion)((t), (h), (o), (s), (hp)))
161 1.1 matt
162 1.1 matt /*
163 1.1 matt * int bus_space_alloc (bus_space_tag_t t, bus_addr_t rstart,
164 1.1 matt * bus_addr_t rend, bus_size_t size, bus_size_t align,
165 1.1 matt * bus_size_t boundary, int flags, bus_addr_t *bpap,
166 1.1 matt * bus_space_handle_t *bshp);
167 1.1 matt *
168 1.1 matt * Allocate a region of bus space.
169 1.1 matt */
170 1.1 matt
171 1.1 matt #define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp) \
172 1.1 matt ((*(t)->pbs_alloc)((t), (rs), (re), (s), (a), (b), (f), (ap), (hp)))
173 1.1 matt
174 1.1 matt /*
175 1.1 matt * int bus_space_free (bus_space_tag_t t,
176 1.1 matt * bus_space_handle_t bsh, bus_size_t size);
177 1.1 matt *
178 1.1 matt * Free a region of bus space.
179 1.1 matt */
180 1.1 matt
181 1.1 matt #define bus_space_free(t, h, s) \
182 1.1 matt ((void)(*(t)->pbs_free)((t), (h), (s)))
183 1.1 matt
184 1.1 matt /*
185 1.1 matt * uintN_t bus_space_read_N (bus_space_tag_t tag,
186 1.1 matt * bus_space_handle_t bsh, bus_size_t offset);
187 1.1 matt *
188 1.1 matt * Read a 1, 2, 4, or 8 byte quantity from bus space
189 1.1 matt * described by tag/handle/offset.
190 1.1 matt */
191 1.1 matt
192 1.1 matt #define bus_space_read_1(t, h, o) \
193 1.1 matt ((*(t)->pbs_scalar.pbss_read_1)((t), (h), (o)))
194 1.1 matt #define bus_space_read_2(t, h, o) \
195 1.1 matt ((*(t)->pbs_scalar.pbss_read_2)((t), (h), (o)))
196 1.1 matt #define bus_space_read_4(t, h, o) \
197 1.1 matt ((*(t)->pbs_scalar.pbss_read_4)((t), (h), (o)))
198 1.1 matt #define bus_space_read_8(t, h, o) \
199 1.1 matt ((*(t)->pbs_scalar.pbss_read_8)((t), (h), (o)))
200 1.1 matt
201 1.1 matt /*
202 1.1 matt * uintN_t bus_space_read_stream_N (bus_space_tag_t tag,
203 1.1 matt * bus_space_handle_t bsh, bus_size_t offset);
204 1.1 matt *
205 1.1 matt * Read a 2, 4, or 8 byte quantity from bus space
206 1.1 matt * described by tag/handle/offset ignoring endianness.
207 1.1 matt */
208 1.1 matt
209 1.1 matt #define bus_space_read_stream_2(t, h, o) \
210 1.1 matt ((*(t)->pbs_scalar_stream.pbss_read_2)((t), (h), (o)))
211 1.1 matt #define bus_space_read_stream_4(t, h, o) \
212 1.1 matt ((*(t)->pbs_scalar_stream.pbss_read_4)((t), (h), (o)))
213 1.1 matt #define bus_space_read_stream_8(t, h, o) \
214 1.1 matt ((*(t)->pbs_scalar_stream.pbss_read_8)((t), (h), (o)))
215 1.1 matt
216 1.1 matt /*
217 1.1 matt * void bus_space_read_multi_N _P((bus_space_tag_t tag,
218 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
219 1.1 matt * uintN_t *addr, size_t count);
220 1.1 matt *
221 1.1 matt * Read `count' 1, 2, 4, or 8 byte quantities from bus space
222 1.1 matt * described by tag/handle/offset and copy into buffer provided.
223 1.1 matt */
224 1.1 matt
225 1.1 matt #define bus_space_read_multi_1(t, h, o, a, c) \
226 1.1 matt ((*(t)->pbs_multi->pbsg_read_1)((t), (h), (o), (a), (c)))
227 1.1 matt #define bus_space_read_multi_2(t, h, o, a, c) \
228 1.1 matt ((*(t)->pbs_multi->pbsg_read_2)((t), (h), (o), (a), (c)))
229 1.1 matt #define bus_space_read_multi_4(t, h, o, a, c) \
230 1.1 matt ((*(t)->pbs_multi->pbsg_read_4)((t), (h), (o), (a), (c)))
231 1.1 matt #define bus_space_read_multi_8(t, h, o, a, c) \
232 1.1 matt ((*(t)->pbs_multi->pbsg_read_8)((t), (h), (o), (a), (c)))
233 1.1 matt
234 1.1 matt /*
235 1.1 matt * void bus_space_read_multi_stream_N (bus_space_tag_t tag,
236 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
237 1.1 matt * uintN_t *addr, size_t count);
238 1.1 matt *
239 1.1 matt * Read `count' 2, 4, or 8 byte stream quantities from bus space
240 1.1 matt * described by tag/handle/offset and copy into buffer provided.
241 1.1 matt */
242 1.1 matt
243 1.1 matt #define bus_space_read_multi_stream_2(t, h, o, a, c) \
244 1.1 matt ((*(t)->pbs_multi_stream->pbsg_read_2)((t), (h), (o), (a), (c)))
245 1.1 matt #define bus_space_read_multi_stream_4(t, h, o, a, c) \
246 1.1 matt ((*(t)->pbs_multi_stream->pbsg_read_4)((t), (h), (o), (a), (c)))
247 1.1 matt #define bus_space_read_multi_stream_8(t, h, o, a, c) \
248 1.1 matt ((*(t)->pbs_multi_stream->pbsg_read_8)((t), (h), (o), (a), (c)))
249 1.1 matt
250 1.1 matt /*
251 1.1 matt * void bus_space_write_N (bus_space_tag_t tag,
252 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
253 1.1 matt * uintN_t value);
254 1.1 matt *
255 1.1 matt * Write the 1, 2, 4, or 8 byte value `value' to bus space
256 1.1 matt * described by tag/handle/offset.
257 1.1 matt */
258 1.1 matt
259 1.1 matt #define bus_space_write_1(t, h, o, v) \
260 1.1 matt ((*(t)->pbs_scalar.pbss_write_1)((t), (h), (o), (v)))
261 1.1 matt #define bus_space_write_2(t, h, o, v) \
262 1.1 matt ((*(t)->pbs_scalar.pbss_write_2)((t), (h), (o), (v)))
263 1.1 matt #define bus_space_write_4(t, h, o, v) \
264 1.1 matt ((*(t)->pbs_scalar.pbss_write_4)((t), (h), (o), (v)))
265 1.1 matt #define bus_space_write_8(t, h, o, v) \
266 1.1 matt ((*(t)->pbs_scalar.pbss_write_8)((t), (h), (o), (v)))
267 1.1 matt
268 1.1 matt /*
269 1.1 matt * void bus_space_write_stream_N (bus_space_tag_t tag,
270 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
271 1.1 matt * uintN_t value);
272 1.1 matt *
273 1.1 matt * Write the 2, 4, or 8 byte stream value `value' to bus space
274 1.1 matt * described by tag/handle/offset.
275 1.1 matt */
276 1.1 matt
277 1.1 matt #define bus_space_write_stream_1(t, h, o, v) \
278 1.1 matt ((*(t)->pbs_scalar_stream.pbss_write_1)((t), (h), (o), (v)))
279 1.1 matt #define bus_space_write_stream_2(t, h, o, v) \
280 1.1 matt ((*(t)->pbs_scalar_stream.pbss_write_2)((t), (h), (o), (v)))
281 1.1 matt #define bus_space_write_stream_4(t, h, o, v) \
282 1.1 matt ((*(t)->pbs_scalar_stream.pbss_write_4)((t), (h), (o), (v)))
283 1.1 matt #define bus_space_write_stream_8(t, h, o, v) \
284 1.1 matt ((*(t)->pbs_scalar_stream.pbss_write_8)((t), (h), (o), (v)))
285 1.1 matt
286 1.1 matt /*
287 1.1 matt * void bus_space_write_multi_N (bus_space_tag_t tag,
288 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
289 1.1 matt * const uintN_t *addr, size_t count);
290 1.1 matt *
291 1.1 matt * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
292 1.1 matt * provided to bus space described by tag/handle/offset.
293 1.1 matt */
294 1.1 matt
295 1.1 matt #define bus_space_write_multi_1(t, h, o, a, c) \
296 1.1 matt ((*(t)->pbs_multi->pbsg_write_1)((t), (h), (o), (a), (c)))
297 1.1 matt #define bus_space_write_multi_2(t, h, o, a, c) \
298 1.1 matt ((*(t)->pbs_multi->pbsg_write_2)((t), (h), (o), (a), (c)))
299 1.1 matt #define bus_space_write_multi_4(t, h, o, a, c) \
300 1.1 matt ((*(t)->pbs_multi->pbsg_write_4)((t), (h), (o), (a), (c)))
301 1.1 matt #define bus_space_write_multi_8(t, h, o, a, c) \
302 1.1 matt ((*(t)->pbs_multi->pbsg_write_8)((t), (h), (o), (a), (c)))
303 1.1 matt
304 1.1 matt /*
305 1.1 matt * void bus_space_write_multi_stream_N (bus_space_tag_t tag,
306 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
307 1.1 matt * const uintN_t *addr, size_t count);
308 1.1 matt *
309 1.1 matt * Write `count' 2, 4, or 8 byte stream quantities from the buffer
310 1.1 matt * provided to bus space described by tag/handle/offset.
311 1.1 matt */
312 1.1 matt
313 1.1 matt #define bus_space_write_multi_stream_1(t, h, o, a, c) \
314 1.1 matt ((*(t)->pbs_multi_stream->pbsg_write_1)((t), (h), (o), (a), (c)))
315 1.1 matt #define bus_space_write_multi_stream_2(t, h, o, a, c) \
316 1.1 matt ((*(t)->pbs_multi_stream->pbsg_write_2)((t), (h), (o), (a), (c)))
317 1.1 matt #define bus_space_write_multi_stream_4(t, h, o, a, c) \
318 1.1 matt ((*(t)->pbs_multi_stream->pbsg_write_4)((t), (h), (o), (a), (c)))
319 1.1 matt #define bus_space_write_multi_stream_8(t, h, o, a, c) \
320 1.1 matt ((*(t)->pbs_multi_stream->pbsg_write_8)((t), (h), (o), (a), (c)))
321 1.1 matt
322 1.1 matt /*
323 1.1 matt * void bus_space_read_region_N (bus_space_tag_t tag,
324 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
325 1.1 matt * uintN_t *addr, size_t count);
326 1.1 matt *
327 1.1 matt * Read `count' 1, 2, 4, or 8 byte quantities from bus space
328 1.1 matt * described by tag/handle and starting at `offset' and copy into
329 1.1 matt * buffer provided.
330 1.1 matt */
331 1.1 matt #define bus_space_read_region_1(t, h, o, a, c) \
332 1.1 matt ((*(t)->pbs_region->pbsg_read_1)((t), (h), (o), (a), (c)))
333 1.1 matt #define bus_space_read_region_2(t, h, o, a, c) \
334 1.1 matt ((*(t)->pbs_region->pbsg_read_2)((t), (h), (o), (a), (c)))
335 1.1 matt #define bus_space_read_region_4(t, h, o, a, c) \
336 1.1 matt ((*(t)->pbs_region->pbsg_read_4)((t), (h), (o), (a), (c)))
337 1.1 matt #define bus_space_read_region_8(t, h, o, a, c) \
338 1.1 matt ((*(t)->pbs_region->pbsg_read_8)((t), (h), (o), (a), (c)))
339 1.1 matt
340 1.1 matt /*
341 1.1 matt * void bus_space_read_region_stream_N (bus_space_tag_t tag,
342 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
343 1.1 matt * uintN_t *addr, size_t count);
344 1.1 matt *
345 1.1 matt * Read `count' 2, 4, or 8 byte stream quantities from bus space
346 1.1 matt * described by tag/handle and starting at `offset' and copy into
347 1.1 matt * buffer provided.
348 1.1 matt */
349 1.1 matt #define bus_space_read_region_stream_2(t, h, o, a, c) \
350 1.1 matt ((*(t)->pbs_region_stream->pbsg_read_2)((t), (h), (o), (a), (c)))
351 1.1 matt #define bus_space_read_region_stream_4(t, h, o, a, c) \
352 1.1 matt ((*(t)->pbs_region_stream->pbsg_read_4)((t), (h), (o), (a), (c)))
353 1.1 matt #define bus_space_read_region_stream_8(t, h, o, a, c) \
354 1.1 matt ((*(t)->pbs_region_stream->pbsg_read_8)((t), (h), (o), (a), (c)))
355 1.1 matt
356 1.1 matt /*
357 1.1 matt * void bus_space_write_region_N (bus_space_tag_t tag,
358 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
359 1.1 matt * const uintN_t *addr, size_t count);
360 1.1 matt *
361 1.1 matt * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
362 1.1 matt * to bus space described by tag/handle starting at `offset'.
363 1.1 matt */
364 1.1 matt #define bus_space_write_region_1(t, h, o, a, c) \
365 1.1 matt ((*(t)->pbs_region->pbsg_write_1)((t), (h), (o), (a), (c)))
366 1.1 matt #define bus_space_write_region_2(t, h, o, a, c) \
367 1.1 matt ((*(t)->pbs_region->pbsg_write_2)((t), (h), (o), (a), (c)))
368 1.1 matt #define bus_space_write_region_4(t, h, o, a, c) \
369 1.1 matt ((*(t)->pbs_region->pbsg_write_4)((t), (h), (o), (a), (c)))
370 1.1 matt #define bus_space_write_region_8(t, h, o, a, c) \
371 1.1 matt ((*(t)->pbs_region->pbsg_write_8)((t), (h), (o), (a), (c)))
372 1.1 matt
373 1.1 matt /*
374 1.1 matt * void bus_space_write_region_stream_N (bus_space_tag_t tag,
375 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
376 1.1 matt * const uintN_t *addr, size_t count);
377 1.1 matt *
378 1.1 matt * Write `count' 2, 4, or 8 byte stream quantities from the buffer provided
379 1.1 matt * to bus space described by tag/handle starting at `offset'.
380 1.1 matt */
381 1.1 matt #define bus_space_write_region_stream_2(t, h, o, a, c) \
382 1.1 matt ((*(t)->pbs_region_stream->pbsg_write_2)((t), (h), (o), (a), (c)))
383 1.1 matt #define bus_space_write_region_stream_4(t, h, o, a, c) \
384 1.1 matt ((*(t)->pbs_region_stream->pbsg_write_4)((t), (h), (o), (a), (c)))
385 1.1 matt #define bus_space_write_region_stream_8(t, h, o, a, c) \
386 1.1 matt ((*(t)->pbs_region_stream->pbsg_write_8)((t), (h), (o), (a), (c)))
387 1.1 matt
388 1.1 matt #if 0
389 1.1 matt /*
390 1.1 matt * void bus_space_set_multi_N (bus_space_tag_t tag,
391 1.1 matt * bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
392 1.1 matt * size_t count);
393 1.1 matt *
394 1.1 matt * Write the 1, 2, 4, or 8 byte value `val' to bus space described
395 1.1 matt * by tag/handle/offset `count' times.
396 1.1 matt */
397 1.1 matt #define bus_space_set_multi_1(t, h, o, v, c)
398 1.1 matt ((*(t)->pbs_set_multi_1)((t), (h), (o), (v), (c)))
399 1.1 matt #define bus_space_set_multi_2(t, h, o, v, c)
400 1.1 matt ((*(t)->pbs_set_multi_2)((t), (h), (o), (v), (c)))
401 1.1 matt #define bus_space_set_multi_4(t, h, o, v, c)
402 1.1 matt ((*(t)->pbs_set_multi_4)((t), (h), (o), (v), (c)))
403 1.1 matt #define bus_space_set_multi_8(t, h, o, v, c)
404 1.1 matt ((*(t)->pbs_set_multi_8)((t), (h), (o), (v), (c)))
405 1.1 matt
406 1.1 matt /*
407 1.1 matt * void bus_space_set_multi_stream_N (bus_space_tag_t tag,
408 1.1 matt * bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
409 1.1 matt * size_t count);
410 1.1 matt *
411 1.1 matt * Write the 2, 4, or 8 byte stream value `val' to bus space described
412 1.1 matt * by tag/handle/offset `count' times.
413 1.1 matt */
414 1.1 matt #define bus_space_set_multi_stream_2(t, h, o, v, c)
415 1.1 matt ((*(t)->pbs_set_multi_stream_2)((t), (h), (o), (v), (c)))
416 1.1 matt #define bus_space_set_multi_stream_4(t, h, o, v, c)
417 1.1 matt ((*(t)->pbs_set_multi_stream_4)((t), (h), (o), (v), (c)))
418 1.1 matt #define bus_space_set_multi_stream_8(t, h, o, v, c)
419 1.1 matt ((*(t)->pbs_set_multi_stream_8)((t), (h), (o), (v), (c)))
420 1.1 matt
421 1.1 matt #endif
422 1.1 matt
423 1.1 matt /*
424 1.1 matt * void bus_space_set_region_N (bus_space_tag_t tag,
425 1.1 matt * bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
426 1.1 matt * size_t count);
427 1.1 matt *
428 1.1 matt * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
429 1.1 matt * by tag/handle starting at `offset'.
430 1.1 matt */
431 1.1 matt #define bus_space_set_region_1(t, h, o, v, c) \
432 1.1 matt ((*(t)->pbs_set->pbss_set_1)((t), (h), (o), (v), (c)))
433 1.1 matt #define bus_space_set_region_2(t, h, o, v, c) \
434 1.1 matt ((*(t)->pbs_set->pbss_set_2)((t), (h), (o), (v), (c)))
435 1.1 matt #define bus_space_set_region_4(t, h, o, v, c) \
436 1.1 matt ((*(t)->pbs_set->pbss_set_4)((t), (h), (o), (v), (c)))
437 1.1 matt #define bus_space_set_region_8(t, h, o, v, c) \
438 1.1 matt ((*(t)->pbs_set->pbss_set_8)((t), (h), (o), (v), (c)))
439 1.1 matt
440 1.1 matt /*
441 1.1 matt * void bus_space_set_region_stream_N (bus_space_tag_t tag,
442 1.1 matt * bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
443 1.1 matt * size_t count);
444 1.1 matt *
445 1.1 matt * Write `count' 2, 4, or 8 byte stream value `val' to bus space described
446 1.1 matt * by tag/handle starting at `offset'.
447 1.1 matt */
448 1.1 matt #define bus_space_set_region_stream_2(t, h, o, v, c) \
449 1.1 matt ((*(t)->pbs_set_stream->pbss_set_2)((t), (h), (o), (v), (c)))
450 1.1 matt #define bus_space_set_region_stream_4(t, h, o, v, c) \
451 1.1 matt ((*(t)->pbs_set_stream->pbss_set_4)((t), (h), (o), (v), (c)))
452 1.1 matt #define bus_space_set_region_stream_8(t, h, o, v, c) \
453 1.1 matt ((*(t)->pbs_set_stream->pbss_set_8)((t), (h), (o), (v), (c)))
454 1.1 matt
455 1.1 matt
456 1.1 matt /*
457 1.1 matt * void bus_space_copy_region_N (bus_space_tag_t tag,
458 1.1 matt * bus_space_handle_t bsh1, bus_size_t off1,
459 1.1 matt * bus_space_handle_t bsh2, bus_size_t off2,
460 1.1 matt * size_t count);
461 1.1 matt *
462 1.1 matt * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
463 1.1 matt * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
464 1.1 matt */
465 1.1 matt #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
466 1.1 matt ((*(t)->pbs_copy->pbsc_copy_1)((t), (h1), (o1), (h2), (o2), (c)))
467 1.1 matt #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
468 1.1 matt ((*(t)->pbs_copy->pbsc_copy_2)((t), (h1), (o1), (h2), (o2), (c)))
469 1.1 matt #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
470 1.1 matt ((*(t)->pbs_copy->pbsc_copy_4)((t), (h1), (o1), (h2), (o2), (c)))
471 1.1 matt #define bus_space_copy_region_8(t, h1, o1, h2, o2, c) \
472 1.1 matt ((*(t)->pbs_copy->pbsc_copy_8)((t), (h1), (o1), (h2), (o2), (c)))
473 1.1 matt
474 1.1 matt /*
475 1.1 matt * Bus read/write barrier methods.
476 1.1 matt *
477 1.1 matt * void bus_space_barrier (bus_space_tag_t tag,
478 1.1 matt * bus_space_handle_t bsh, bus_size_t offset,
479 1.1 matt * bus_size_t len, int flags);
480 1.1 matt *
481 1.1 matt */
482 1.1 matt #define bus_space_barrier(t, h, o, l, f) \
483 1.1 matt ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
484 1.1 matt
485 1.1 matt /*
486 1.1 matt * Bus DMA methods.
487 1.1 matt */
488 1.1 matt
489 1.1 matt /* Forwards needed by prototypes below. */
490 1.1 matt struct proc;
491 1.1 matt struct mbuf;
492 1.1 matt struct uio;
493 1.1 matt
494 1.1 matt #define bus_dmamap_create(t, s, n, m, b, f, p) \
495 1.1 matt (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
496 1.1 matt #define bus_dmamap_destroy(t, p) \
497 1.1 matt (*(t)->_dmamap_destroy)((t), (p))
498 1.1 matt #define bus_dmamap_load(t, m, b, s, p, f) \
499 1.1 matt (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
500 1.1 matt #define bus_dmamap_load_mbuf(t, m, b, f) \
501 1.1 matt (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
502 1.1 matt #define bus_dmamap_load_uio(t, m, u, f) \
503 1.1 matt (*(t)->_dmamap_load_uio)((t), (m), (u), (f))
504 1.1 matt #define bus_dmamap_load_raw(t, m, sg, n, s, f) \
505 1.1 matt (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
506 1.1 matt #define bus_dmamap_unload(t, p) \
507 1.1 matt (*(t)->_dmamap_unload)((t), (p))
508 1.1 matt #define bus_dmamap_sync(t, p, o, l, ops) \
509 1.1 matt (void)((t)->_dmamap_sync ? \
510 1.1 matt (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
511 1.1 matt
512 1.1 matt #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
513 1.1 matt (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
514 1.1 matt #define bus_dmamem_free(t, sg, n) \
515 1.1 matt (*(t)->_dmamem_free)((t), (sg), (n))
516 1.1 matt #define bus_dmamem_map(t, sg, n, s, k, f) \
517 1.1 matt (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
518 1.1 matt #define bus_dmamem_unmap(t, k, s) \
519 1.1 matt (*(t)->_dmamem_unmap)((t), (k), (s))
520 1.1 matt #define bus_dmamem_mmap(t, sg, n, o, p, f) \
521 1.1 matt (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
522 1.1 matt
523 1.1 matt #define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP
524 1.1 matt #define bus_dmatag_destroy(t)
525 1.1 matt
526 1.1 matt #ifdef _AARCH64_BUS_DMA_PRIVATE
527 1.1 matt int _bus_dmamap_create (bus_dma_tag_t, bus_size_t, int, bus_size_t,
528 1.1 matt bus_size_t, int, bus_dmamap_t *);
529 1.1 matt void _bus_dmamap_destroy (bus_dma_tag_t, bus_dmamap_t);
530 1.1 matt int _bus_dmamap_load (bus_dma_tag_t, bus_dmamap_t, void *,
531 1.1 matt bus_size_t, struct proc *, int);
532 1.1 matt int _bus_dmamap_load_mbuf (bus_dma_tag_t, bus_dmamap_t,
533 1.1 matt struct mbuf *, int);
534 1.1 matt int _bus_dmamap_load_uio (bus_dma_tag_t, bus_dmamap_t,
535 1.1 matt struct uio *, int);
536 1.1 matt int _bus_dmamap_load_raw (bus_dma_tag_t, bus_dmamap_t,
537 1.1 matt bus_dma_segment_t *, int, bus_size_t, int);
538 1.1 matt void _bus_dmamap_unload (bus_dma_tag_t, bus_dmamap_t);
539 1.1 matt void _bus_dmamap_sync (bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
540 1.1 matt bus_size_t, int);
541 1.1 matt
542 1.1 matt int _bus_dmamem_alloc (bus_dma_tag_t tag, bus_size_t size,
543 1.1 matt bus_size_t alignment, bus_size_t boundary,
544 1.1 matt bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
545 1.1 matt void _bus_dmamem_free (bus_dma_tag_t tag, bus_dma_segment_t *segs,
546 1.1 matt int nsegs);
547 1.1 matt int _bus_dmamem_map (bus_dma_tag_t tag, bus_dma_segment_t *segs,
548 1.1 matt int nsegs, size_t size, void **kvap, int flags);
549 1.1 matt void _bus_dmamem_unmap (bus_dma_tag_t tag, void *kva,
550 1.1 matt size_t size);
551 1.1 matt paddr_t _bus_dmamem_mmap (bus_dma_tag_t tag, bus_dma_segment_t *segs,
552 1.1 matt int nsegs, off_t off, int prot, int flags);
553 1.1 matt
554 1.1 matt int _bus_dmamem_alloc_range (bus_dma_tag_t tag, bus_size_t size,
555 1.1 matt bus_size_t alignment, bus_size_t boundary,
556 1.1 matt bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
557 1.1 matt paddr_t low, paddr_t high);
558 1.1 matt
559 1.1 matt #endif /* _AARCH64_BUS_DMA_PRIVATE */
560 1.1 matt
561 1.1 matt #elif defined(__arm__)
562 1.1 matt
563 1.1 matt #include <arm/bus_funcs.h>
564 1.1 matt
565 1.1 matt #endif /* __aarch64__/__arm__ */
566 1.1 matt
567 1.1 matt #endif /* _AARCH64_BUS_FUNCS_H_ */
568