bus.h revision 1.18.4.2 1 1.18.4.2 thorpej /* $NetBSD: bus.h,v 1.18.4.2 2002/12/11 06:12:38 thorpej Exp $ */
2 1.18.4.2 thorpej
3 1.18.4.2 thorpej /*-
4 1.18.4.2 thorpej * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
5 1.18.4.2 thorpej * All rights reserved.
6 1.18.4.2 thorpej *
7 1.18.4.2 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.18.4.2 thorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.18.4.2 thorpej * NASA Ames Research Center.
10 1.18.4.2 thorpej *
11 1.18.4.2 thorpej * Redistribution and use in source and binary forms, with or without
12 1.18.4.2 thorpej * modification, are permitted provided that the following conditions
13 1.18.4.2 thorpej * are met:
14 1.18.4.2 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.18.4.2 thorpej * notice, this list of conditions and the following disclaimer.
16 1.18.4.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.18.4.2 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.18.4.2 thorpej * documentation and/or other materials provided with the distribution.
19 1.18.4.2 thorpej * 3. All advertising materials mentioning features or use of this software
20 1.18.4.2 thorpej * must display the following acknowledgement:
21 1.18.4.2 thorpej * This product includes software developed by the NetBSD
22 1.18.4.2 thorpej * Foundation, Inc. and its contributors.
23 1.18.4.2 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.18.4.2 thorpej * contributors may be used to endorse or promote products derived
25 1.18.4.2 thorpej * from this software without specific prior written permission.
26 1.18.4.2 thorpej *
27 1.18.4.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.18.4.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.18.4.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.18.4.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.18.4.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.18.4.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.18.4.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.18.4.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.18.4.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.18.4.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.18.4.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
38 1.18.4.2 thorpej */
39 1.18.4.2 thorpej
40 1.18.4.2 thorpej /*
41 1.18.4.2 thorpej * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
42 1.18.4.2 thorpej * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
43 1.18.4.2 thorpej *
44 1.18.4.2 thorpej * Redistribution and use in source and binary forms, with or without
45 1.18.4.2 thorpej * modification, are permitted provided that the following conditions
46 1.18.4.2 thorpej * are met:
47 1.18.4.2 thorpej * 1. Redistributions of source code must retain the above copyright
48 1.18.4.2 thorpej * notice, this list of conditions and the following disclaimer.
49 1.18.4.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
50 1.18.4.2 thorpej * notice, this list of conditions and the following disclaimer in the
51 1.18.4.2 thorpej * documentation and/or other materials provided with the distribution.
52 1.18.4.2 thorpej * 3. All advertising materials mentioning features or use of this software
53 1.18.4.2 thorpej * must display the following acknowledgement:
54 1.18.4.2 thorpej * This product includes software developed by Christopher G. Demetriou
55 1.18.4.2 thorpej * for the NetBSD Project.
56 1.18.4.2 thorpej * 4. The name of the author may not be used to endorse or promote products
57 1.18.4.2 thorpej * derived from this software without specific prior written permission
58 1.18.4.2 thorpej *
59 1.18.4.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
60 1.18.4.2 thorpej * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
61 1.18.4.2 thorpej * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
62 1.18.4.2 thorpej * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
63 1.18.4.2 thorpej * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64 1.18.4.2 thorpej * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
65 1.18.4.2 thorpej * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
66 1.18.4.2 thorpej * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67 1.18.4.2 thorpej * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
68 1.18.4.2 thorpej * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
69 1.18.4.2 thorpej */
70 1.18.4.2 thorpej
71 1.18.4.2 thorpej #ifndef _VAX_BUS_H_
72 1.18.4.2 thorpej #define _VAX_BUS_H_
73 1.18.4.2 thorpej
74 1.18.4.2 thorpej #ifdef BUS_SPACE_DEBUG
75 1.18.4.2 thorpej #include <sys/systm.h> /* for printf() prototype */
76 1.18.4.2 thorpej /*
77 1.18.4.2 thorpej * Macros for sanity-checking the aligned-ness of pointers passed to
78 1.18.4.2 thorpej * bus space ops. These are not strictly necessary on the VAX, but
79 1.18.4.2 thorpej * could lead to performance improvements, and help catch problems
80 1.18.4.2 thorpej * with drivers that would creep up on other architectures.
81 1.18.4.2 thorpej */
82 1.18.4.2 thorpej #define __BUS_SPACE_ALIGNED_ADDRESS(p, t) \
83 1.18.4.2 thorpej ((((u_long)(p)) & (sizeof(t)-1)) == 0)
84 1.18.4.2 thorpej
85 1.18.4.2 thorpej #define __BUS_SPACE_ADDRESS_SANITY(p, t, d) \
86 1.18.4.2 thorpej ({ \
87 1.18.4.2 thorpej if (__BUS_SPACE_ALIGNED_ADDRESS((p), t) == 0) { \
88 1.18.4.2 thorpej printf("%s 0x%lx not aligned to %d bytes %s:%d\n", \
89 1.18.4.2 thorpej d, (u_long)(p), sizeof(t), __FILE__, __LINE__); \
90 1.18.4.2 thorpej } \
91 1.18.4.2 thorpej (void) 0; \
92 1.18.4.2 thorpej })
93 1.18.4.2 thorpej
94 1.18.4.2 thorpej #define BUS_SPACE_ALIGNED_POINTER(p, t) __BUS_SPACE_ALIGNED_ADDRESS(p, t)
95 1.18.4.2 thorpej #else
96 1.18.4.2 thorpej #define __BUS_SPACE_ADDRESS_SANITY(p,t,d) (void) 0
97 1.18.4.2 thorpej #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
98 1.18.4.2 thorpej #endif /* BUS_SPACE_DEBUG */
99 1.18.4.2 thorpej
100 1.18.4.2 thorpej /*
101 1.18.4.2 thorpej * Bus address and size types
102 1.18.4.2 thorpej */
103 1.18.4.2 thorpej typedef u_long bus_addr_t;
104 1.18.4.2 thorpej typedef u_long bus_size_t;
105 1.18.4.2 thorpej
106 1.18.4.2 thorpej /*
107 1.18.4.2 thorpej * Access methods for bus resources and address space.
108 1.18.4.2 thorpej */
109 1.18.4.2 thorpej typedef struct vax_bus_space *bus_space_tag_t;
110 1.18.4.2 thorpej typedef u_long bus_space_handle_t;
111 1.18.4.2 thorpej
112 1.18.4.2 thorpej struct vax_bus_space {
113 1.18.4.2 thorpej /* cookie */
114 1.18.4.2 thorpej void *vbs_cookie;
115 1.18.4.2 thorpej
116 1.18.4.2 thorpej /* mapping/unmapping */
117 1.18.4.2 thorpej int (*vbs_map) __P((void *, bus_addr_t, bus_size_t,
118 1.18.4.2 thorpej int, bus_space_handle_t *, int));
119 1.18.4.2 thorpej void (*vbs_unmap) __P((void *, bus_space_handle_t,
120 1.18.4.2 thorpej bus_size_t, int));
121 1.18.4.2 thorpej int (*vbs_subregion) __P((void *, bus_space_handle_t,
122 1.18.4.2 thorpej bus_size_t, bus_size_t, bus_space_handle_t *));
123 1.18.4.2 thorpej
124 1.18.4.2 thorpej /* allocation/deallocation */
125 1.18.4.2 thorpej int (*vbs_alloc) __P((void *, bus_addr_t, bus_addr_t,
126 1.18.4.2 thorpej bus_size_t, bus_size_t, bus_size_t, int,
127 1.18.4.2 thorpej bus_addr_t *, bus_space_handle_t *));
128 1.18.4.2 thorpej void (*vbs_free) __P((void *, bus_space_handle_t,
129 1.18.4.2 thorpej bus_size_t));
130 1.18.4.2 thorpej /* mmap bus space for user */
131 1.18.4.2 thorpej paddr_t (*vbs_mmap)(void *, bus_addr_t, off_t, int, int);
132 1.18.4.2 thorpej };
133 1.18.4.2 thorpej
134 1.18.4.2 thorpej /*
135 1.18.4.2 thorpej * int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr,
136 1.18.4.2 thorpej * bus_size_t size, int flags, bus_space_handle_t *bshp));
137 1.18.4.2 thorpej *
138 1.18.4.2 thorpej * Map a region of bus space.
139 1.18.4.2 thorpej */
140 1.18.4.2 thorpej
141 1.18.4.2 thorpej #define BUS_SPACE_MAP_CACHEABLE 0x01
142 1.18.4.2 thorpej #define BUS_SPACE_MAP_LINEAR 0x02
143 1.18.4.2 thorpej #define BUS_SPACE_MAP_PREFETCHABLE 0x04
144 1.18.4.2 thorpej
145 1.18.4.2 thorpej #define bus_space_map(t, a, s, f, hp) \
146 1.18.4.2 thorpej (*(t)->vbs_map)((t)->vbs_cookie, (a), (s), (f), (hp), 1)
147 1.18.4.2 thorpej #define vax_bus_space_map_noacct(t, a, s, f, hp) \
148 1.18.4.2 thorpej (*(t)->vbs_map)((t)->vbs_cookie, (a), (s), (f), (hp), 0)
149 1.18.4.2 thorpej
150 1.18.4.2 thorpej /*
151 1.18.4.2 thorpej * int bus_space_unmap __P((bus_space_tag_t t,
152 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t size));
153 1.18.4.2 thorpej *
154 1.18.4.2 thorpej * Unmap a region of bus space.
155 1.18.4.2 thorpej */
156 1.18.4.2 thorpej
157 1.18.4.2 thorpej #define bus_space_unmap(t, h, s) \
158 1.18.4.2 thorpej (*(t)->vbs_unmap)((t)->vbs_cookie, (h), (s), 1)
159 1.18.4.2 thorpej #define vax_bus_space_unmap_noacct(t, h, s) \
160 1.18.4.2 thorpej (*(t)->vbs_unmap)((t)->vbs_cookie, (h), (s), 0)
161 1.18.4.2 thorpej
162 1.18.4.2 thorpej /*
163 1.18.4.2 thorpej * int bus_space_subregion __P((bus_space_tag_t t,
164 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
165 1.18.4.2 thorpej * bus_space_handle_t *nbshp));
166 1.18.4.2 thorpej *
167 1.18.4.2 thorpej * Get a new handle for a subregion of an already-mapped area of bus space.
168 1.18.4.2 thorpej */
169 1.18.4.2 thorpej
170 1.18.4.2 thorpej #define bus_space_subregion(t, h, o, s, nhp) \
171 1.18.4.2 thorpej (*(t)->vbs_subregion)((t)->vbs_cookie, (h), (o), (s), (nhp))
172 1.18.4.2 thorpej
173 1.18.4.2 thorpej /*
174 1.18.4.2 thorpej * int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
175 1.18.4.2 thorpej * bus_addr_t rend, bus_size_t size, bus_size_t align,
176 1.18.4.2 thorpej * bus_size_t boundary, int flags, bus_addr_t *addrp,
177 1.18.4.2 thorpej * bus_space_handle_t *bshp));
178 1.18.4.2 thorpej *
179 1.18.4.2 thorpej * Allocate a region of bus space.
180 1.18.4.2 thorpej */
181 1.18.4.2 thorpej
182 1.18.4.2 thorpej #define bus_space_alloc(t, rs, re, s, a, b, f, ap, hp) \
183 1.18.4.2 thorpej (*(t)->vbs_alloc)((t)->vbs_cookie, (rs), (re), (s), (a), (b), \
184 1.18.4.2 thorpej (f), (ap), (hp))
185 1.18.4.2 thorpej
186 1.18.4.2 thorpej /*
187 1.18.4.2 thorpej * int bus_space_free __P((bus_space_tag_t t,
188 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t size));
189 1.18.4.2 thorpej *
190 1.18.4.2 thorpej * Free a region of bus space.
191 1.18.4.2 thorpej */
192 1.18.4.2 thorpej
193 1.18.4.2 thorpej #define bus_space_free(t, h, s) \
194 1.18.4.2 thorpej (*(t)->vbs_free)((t)->vbs_cookie, (h), (s))
195 1.18.4.2 thorpej
196 1.18.4.2 thorpej /*
197 1.18.4.2 thorpej * Mmap bus space for a user application.
198 1.18.4.2 thorpej */
199 1.18.4.2 thorpej #define bus_space_mmap(t, a, o, p, f) \
200 1.18.4.2 thorpej (*(t)->vbs_mmap)((t)->vbs_cookie, (a), (o), (p), (f))
201 1.18.4.2 thorpej
202 1.18.4.2 thorpej
203 1.18.4.2 thorpej /*
204 1.18.4.2 thorpej * u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
205 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset));
206 1.18.4.2 thorpej *
207 1.18.4.2 thorpej * Read a 1, 2, 4, or 8 byte quantity from bus space
208 1.18.4.2 thorpej * described by tag/handle/offset.
209 1.18.4.2 thorpej */
210 1.18.4.2 thorpej
211 1.18.4.2 thorpej #define bus_space_read_1(t, h, o) \
212 1.18.4.2 thorpej (*(volatile u_int8_t *)((h) + (o)))
213 1.18.4.2 thorpej
214 1.18.4.2 thorpej #define bus_space_read_2(t, h, o) \
215 1.18.4.2 thorpej (__BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"), \
216 1.18.4.2 thorpej (*(volatile u_int16_t *)((h) + (o))))
217 1.18.4.2 thorpej
218 1.18.4.2 thorpej #define bus_space_read_4(t, h, o) \
219 1.18.4.2 thorpej (__BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"), \
220 1.18.4.2 thorpej (*(volatile u_int32_t *)((h) + (o))))
221 1.18.4.2 thorpej
222 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_read_8 */
223 1.18.4.2 thorpej #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
224 1.18.4.2 thorpej #endif
225 1.18.4.2 thorpej
226 1.18.4.2 thorpej /*
227 1.18.4.2 thorpej * void bus_space_read_multi_N __P((bus_space_tag_t tag,
228 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset,
229 1.18.4.2 thorpej * u_intN_t *addr, size_t count));
230 1.18.4.2 thorpej *
231 1.18.4.2 thorpej * Read `count' 1, 2, 4, or 8 byte quantities from bus space
232 1.18.4.2 thorpej * described by tag/handle/offset and copy into buffer provided.
233 1.18.4.2 thorpej */
234 1.18.4.2 thorpej static __inline void vax_mem_read_multi_1 __P((bus_space_tag_t,
235 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int8_t *, size_t));
236 1.18.4.2 thorpej static __inline void vax_mem_read_multi_2 __P((bus_space_tag_t,
237 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int16_t *, size_t));
238 1.18.4.2 thorpej static __inline void vax_mem_read_multi_4 __P((bus_space_tag_t,
239 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int32_t *, size_t));
240 1.18.4.2 thorpej
241 1.18.4.2 thorpej #define bus_space_read_multi_1(t, h, o, a, c) \
242 1.18.4.2 thorpej vax_mem_read_multi_1((t), (h), (o), (a), (c))
243 1.18.4.2 thorpej
244 1.18.4.2 thorpej #define bus_space_read_multi_2(t, h, o, a, c) \
245 1.18.4.2 thorpej do { \
246 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int16_t, "buffer"); \
247 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"); \
248 1.18.4.2 thorpej vax_mem_read_multi_2((t), (h), (o), (a), (c)); \
249 1.18.4.2 thorpej } while (0)
250 1.18.4.2 thorpej
251 1.18.4.2 thorpej #define bus_space_read_multi_4(t, h, o, a, c) \
252 1.18.4.2 thorpej do { \
253 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int32_t, "buffer"); \
254 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"); \
255 1.18.4.2 thorpej vax_mem_read_multi_4((t), (h), (o), (a), (c)); \
256 1.18.4.2 thorpej } while (0)
257 1.18.4.2 thorpej
258 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_read_multi_8 */
259 1.18.4.2 thorpej #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
260 1.18.4.2 thorpej #endif
261 1.18.4.2 thorpej
262 1.18.4.2 thorpej static __inline void
263 1.18.4.2 thorpej vax_mem_read_multi_1(t, h, o, a, c)
264 1.18.4.2 thorpej bus_space_tag_t t;
265 1.18.4.2 thorpej bus_space_handle_t h;
266 1.18.4.2 thorpej bus_size_t o;
267 1.18.4.2 thorpej u_int8_t *a;
268 1.18.4.2 thorpej size_t c;
269 1.18.4.2 thorpej {
270 1.18.4.2 thorpej const bus_addr_t addr = h + o;
271 1.18.4.2 thorpej
272 1.18.4.2 thorpej for (; c != 0; c--, a++)
273 1.18.4.2 thorpej *a = *(volatile u_int8_t *)(addr);
274 1.18.4.2 thorpej }
275 1.18.4.2 thorpej
276 1.18.4.2 thorpej static __inline void
277 1.18.4.2 thorpej vax_mem_read_multi_2(t, h, o, a, c)
278 1.18.4.2 thorpej bus_space_tag_t t;
279 1.18.4.2 thorpej bus_space_handle_t h;
280 1.18.4.2 thorpej bus_size_t o;
281 1.18.4.2 thorpej u_int16_t *a;
282 1.18.4.2 thorpej size_t c;
283 1.18.4.2 thorpej {
284 1.18.4.2 thorpej const bus_addr_t addr = h + o;
285 1.18.4.2 thorpej
286 1.18.4.2 thorpej for (; c != 0; c--, a++)
287 1.18.4.2 thorpej *a = *(volatile u_int16_t *)(addr);
288 1.18.4.2 thorpej }
289 1.18.4.2 thorpej
290 1.18.4.2 thorpej static __inline void
291 1.18.4.2 thorpej vax_mem_read_multi_4(t, h, o, a, c)
292 1.18.4.2 thorpej bus_space_tag_t t;
293 1.18.4.2 thorpej bus_space_handle_t h;
294 1.18.4.2 thorpej bus_size_t o;
295 1.18.4.2 thorpej u_int32_t *a;
296 1.18.4.2 thorpej size_t c;
297 1.18.4.2 thorpej {
298 1.18.4.2 thorpej const bus_addr_t addr = h + o;
299 1.18.4.2 thorpej
300 1.18.4.2 thorpej for (; c != 0; c--, a++)
301 1.18.4.2 thorpej *a = *(volatile u_int32_t *)(addr);
302 1.18.4.2 thorpej }
303 1.18.4.2 thorpej
304 1.18.4.2 thorpej /*
305 1.18.4.2 thorpej * void bus_space_read_region_N __P((bus_space_tag_t tag,
306 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset,
307 1.18.4.2 thorpej * u_intN_t *addr, size_t count));
308 1.18.4.2 thorpej *
309 1.18.4.2 thorpej * Read `count' 1, 2, 4, or 8 byte quantities from bus space
310 1.18.4.2 thorpej * described by tag/handle and starting at `offset' and copy into
311 1.18.4.2 thorpej * buffer provided.
312 1.18.4.2 thorpej */
313 1.18.4.2 thorpej
314 1.18.4.2 thorpej static __inline void vax_mem_read_region_1 __P((bus_space_tag_t,
315 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int8_t *, size_t));
316 1.18.4.2 thorpej static __inline void vax_mem_read_region_2 __P((bus_space_tag_t,
317 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int16_t *, size_t));
318 1.18.4.2 thorpej static __inline void vax_mem_read_region_4 __P((bus_space_tag_t,
319 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int32_t *, size_t));
320 1.18.4.2 thorpej
321 1.18.4.2 thorpej #define bus_space_read_region_1(t, h, o, a, c) \
322 1.18.4.2 thorpej do { \
323 1.18.4.2 thorpej vax_mem_read_region_1((t), (h), (o), (a), (c)); \
324 1.18.4.2 thorpej } while (0)
325 1.18.4.2 thorpej
326 1.18.4.2 thorpej #define bus_space_read_region_2(t, h, o, a, c) \
327 1.18.4.2 thorpej do { \
328 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int16_t, "buffer"); \
329 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"); \
330 1.18.4.2 thorpej vax_mem_read_region_2((t), (h), (o), (a), (c)); \
331 1.18.4.2 thorpej } while (0)
332 1.18.4.2 thorpej
333 1.18.4.2 thorpej #define bus_space_read_region_4(t, h, o, a, c) \
334 1.18.4.2 thorpej do { \
335 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int32_t, "buffer"); \
336 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"); \
337 1.18.4.2 thorpej vax_mem_read_region_4((t), (h), (o), (a), (c)); \
338 1.18.4.2 thorpej } while (0)
339 1.18.4.2 thorpej
340 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_read_region_8 */
341 1.18.4.2 thorpej #define bus_space_read_region_8 \
342 1.18.4.2 thorpej !!! bus_space_read_region_8 unimplemented !!!
343 1.18.4.2 thorpej #endif
344 1.18.4.2 thorpej
345 1.18.4.2 thorpej static __inline void
346 1.18.4.2 thorpej vax_mem_read_region_1(t, h, o, a, c)
347 1.18.4.2 thorpej bus_space_tag_t t;
348 1.18.4.2 thorpej bus_space_handle_t h;
349 1.18.4.2 thorpej bus_size_t o;
350 1.18.4.2 thorpej u_int8_t *a;
351 1.18.4.2 thorpej size_t c;
352 1.18.4.2 thorpej {
353 1.18.4.2 thorpej bus_addr_t addr = h + o;
354 1.18.4.2 thorpej
355 1.18.4.2 thorpej for (; c != 0; c--, addr++, a++)
356 1.18.4.2 thorpej *a = *(volatile u_int8_t *)(addr);
357 1.18.4.2 thorpej }
358 1.18.4.2 thorpej
359 1.18.4.2 thorpej static __inline void
360 1.18.4.2 thorpej vax_mem_read_region_2(t, h, o, a, c)
361 1.18.4.2 thorpej bus_space_tag_t t;
362 1.18.4.2 thorpej bus_space_handle_t h;
363 1.18.4.2 thorpej bus_size_t o;
364 1.18.4.2 thorpej u_int16_t *a;
365 1.18.4.2 thorpej size_t c;
366 1.18.4.2 thorpej {
367 1.18.4.2 thorpej bus_addr_t addr = h + o;
368 1.18.4.2 thorpej
369 1.18.4.2 thorpej for (; c != 0; c--, addr += 2, a++)
370 1.18.4.2 thorpej *a = *(volatile u_int16_t *)(addr);
371 1.18.4.2 thorpej }
372 1.18.4.2 thorpej
373 1.18.4.2 thorpej static __inline void
374 1.18.4.2 thorpej vax_mem_read_region_4(t, h, o, a, c)
375 1.18.4.2 thorpej bus_space_tag_t t;
376 1.18.4.2 thorpej bus_space_handle_t h;
377 1.18.4.2 thorpej bus_size_t o;
378 1.18.4.2 thorpej u_int32_t *a;
379 1.18.4.2 thorpej size_t c;
380 1.18.4.2 thorpej {
381 1.18.4.2 thorpej bus_addr_t addr = h + o;
382 1.18.4.2 thorpej
383 1.18.4.2 thorpej for (; c != 0; c--, addr += 4, a++)
384 1.18.4.2 thorpej *a = *(volatile u_int32_t *)(addr);
385 1.18.4.2 thorpej }
386 1.18.4.2 thorpej
387 1.18.4.2 thorpej /*
388 1.18.4.2 thorpej * void bus_space_write_N __P((bus_space_tag_t tag,
389 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset,
390 1.18.4.2 thorpej * u_intN_t value));
391 1.18.4.2 thorpej *
392 1.18.4.2 thorpej * Write the 1, 2, 4, or 8 byte value `value' to bus space
393 1.18.4.2 thorpej * described by tag/handle/offset.
394 1.18.4.2 thorpej */
395 1.18.4.2 thorpej
396 1.18.4.2 thorpej #define bus_space_write_1(t, h, o, v) \
397 1.18.4.2 thorpej do { \
398 1.18.4.2 thorpej ((void)(*(volatile u_int8_t *)((h) + (o)) = (v))); \
399 1.18.4.2 thorpej } while (0)
400 1.18.4.2 thorpej
401 1.18.4.2 thorpej #define bus_space_write_2(t, h, o, v) \
402 1.18.4.2 thorpej do { \
403 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"); \
404 1.18.4.2 thorpej ((void)(*(volatile u_int16_t *)((h) + (o)) = (v))); \
405 1.18.4.2 thorpej } while (0)
406 1.18.4.2 thorpej
407 1.18.4.2 thorpej #define bus_space_write_4(t, h, o, v) \
408 1.18.4.2 thorpej do { \
409 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"); \
410 1.18.4.2 thorpej ((void)(*(volatile u_int32_t *)((h) + (o)) = (v))); \
411 1.18.4.2 thorpej } while (0)
412 1.18.4.2 thorpej
413 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_write_8 */
414 1.18.4.2 thorpej #define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
415 1.18.4.2 thorpej #endif
416 1.18.4.2 thorpej
417 1.18.4.2 thorpej /*
418 1.18.4.2 thorpej * void bus_space_write_multi_N __P((bus_space_tag_t tag,
419 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset,
420 1.18.4.2 thorpej * const u_intN_t *addr, size_t count));
421 1.18.4.2 thorpej *
422 1.18.4.2 thorpej * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
423 1.18.4.2 thorpej * provided to bus space described by tag/handle/offset.
424 1.18.4.2 thorpej */
425 1.18.4.2 thorpej static __inline void vax_mem_write_multi_1 __P((bus_space_tag_t,
426 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, const u_int8_t *, size_t));
427 1.18.4.2 thorpej static __inline void vax_mem_write_multi_2 __P((bus_space_tag_t,
428 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, const u_int16_t *, size_t));
429 1.18.4.2 thorpej static __inline void vax_mem_write_multi_4 __P((bus_space_tag_t,
430 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, const u_int32_t *, size_t));
431 1.18.4.2 thorpej
432 1.18.4.2 thorpej #define bus_space_write_multi_1(t, h, o, a, c) \
433 1.18.4.2 thorpej do { \
434 1.18.4.2 thorpej vax_mem_write_multi_1((t), (h), (o), (a), (c)); \
435 1.18.4.2 thorpej } while (0)
436 1.18.4.2 thorpej
437 1.18.4.2 thorpej #define bus_space_write_multi_2(t, h, o, a, c) \
438 1.18.4.2 thorpej do { \
439 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int16_t, "buffer"); \
440 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"); \
441 1.18.4.2 thorpej vax_mem_write_multi_2((t), (h), (o), (a), (c)); \
442 1.18.4.2 thorpej } while (0)
443 1.18.4.2 thorpej
444 1.18.4.2 thorpej #define bus_space_write_multi_4(t, h, o, a, c) \
445 1.18.4.2 thorpej do { \
446 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int32_t, "buffer"); \
447 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"); \
448 1.18.4.2 thorpej vax_mem_write_multi_4((t), (h), (o), (a), (c)); \
449 1.18.4.2 thorpej } while (0)
450 1.18.4.2 thorpej
451 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_write_multi_8 */
452 1.18.4.2 thorpej #define bus_space_write_multi_8(t, h, o, a, c) \
453 1.18.4.2 thorpej !!! bus_space_write_multi_8 unimplemented !!!
454 1.18.4.2 thorpej #endif
455 1.18.4.2 thorpej
456 1.18.4.2 thorpej static __inline void
457 1.18.4.2 thorpej vax_mem_write_multi_1(t, h, o, a, c)
458 1.18.4.2 thorpej bus_space_tag_t t;
459 1.18.4.2 thorpej bus_space_handle_t h;
460 1.18.4.2 thorpej bus_size_t o;
461 1.18.4.2 thorpej const u_int8_t *a;
462 1.18.4.2 thorpej size_t c;
463 1.18.4.2 thorpej {
464 1.18.4.2 thorpej const bus_addr_t addr = h + o;
465 1.18.4.2 thorpej
466 1.18.4.2 thorpej for (; c != 0; c--, a++)
467 1.18.4.2 thorpej *(volatile u_int8_t *)(addr) = *a;
468 1.18.4.2 thorpej }
469 1.18.4.2 thorpej
470 1.18.4.2 thorpej static __inline void
471 1.18.4.2 thorpej vax_mem_write_multi_2(t, h, o, a, c)
472 1.18.4.2 thorpej bus_space_tag_t t;
473 1.18.4.2 thorpej bus_space_handle_t h;
474 1.18.4.2 thorpej bus_size_t o;
475 1.18.4.2 thorpej const u_int16_t *a;
476 1.18.4.2 thorpej size_t c;
477 1.18.4.2 thorpej {
478 1.18.4.2 thorpej const bus_addr_t addr = h + o;
479 1.18.4.2 thorpej
480 1.18.4.2 thorpej for (; c != 0; c--, a++)
481 1.18.4.2 thorpej *(volatile u_int16_t *)(addr) = *a;
482 1.18.4.2 thorpej }
483 1.18.4.2 thorpej
484 1.18.4.2 thorpej static __inline void
485 1.18.4.2 thorpej vax_mem_write_multi_4(t, h, o, a, c)
486 1.18.4.2 thorpej bus_space_tag_t t;
487 1.18.4.2 thorpej bus_space_handle_t h;
488 1.18.4.2 thorpej bus_size_t o;
489 1.18.4.2 thorpej const u_int32_t *a;
490 1.18.4.2 thorpej size_t c;
491 1.18.4.2 thorpej {
492 1.18.4.2 thorpej const bus_addr_t addr = h + o;
493 1.18.4.2 thorpej
494 1.18.4.2 thorpej for (; c != 0; c--, a++)
495 1.18.4.2 thorpej *(volatile u_int32_t *)(addr) = *a;
496 1.18.4.2 thorpej }
497 1.18.4.2 thorpej
498 1.18.4.2 thorpej /*
499 1.18.4.2 thorpej * void bus_space_write_region_N __P((bus_space_tag_t tag,
500 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset,
501 1.18.4.2 thorpej * const u_intN_t *addr, size_t count));
502 1.18.4.2 thorpej *
503 1.18.4.2 thorpej * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
504 1.18.4.2 thorpej * to bus space described by tag/handle starting at `offset'.
505 1.18.4.2 thorpej */
506 1.18.4.2 thorpej static __inline void vax_mem_write_region_1 __P((bus_space_tag_t,
507 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, const u_int8_t *, size_t));
508 1.18.4.2 thorpej static __inline void vax_mem_write_region_2 __P((bus_space_tag_t,
509 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, const u_int16_t *, size_t));
510 1.18.4.2 thorpej static __inline void vax_mem_write_region_4 __P((bus_space_tag_t,
511 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, const u_int32_t *, size_t));
512 1.18.4.2 thorpej
513 1.18.4.2 thorpej #define bus_space_write_region_1(t, h, o, a, c) \
514 1.18.4.2 thorpej vax_mem_write_region_1((t), (h), (o), (a), (c))
515 1.18.4.2 thorpej
516 1.18.4.2 thorpej #define bus_space_write_region_2(t, h, o, a, c) \
517 1.18.4.2 thorpej do { \
518 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int16_t, "buffer"); \
519 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"); \
520 1.18.4.2 thorpej vax_mem_write_region_2((t), (h), (o), (a), (c)); \
521 1.18.4.2 thorpej } while (0)
522 1.18.4.2 thorpej
523 1.18.4.2 thorpej #define bus_space_write_region_4(t, h, o, a, c) \
524 1.18.4.2 thorpej do { \
525 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((a), u_int32_t, "buffer"); \
526 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"); \
527 1.18.4.2 thorpej vax_mem_write_region_4((t), (h), (o), (a), (c)); \
528 1.18.4.2 thorpej } while (0)
529 1.18.4.2 thorpej
530 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_write_region_8 */
531 1.18.4.2 thorpej #define bus_space_write_region_8 \
532 1.18.4.2 thorpej !!! bus_space_write_region_8 unimplemented !!!
533 1.18.4.2 thorpej #endif
534 1.18.4.2 thorpej
535 1.18.4.2 thorpej static __inline void
536 1.18.4.2 thorpej vax_mem_write_region_1(t, h, o, a, c)
537 1.18.4.2 thorpej bus_space_tag_t t;
538 1.18.4.2 thorpej bus_space_handle_t h;
539 1.18.4.2 thorpej bus_size_t o;
540 1.18.4.2 thorpej const u_int8_t *a;
541 1.18.4.2 thorpej size_t c;
542 1.18.4.2 thorpej {
543 1.18.4.2 thorpej bus_addr_t addr = h + o;
544 1.18.4.2 thorpej
545 1.18.4.2 thorpej for (; c != 0; c--, addr++, a++)
546 1.18.4.2 thorpej *(volatile u_int8_t *)(addr) = *a;
547 1.18.4.2 thorpej }
548 1.18.4.2 thorpej
549 1.18.4.2 thorpej static __inline void
550 1.18.4.2 thorpej vax_mem_write_region_2(t, h, o, a, c)
551 1.18.4.2 thorpej bus_space_tag_t t;
552 1.18.4.2 thorpej bus_space_handle_t h;
553 1.18.4.2 thorpej bus_size_t o;
554 1.18.4.2 thorpej const u_int16_t *a;
555 1.18.4.2 thorpej size_t c;
556 1.18.4.2 thorpej {
557 1.18.4.2 thorpej bus_addr_t addr = h + o;
558 1.18.4.2 thorpej
559 1.18.4.2 thorpej for (; c != 0; c--, addr++, a++)
560 1.18.4.2 thorpej *(volatile u_int16_t *)(addr) = *a;
561 1.18.4.2 thorpej }
562 1.18.4.2 thorpej
563 1.18.4.2 thorpej static __inline void
564 1.18.4.2 thorpej vax_mem_write_region_4(t, h, o, a, c)
565 1.18.4.2 thorpej bus_space_tag_t t;
566 1.18.4.2 thorpej bus_space_handle_t h;
567 1.18.4.2 thorpej bus_size_t o;
568 1.18.4.2 thorpej const u_int32_t *a;
569 1.18.4.2 thorpej size_t c;
570 1.18.4.2 thorpej {
571 1.18.4.2 thorpej bus_addr_t addr = h + o;
572 1.18.4.2 thorpej
573 1.18.4.2 thorpej for (; c != 0; c--, addr++, a++)
574 1.18.4.2 thorpej *(volatile u_int32_t *)(addr) = *a;
575 1.18.4.2 thorpej }
576 1.18.4.2 thorpej
577 1.18.4.2 thorpej /*
578 1.18.4.2 thorpej * void bus_space_set_multi_N __P((bus_space_tag_t tag,
579 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
580 1.18.4.2 thorpej * size_t count));
581 1.18.4.2 thorpej *
582 1.18.4.2 thorpej * Write the 1, 2, 4, or 8 byte value `val' to bus space described
583 1.18.4.2 thorpej * by tag/handle/offset `count' times.
584 1.18.4.2 thorpej */
585 1.18.4.2 thorpej
586 1.18.4.2 thorpej static __inline void vax_mem_set_multi_1 __P((bus_space_tag_t,
587 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int8_t, size_t));
588 1.18.4.2 thorpej static __inline void vax_mem_set_multi_2 __P((bus_space_tag_t,
589 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int16_t, size_t));
590 1.18.4.2 thorpej static __inline void vax_mem_set_multi_4 __P((bus_space_tag_t,
591 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int32_t, size_t));
592 1.18.4.2 thorpej
593 1.18.4.2 thorpej #define bus_space_set_multi_1(t, h, o, v, c) \
594 1.18.4.2 thorpej vax_mem_set_multi_1((t), (h), (o), (v), (c))
595 1.18.4.2 thorpej
596 1.18.4.2 thorpej #define bus_space_set_multi_2(t, h, o, v, c) \
597 1.18.4.2 thorpej do { \
598 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"); \
599 1.18.4.2 thorpej vax_mem_set_multi_2((t), (h), (o), (v), (c)); \
600 1.18.4.2 thorpej } while (0)
601 1.18.4.2 thorpej
602 1.18.4.2 thorpej #define bus_space_set_multi_4(t, h, o, v, c) \
603 1.18.4.2 thorpej do { \
604 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"); \
605 1.18.4.2 thorpej vax_mem_set_multi_4((t), (h), (o), (v), (c)); \
606 1.18.4.2 thorpej } while (0)
607 1.18.4.2 thorpej
608 1.18.4.2 thorpej static __inline void
609 1.18.4.2 thorpej vax_mem_set_multi_1(t, h, o, v, c)
610 1.18.4.2 thorpej bus_space_tag_t t;
611 1.18.4.2 thorpej bus_space_handle_t h;
612 1.18.4.2 thorpej bus_size_t o;
613 1.18.4.2 thorpej u_int8_t v;
614 1.18.4.2 thorpej size_t c;
615 1.18.4.2 thorpej {
616 1.18.4.2 thorpej bus_addr_t addr = h + o;
617 1.18.4.2 thorpej
618 1.18.4.2 thorpej while (c--)
619 1.18.4.2 thorpej *(volatile u_int8_t *)(addr) = v;
620 1.18.4.2 thorpej }
621 1.18.4.2 thorpej
622 1.18.4.2 thorpej static __inline void
623 1.18.4.2 thorpej vax_mem_set_multi_2(t, h, o, v, c)
624 1.18.4.2 thorpej bus_space_tag_t t;
625 1.18.4.2 thorpej bus_space_handle_t h;
626 1.18.4.2 thorpej bus_size_t o;
627 1.18.4.2 thorpej u_int16_t v;
628 1.18.4.2 thorpej size_t c;
629 1.18.4.2 thorpej {
630 1.18.4.2 thorpej bus_addr_t addr = h + o;
631 1.18.4.2 thorpej
632 1.18.4.2 thorpej while (c--)
633 1.18.4.2 thorpej *(volatile u_int16_t *)(addr) = v;
634 1.18.4.2 thorpej }
635 1.18.4.2 thorpej
636 1.18.4.2 thorpej static __inline void
637 1.18.4.2 thorpej vax_mem_set_multi_4(t, h, o, v, c)
638 1.18.4.2 thorpej bus_space_tag_t t;
639 1.18.4.2 thorpej bus_space_handle_t h;
640 1.18.4.2 thorpej bus_size_t o;
641 1.18.4.2 thorpej u_int32_t v;
642 1.18.4.2 thorpej size_t c;
643 1.18.4.2 thorpej {
644 1.18.4.2 thorpej bus_addr_t addr = h + o;
645 1.18.4.2 thorpej
646 1.18.4.2 thorpej while (c--)
647 1.18.4.2 thorpej *(volatile u_int32_t *)(addr) = v;
648 1.18.4.2 thorpej }
649 1.18.4.2 thorpej
650 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_set_multi_8 */
651 1.18.4.2 thorpej #define bus_space_set_multi_8 !!! bus_space_set_multi_8 unimplemented !!!
652 1.18.4.2 thorpej #endif
653 1.18.4.2 thorpej
654 1.18.4.2 thorpej /*
655 1.18.4.2 thorpej * void bus_space_set_region_N __P((bus_space_tag_t tag,
656 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
657 1.18.4.2 thorpej * size_t count));
658 1.18.4.2 thorpej *
659 1.18.4.2 thorpej * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
660 1.18.4.2 thorpej * by tag/handle starting at `offset'.
661 1.18.4.2 thorpej */
662 1.18.4.2 thorpej
663 1.18.4.2 thorpej static __inline void vax_mem_set_region_1 __P((bus_space_tag_t,
664 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int8_t, size_t));
665 1.18.4.2 thorpej static __inline void vax_mem_set_region_2 __P((bus_space_tag_t,
666 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int16_t, size_t));
667 1.18.4.2 thorpej static __inline void vax_mem_set_region_4 __P((bus_space_tag_t,
668 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, u_int32_t, size_t));
669 1.18.4.2 thorpej
670 1.18.4.2 thorpej #define bus_space_set_region_1(t, h, o, v, c) \
671 1.18.4.2 thorpej vax_mem_set_region_1((t), (h), (o), (v), (c))
672 1.18.4.2 thorpej
673 1.18.4.2 thorpej #define bus_space_set_region_2(t, h, o, v, c) \
674 1.18.4.2 thorpej do { \
675 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int16_t, "bus addr"); \
676 1.18.4.2 thorpej vax_mem_set_region_2((t), (h), (o), (v), (c)); \
677 1.18.4.2 thorpej } while (0)
678 1.18.4.2 thorpej
679 1.18.4.2 thorpej #define bus_space_set_region_4(t, h, o, v, c) \
680 1.18.4.2 thorpej do { \
681 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h) + (o), u_int32_t, "bus addr"); \
682 1.18.4.2 thorpej vax_mem_set_region_4((t), (h), (o), (v), (c)); \
683 1.18.4.2 thorpej } while (0)
684 1.18.4.2 thorpej
685 1.18.4.2 thorpej static __inline void
686 1.18.4.2 thorpej vax_mem_set_region_1(t, h, o, v, c)
687 1.18.4.2 thorpej bus_space_tag_t t;
688 1.18.4.2 thorpej bus_space_handle_t h;
689 1.18.4.2 thorpej bus_size_t o;
690 1.18.4.2 thorpej u_int8_t v;
691 1.18.4.2 thorpej size_t c;
692 1.18.4.2 thorpej {
693 1.18.4.2 thorpej bus_addr_t addr = h + o;
694 1.18.4.2 thorpej
695 1.18.4.2 thorpej for (; c != 0; c--, addr++)
696 1.18.4.2 thorpej *(volatile u_int8_t *)(addr) = v;
697 1.18.4.2 thorpej }
698 1.18.4.2 thorpej
699 1.18.4.2 thorpej static __inline void
700 1.18.4.2 thorpej vax_mem_set_region_2(t, h, o, v, c)
701 1.18.4.2 thorpej bus_space_tag_t t;
702 1.18.4.2 thorpej bus_space_handle_t h;
703 1.18.4.2 thorpej bus_size_t o;
704 1.18.4.2 thorpej u_int16_t v;
705 1.18.4.2 thorpej size_t c;
706 1.18.4.2 thorpej {
707 1.18.4.2 thorpej bus_addr_t addr = h + o;
708 1.18.4.2 thorpej
709 1.18.4.2 thorpej for (; c != 0; c--, addr += 2)
710 1.18.4.2 thorpej *(volatile u_int16_t *)(addr) = v;
711 1.18.4.2 thorpej }
712 1.18.4.2 thorpej
713 1.18.4.2 thorpej static __inline void
714 1.18.4.2 thorpej vax_mem_set_region_4(t, h, o, v, c)
715 1.18.4.2 thorpej bus_space_tag_t t;
716 1.18.4.2 thorpej bus_space_handle_t h;
717 1.18.4.2 thorpej bus_size_t o;
718 1.18.4.2 thorpej u_int32_t v;
719 1.18.4.2 thorpej size_t c;
720 1.18.4.2 thorpej {
721 1.18.4.2 thorpej bus_addr_t addr = h + o;
722 1.18.4.2 thorpej
723 1.18.4.2 thorpej for (; c != 0; c--, addr += 4)
724 1.18.4.2 thorpej *(volatile u_int32_t *)(addr) = v;
725 1.18.4.2 thorpej }
726 1.18.4.2 thorpej
727 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_set_region_8 */
728 1.18.4.2 thorpej #define bus_space_set_region_8 !!! bus_space_set_region_8 unimplemented !!!
729 1.18.4.2 thorpej #endif
730 1.18.4.2 thorpej
731 1.18.4.2 thorpej /*
732 1.18.4.2 thorpej * void bus_space_copy_region_N __P((bus_space_tag_t tag,
733 1.18.4.2 thorpej * bus_space_handle_t bsh1, bus_size_t off1,
734 1.18.4.2 thorpej * bus_space_handle_t bsh2, bus_size_t off2,
735 1.18.4.2 thorpej * size_t count));
736 1.18.4.2 thorpej *
737 1.18.4.2 thorpej * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
738 1.18.4.2 thorpej * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
739 1.18.4.2 thorpej */
740 1.18.4.2 thorpej
741 1.18.4.2 thorpej static __inline void vax_mem_copy_region_1 __P((bus_space_tag_t,
742 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, bus_space_handle_t,
743 1.18.4.2 thorpej bus_size_t, size_t));
744 1.18.4.2 thorpej static __inline void vax_mem_copy_region_2 __P((bus_space_tag_t,
745 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, bus_space_handle_t,
746 1.18.4.2 thorpej bus_size_t, size_t));
747 1.18.4.2 thorpej static __inline void vax_mem_copy_region_4 __P((bus_space_tag_t,
748 1.18.4.2 thorpej bus_space_handle_t, bus_size_t, bus_space_handle_t,
749 1.18.4.2 thorpej bus_size_t, size_t));
750 1.18.4.2 thorpej
751 1.18.4.2 thorpej #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
752 1.18.4.2 thorpej vax_mem_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
753 1.18.4.2 thorpej
754 1.18.4.2 thorpej #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
755 1.18.4.2 thorpej do { \
756 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h1) + (o1), u_int16_t, "bus addr 1"); \
757 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h2) + (o2), u_int16_t, "bus addr 2"); \
758 1.18.4.2 thorpej vax_mem_copy_region_2((t), (h1), (o1), (h2), (o2), (c)); \
759 1.18.4.2 thorpej } while (0)
760 1.18.4.2 thorpej
761 1.18.4.2 thorpej #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
762 1.18.4.2 thorpej do { \
763 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h1) + (o1), u_int32_t, "bus addr 1"); \
764 1.18.4.2 thorpej __BUS_SPACE_ADDRESS_SANITY((h2) + (o2), u_int32_t, "bus addr 2"); \
765 1.18.4.2 thorpej vax_mem_copy_region_4((t), (h1), (o1), (h2), (o2), (c)); \
766 1.18.4.2 thorpej } while (0)
767 1.18.4.2 thorpej
768 1.18.4.2 thorpej static __inline void
769 1.18.4.2 thorpej vax_mem_copy_region_1(t, h1, o1, h2, o2, c)
770 1.18.4.2 thorpej bus_space_tag_t t;
771 1.18.4.2 thorpej bus_space_handle_t h1;
772 1.18.4.2 thorpej bus_size_t o1;
773 1.18.4.2 thorpej bus_space_handle_t h2;
774 1.18.4.2 thorpej bus_size_t o2;
775 1.18.4.2 thorpej size_t c;
776 1.18.4.2 thorpej {
777 1.18.4.2 thorpej bus_addr_t addr1 = h1 + o1;
778 1.18.4.2 thorpej bus_addr_t addr2 = h2 + o2;
779 1.18.4.2 thorpej
780 1.18.4.2 thorpej if (addr1 >= addr2) {
781 1.18.4.2 thorpej /* src after dest: copy forward */
782 1.18.4.2 thorpej for (; c != 0; c--, addr1++, addr2++)
783 1.18.4.2 thorpej *(volatile u_int8_t *)(addr2) =
784 1.18.4.2 thorpej *(volatile u_int8_t *)(addr1);
785 1.18.4.2 thorpej } else {
786 1.18.4.2 thorpej /* dest after src: copy backwards */
787 1.18.4.2 thorpej for (addr1 += (c - 1), addr2 += (c - 1);
788 1.18.4.2 thorpej c != 0; c--, addr1--, addr2--)
789 1.18.4.2 thorpej *(volatile u_int8_t *)(addr2) =
790 1.18.4.2 thorpej *(volatile u_int8_t *)(addr1);
791 1.18.4.2 thorpej }
792 1.18.4.2 thorpej }
793 1.18.4.2 thorpej
794 1.18.4.2 thorpej static __inline void
795 1.18.4.2 thorpej vax_mem_copy_region_2(t, h1, o1, h2, o2, c)
796 1.18.4.2 thorpej bus_space_tag_t t;
797 1.18.4.2 thorpej bus_space_handle_t h1;
798 1.18.4.2 thorpej bus_size_t o1;
799 1.18.4.2 thorpej bus_space_handle_t h2;
800 1.18.4.2 thorpej bus_size_t o2;
801 1.18.4.2 thorpej size_t c;
802 1.18.4.2 thorpej {
803 1.18.4.2 thorpej bus_addr_t addr1 = h1 + o1;
804 1.18.4.2 thorpej bus_addr_t addr2 = h2 + o2;
805 1.18.4.2 thorpej
806 1.18.4.2 thorpej if (addr1 >= addr2) {
807 1.18.4.2 thorpej /* src after dest: copy forward */
808 1.18.4.2 thorpej for (; c != 0; c--, addr1 += 2, addr2 += 2)
809 1.18.4.2 thorpej *(volatile u_int16_t *)(addr2) =
810 1.18.4.2 thorpej *(volatile u_int16_t *)(addr1);
811 1.18.4.2 thorpej } else {
812 1.18.4.2 thorpej /* dest after src: copy backwards */
813 1.18.4.2 thorpej for (addr1 += 2 * (c - 1), addr2 += 2 * (c - 1);
814 1.18.4.2 thorpej c != 0; c--, addr1 -= 2, addr2 -= 2)
815 1.18.4.2 thorpej *(volatile u_int16_t *)(addr2) =
816 1.18.4.2 thorpej *(volatile u_int16_t *)(addr1);
817 1.18.4.2 thorpej }
818 1.18.4.2 thorpej }
819 1.18.4.2 thorpej
820 1.18.4.2 thorpej static __inline void
821 1.18.4.2 thorpej vax_mem_copy_region_4(t, h1, o1, h2, o2, c)
822 1.18.4.2 thorpej bus_space_tag_t t;
823 1.18.4.2 thorpej bus_space_handle_t h1;
824 1.18.4.2 thorpej bus_size_t o1;
825 1.18.4.2 thorpej bus_space_handle_t h2;
826 1.18.4.2 thorpej bus_size_t o2;
827 1.18.4.2 thorpej size_t c;
828 1.18.4.2 thorpej {
829 1.18.4.2 thorpej bus_addr_t addr1 = h1 + o1;
830 1.18.4.2 thorpej bus_addr_t addr2 = h2 + o2;
831 1.18.4.2 thorpej
832 1.18.4.2 thorpej if (addr1 >= addr2) {
833 1.18.4.2 thorpej /* src after dest: copy forward */
834 1.18.4.2 thorpej for (; c != 0; c--, addr1 += 4, addr2 += 4)
835 1.18.4.2 thorpej *(volatile u_int32_t *)(addr2) =
836 1.18.4.2 thorpej *(volatile u_int32_t *)(addr1);
837 1.18.4.2 thorpej } else {
838 1.18.4.2 thorpej /* dest after src: copy backwards */
839 1.18.4.2 thorpej for (addr1 += 4 * (c - 1), addr2 += 4 * (c - 1);
840 1.18.4.2 thorpej c != 0; c--, addr1 -= 4, addr2 -= 4)
841 1.18.4.2 thorpej *(volatile u_int32_t *)(addr2) =
842 1.18.4.2 thorpej *(volatile u_int32_t *)(addr1);
843 1.18.4.2 thorpej }
844 1.18.4.2 thorpej }
845 1.18.4.2 thorpej
846 1.18.4.2 thorpej #if 0 /* Cause a link error for bus_space_copy_8 */
847 1.18.4.2 thorpej #define bus_space_copy_region_8 !!! bus_space_copy_region_8 unimplemented !!!
848 1.18.4.2 thorpej #endif
849 1.18.4.2 thorpej
850 1.18.4.2 thorpej
851 1.18.4.2 thorpej /*
852 1.18.4.2 thorpej * Bus read/write barrier methods.
853 1.18.4.2 thorpej *
854 1.18.4.2 thorpej * void bus_space_barrier __P((bus_space_tag_t tag,
855 1.18.4.2 thorpej * bus_space_handle_t bsh, bus_size_t offset,
856 1.18.4.2 thorpej * bus_size_t len, int flags));
857 1.18.4.2 thorpej *
858 1.18.4.2 thorpej * Note: the vax does not currently require barriers, but we must
859 1.18.4.2 thorpej * provide the flags to MI code.
860 1.18.4.2 thorpej */
861 1.18.4.2 thorpej #define bus_space_barrier(t, h, o, l, f) \
862 1.18.4.2 thorpej ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
863 1.18.4.2 thorpej #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
864 1.18.4.2 thorpej #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
865 1.18.4.2 thorpej
866 1.18.4.2 thorpej
867 1.18.4.2 thorpej /*
868 1.18.4.2 thorpej * Flags used in various bus DMA methods.
869 1.18.4.2 thorpej */
870 1.18.4.2 thorpej #define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
871 1.18.4.2 thorpej #define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
872 1.18.4.2 thorpej #define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
873 1.18.4.2 thorpej #define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
874 1.18.4.2 thorpej #define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
875 1.18.4.2 thorpej #define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
876 1.18.4.2 thorpej #define BUS_DMA_BUS2 0x020
877 1.18.4.2 thorpej #define BUS_DMA_BUS3 0x040
878 1.18.4.2 thorpej #define BUS_DMA_BUS4 0x080
879 1.18.4.2 thorpej #define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
880 1.18.4.2 thorpej #define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
881 1.18.4.2 thorpej
882 1.18.4.2 thorpej #define VAX_BUS_DMA_SPILLPAGE BUS_DMA_BUS1 /* VS4000 kludge */
883 1.18.4.2 thorpej /*
884 1.18.4.2 thorpej * Private flags stored in the DMA map.
885 1.18.4.2 thorpej */
886 1.18.4.2 thorpej #define DMAMAP_HAS_SGMAP 0x80000000 /* sgva/len are valid */
887 1.18.4.2 thorpej
888 1.18.4.2 thorpej /* Forwards needed by prototypes below. */
889 1.18.4.2 thorpej struct mbuf;
890 1.18.4.2 thorpej struct uio;
891 1.18.4.2 thorpej struct vax_sgmap;
892 1.18.4.2 thorpej
893 1.18.4.2 thorpej /*
894 1.18.4.2 thorpej * Operations performed by bus_dmamap_sync().
895 1.18.4.2 thorpej */
896 1.18.4.2 thorpej #define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
897 1.18.4.2 thorpej #define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
898 1.18.4.2 thorpej #define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
899 1.18.4.2 thorpej #define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
900 1.18.4.2 thorpej
901 1.18.4.2 thorpej /*
902 1.18.4.2 thorpej * vax_bus_t
903 1.18.4.2 thorpej *
904 1.18.4.2 thorpej * Busses supported by NetBSD/vax, used by internal
905 1.18.4.2 thorpej * utility functions. NOT TO BE USED BY MACHINE-INDEPENDENT
906 1.18.4.2 thorpej * CODE!
907 1.18.4.2 thorpej */
908 1.18.4.2 thorpej typedef enum {
909 1.18.4.2 thorpej VAX_BUS_MAINBUS,
910 1.18.4.2 thorpej VAX_BUS_SBI,
911 1.18.4.2 thorpej VAX_BUS_MASSBUS,
912 1.18.4.2 thorpej VAX_BUS_UNIBUS, /* Also handles QBUS */
913 1.18.4.2 thorpej VAX_BUS_BI,
914 1.18.4.2 thorpej VAX_BUS_XMI,
915 1.18.4.2 thorpej VAX_BUS_TURBOCHANNEL
916 1.18.4.2 thorpej } vax_bus_t;
917 1.18.4.2 thorpej
918 1.18.4.2 thorpej typedef struct vax_bus_dma_tag *bus_dma_tag_t;
919 1.18.4.2 thorpej typedef struct vax_bus_dmamap *bus_dmamap_t;
920 1.18.4.2 thorpej
921 1.18.4.2 thorpej /*
922 1.18.4.2 thorpej * bus_dma_segment_t
923 1.18.4.2 thorpej *
924 1.18.4.2 thorpej * Describes a single contiguous DMA transaction. Values
925 1.18.4.2 thorpej * are suitable for programming into DMA registers.
926 1.18.4.2 thorpej */
927 1.18.4.2 thorpej struct vax_bus_dma_segment {
928 1.18.4.2 thorpej bus_addr_t ds_addr; /* DMA address */
929 1.18.4.2 thorpej bus_size_t ds_len; /* length of transfer */
930 1.18.4.2 thorpej };
931 1.18.4.2 thorpej typedef struct vax_bus_dma_segment bus_dma_segment_t;
932 1.18.4.2 thorpej
933 1.18.4.2 thorpej struct proc;
934 1.18.4.2 thorpej
935 1.18.4.2 thorpej /*
936 1.18.4.2 thorpej * bus_dma_tag_t
937 1.18.4.2 thorpej *
938 1.18.4.2 thorpej * A machine-dependent opaque type describing the implementation of
939 1.18.4.2 thorpej * DMA for a given bus.
940 1.18.4.2 thorpej */
941 1.18.4.2 thorpej struct vax_bus_dma_tag {
942 1.18.4.2 thorpej void *_cookie; /* cookie used in the guts */
943 1.18.4.2 thorpej bus_addr_t _wbase; /* DMA window base */
944 1.18.4.2 thorpej bus_size_t _wsize; /* DMA window size */
945 1.18.4.2 thorpej
946 1.18.4.2 thorpej /*
947 1.18.4.2 thorpej * Some chipsets have a built-in boundary constraint, independent
948 1.18.4.2 thorpej * of what the device requests. This allows that boundary to
949 1.18.4.2 thorpej * be specified. If the device has a more restrictive constraint,
950 1.18.4.2 thorpej * the map will use that, otherwise this boundary will be used.
951 1.18.4.2 thorpej * This value is ignored if 0.
952 1.18.4.2 thorpej */
953 1.18.4.2 thorpej bus_size_t _boundary;
954 1.18.4.2 thorpej
955 1.18.4.2 thorpej /*
956 1.18.4.2 thorpej * A bus may have more than one SGMAP window, so SGMAP
957 1.18.4.2 thorpej * windows also get a pointer to their SGMAP state.
958 1.18.4.2 thorpej */
959 1.18.4.2 thorpej struct vax_sgmap *_sgmap;
960 1.18.4.2 thorpej
961 1.18.4.2 thorpej /*
962 1.18.4.2 thorpej * Internal-use only utility methods. NOT TO BE USED BY
963 1.18.4.2 thorpej * MACHINE-INDEPENDENT CODE!
964 1.18.4.2 thorpej */
965 1.18.4.2 thorpej bus_dma_tag_t (*_get_tag) __P((bus_dma_tag_t, vax_bus_t));
966 1.18.4.2 thorpej
967 1.18.4.2 thorpej /*
968 1.18.4.2 thorpej * DMA mapping methods.
969 1.18.4.2 thorpej */
970 1.18.4.2 thorpej int (*_dmamap_create) __P((bus_dma_tag_t, bus_size_t, int,
971 1.18.4.2 thorpej bus_size_t, bus_size_t, int, bus_dmamap_t *));
972 1.18.4.2 thorpej void (*_dmamap_destroy) __P((bus_dma_tag_t, bus_dmamap_t));
973 1.18.4.2 thorpej int (*_dmamap_load) __P((bus_dma_tag_t, bus_dmamap_t, void *,
974 1.18.4.2 thorpej bus_size_t, struct proc *, int));
975 1.18.4.2 thorpej int (*_dmamap_load_mbuf) __P((bus_dma_tag_t, bus_dmamap_t,
976 1.18.4.2 thorpej struct mbuf *, int));
977 1.18.4.2 thorpej int (*_dmamap_load_uio) __P((bus_dma_tag_t, bus_dmamap_t,
978 1.18.4.2 thorpej struct uio *, int));
979 1.18.4.2 thorpej int (*_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t,
980 1.18.4.2 thorpej bus_dma_segment_t *, int, bus_size_t, int));
981 1.18.4.2 thorpej void (*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
982 1.18.4.2 thorpej void (*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
983 1.18.4.2 thorpej bus_addr_t, bus_size_t, int));
984 1.18.4.2 thorpej
985 1.18.4.2 thorpej /*
986 1.18.4.2 thorpej * DMA memory utility functions.
987 1.18.4.2 thorpej */
988 1.18.4.2 thorpej int (*_dmamem_alloc) __P((bus_dma_tag_t, bus_size_t, bus_size_t,
989 1.18.4.2 thorpej bus_size_t, bus_dma_segment_t *, int, int *, int));
990 1.18.4.2 thorpej void (*_dmamem_free) __P((bus_dma_tag_t,
991 1.18.4.2 thorpej bus_dma_segment_t *, int));
992 1.18.4.2 thorpej int (*_dmamem_map) __P((bus_dma_tag_t, bus_dma_segment_t *,
993 1.18.4.2 thorpej int, size_t, caddr_t *, int));
994 1.18.4.2 thorpej void (*_dmamem_unmap) __P((bus_dma_tag_t, caddr_t, size_t));
995 1.18.4.2 thorpej paddr_t (*_dmamem_mmap) __P((bus_dma_tag_t, bus_dma_segment_t *,
996 1.18.4.2 thorpej int, off_t, int, int));
997 1.18.4.2 thorpej };
998 1.18.4.2 thorpej
999 1.18.4.2 thorpej #define vaxbus_dma_get_tag(t, b) \
1000 1.18.4.2 thorpej (*(t)->_get_tag)(t, b)
1001 1.18.4.2 thorpej
1002 1.18.4.2 thorpej #define bus_dmamap_create(t, s, n, m, b, f, p) \
1003 1.18.4.2 thorpej (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
1004 1.18.4.2 thorpej #define bus_dmamap_destroy(t, p) \
1005 1.18.4.2 thorpej (*(t)->_dmamap_destroy)((t), (p))
1006 1.18.4.2 thorpej #define bus_dmamap_load(t, m, b, s, p, f) \
1007 1.18.4.2 thorpej (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
1008 1.18.4.2 thorpej #define bus_dmamap_load_mbuf(t, m, b, f) \
1009 1.18.4.2 thorpej (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
1010 1.18.4.2 thorpej #define bus_dmamap_load_uio(t, m, u, f) \
1011 1.18.4.2 thorpej (*(t)->_dmamap_load_uio)((t), (m), (u), (f))
1012 1.18.4.2 thorpej #define bus_dmamap_load_raw(t, m, sg, n, s, f) \
1013 1.18.4.2 thorpej (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
1014 1.18.4.2 thorpej #define bus_dmamap_unload(t, p) \
1015 1.18.4.2 thorpej (*(t)->_dmamap_unload)((t), (p))
1016 1.18.4.2 thorpej #define bus_dmamap_sync(t, p, o, l, ops) \
1017 1.18.4.2 thorpej (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops))
1018 1.18.4.2 thorpej #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
1019 1.18.4.2 thorpej (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
1020 1.18.4.2 thorpej #define bus_dmamem_free(t, sg, n) \
1021 1.18.4.2 thorpej (*(t)->_dmamem_free)((t), (sg), (n))
1022 1.18.4.2 thorpej #define bus_dmamem_map(t, sg, n, s, k, f) \
1023 1.18.4.2 thorpej (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
1024 1.18.4.2 thorpej #define bus_dmamem_unmap(t, k, s) \
1025 1.18.4.2 thorpej (*(t)->_dmamem_unmap)((t), (k), (s))
1026 1.18.4.2 thorpej #define bus_dmamem_mmap(t, sg, n, o, p, f) \
1027 1.18.4.2 thorpej (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
1028 1.18.4.2 thorpej
1029 1.18.4.2 thorpej /*
1030 1.18.4.2 thorpej * bus_dmamap_t
1031 1.18.4.2 thorpej *
1032 1.18.4.2 thorpej * Describes a DMA mapping.
1033 1.18.4.2 thorpej */
1034 1.18.4.2 thorpej struct vax_bus_dmamap {
1035 1.18.4.2 thorpej /*
1036 1.18.4.2 thorpej * PRIVATE MEMBERS: not for use my machine-independent code.
1037 1.18.4.2 thorpej */
1038 1.18.4.2 thorpej bus_size_t _dm_size; /* largest DMA transfer mappable */
1039 1.18.4.2 thorpej int _dm_segcnt; /* number of segs this map can map */
1040 1.18.4.2 thorpej bus_size_t _dm_maxsegsz; /* largest possible segment */
1041 1.18.4.2 thorpej bus_size_t _dm_boundary; /* don't cross this */
1042 1.18.4.2 thorpej int _dm_flags; /* misc. flags */
1043 1.18.4.2 thorpej
1044 1.18.4.2 thorpej /*
1045 1.18.4.2 thorpej * This is used only for SGMAP-mapped DMA, but we keep it
1046 1.18.4.2 thorpej * here to avoid pointless indirection.
1047 1.18.4.2 thorpej */
1048 1.18.4.2 thorpej int _dm_pteidx; /* PTE index */
1049 1.18.4.2 thorpej int _dm_ptecnt; /* PTE count */
1050 1.18.4.2 thorpej u_long _dm_sgva; /* allocated sgva */
1051 1.18.4.2 thorpej bus_size_t _dm_sgvalen; /* svga length */
1052 1.18.4.2 thorpej
1053 1.18.4.2 thorpej /*
1054 1.18.4.2 thorpej * PUBLIC MEMBERS: these are used by machine-independent code.
1055 1.18.4.2 thorpej */
1056 1.18.4.2 thorpej bus_size_t dm_mapsize; /* size of the mapping */
1057 1.18.4.2 thorpej int dm_nsegs; /* # valid segments in mapping */
1058 1.18.4.2 thorpej bus_dma_segment_t dm_segs[1]; /* segments; variable length */
1059 1.18.4.2 thorpej };
1060 1.18.4.2 thorpej
1061 1.18.4.2 thorpej /*#ifdef _VAX_BUS_DMA_PRIVATE */
1062 1.18.4.2 thorpej int _bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t,
1063 1.18.4.2 thorpej bus_size_t, int, bus_dmamap_t *));
1064 1.18.4.2 thorpej void _bus_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t));
1065 1.18.4.2 thorpej
1066 1.18.4.2 thorpej int _bus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t,
1067 1.18.4.2 thorpej void *, bus_size_t, struct proc *, int));
1068 1.18.4.2 thorpej int _bus_dmamap_load_mbuf __P((bus_dma_tag_t,
1069 1.18.4.2 thorpej bus_dmamap_t, struct mbuf *, int));
1070 1.18.4.2 thorpej int _bus_dmamap_load_uio __P((bus_dma_tag_t,
1071 1.18.4.2 thorpej bus_dmamap_t, struct uio *, int));
1072 1.18.4.2 thorpej int _bus_dmamap_load_raw __P((bus_dma_tag_t,
1073 1.18.4.2 thorpej bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int));
1074 1.18.4.2 thorpej
1075 1.18.4.2 thorpej void _bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
1076 1.18.4.2 thorpej void _bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
1077 1.18.4.2 thorpej bus_size_t, int));
1078 1.18.4.2 thorpej
1079 1.18.4.2 thorpej int _bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size,
1080 1.18.4.2 thorpej bus_size_t alignment, bus_size_t boundary,
1081 1.18.4.2 thorpej bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags));
1082 1.18.4.2 thorpej void _bus_dmamem_free __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
1083 1.18.4.2 thorpej int nsegs));
1084 1.18.4.2 thorpej int _bus_dmamem_map __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
1085 1.18.4.2 thorpej int nsegs, size_t size, caddr_t *kvap, int flags));
1086 1.18.4.2 thorpej void _bus_dmamem_unmap __P((bus_dma_tag_t tag, caddr_t kva,
1087 1.18.4.2 thorpej size_t size));
1088 1.18.4.2 thorpej paddr_t _bus_dmamem_mmap __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
1089 1.18.4.2 thorpej int nsegs, off_t off, int prot, int flags));
1090 1.18.4.2 thorpej /*#endif*/ /* _VAX_BUS_DMA_PRIVATE */
1091 1.18.4.2 thorpej
1092 1.18.4.2 thorpej #endif /* _VAX_BUS_H_ */
1093