bus.h revision 1.3.6.2 1 1.3.6.2 bouyer /* $NetBSD: bus.h,v 1.3.6.2 2000/11/20 20:10:28 bouyer Exp $ */
2 1.3.6.2 bouyer
3 1.3.6.2 bouyer /*-
4 1.3.6.2 bouyer * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
5 1.3.6.2 bouyer * All rights reserved.
6 1.3.6.2 bouyer *
7 1.3.6.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.3.6.2 bouyer * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.3.6.2 bouyer * NASA Ames Research Center.
10 1.3.6.2 bouyer *
11 1.3.6.2 bouyer * Redistribution and use in source and binary forms, with or without
12 1.3.6.2 bouyer * modification, are permitted provided that the following conditions
13 1.3.6.2 bouyer * are met:
14 1.3.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
15 1.3.6.2 bouyer * notice, this list of conditions and the following disclaimer.
16 1.3.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
17 1.3.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
18 1.3.6.2 bouyer * documentation and/or other materials provided with the distribution.
19 1.3.6.2 bouyer * 3. All advertising materials mentioning features or use of this software
20 1.3.6.2 bouyer * must display the following acknowledgement:
21 1.3.6.2 bouyer * This product includes software developed by the NetBSD
22 1.3.6.2 bouyer * Foundation, Inc. and its contributors.
23 1.3.6.2 bouyer * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.3.6.2 bouyer * contributors may be used to endorse or promote products derived
25 1.3.6.2 bouyer * from this software without specific prior written permission.
26 1.3.6.2 bouyer *
27 1.3.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.3.6.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.3.6.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.3.6.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.3.6.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.3.6.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.3.6.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.3.6.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.3.6.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.3.6.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.3.6.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
38 1.3.6.2 bouyer */
39 1.3.6.2 bouyer
40 1.3.6.2 bouyer /*
41 1.3.6.2 bouyer * Copyright (C) 1997 Scott Reynolds. All rights reserved.
42 1.3.6.2 bouyer *
43 1.3.6.2 bouyer * Redistribution and use in source and binary forms, with or without
44 1.3.6.2 bouyer * modification, are permitted provided that the following conditions
45 1.3.6.2 bouyer * are met:
46 1.3.6.2 bouyer * 1. Redistributions of source code must retain the above copyright
47 1.3.6.2 bouyer * notice, this list of conditions and the following disclaimer.
48 1.3.6.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
49 1.3.6.2 bouyer * notice, this list of conditions and the following disclaimer in the
50 1.3.6.2 bouyer * documentation and/or other materials provided with the distribution.
51 1.3.6.2 bouyer * 3. The name of the author may not be used to endorse or promote products
52 1.3.6.2 bouyer * derived from this software without specific prior written permission
53 1.3.6.2 bouyer *
54 1.3.6.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
55 1.3.6.2 bouyer * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
56 1.3.6.2 bouyer * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
57 1.3.6.2 bouyer * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
58 1.3.6.2 bouyer * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
59 1.3.6.2 bouyer * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
60 1.3.6.2 bouyer * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
61 1.3.6.2 bouyer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
62 1.3.6.2 bouyer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
63 1.3.6.2 bouyer * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64 1.3.6.2 bouyer */
65 1.3.6.2 bouyer
66 1.3.6.2 bouyer #ifndef _MACHINE_BUS_H_
67 1.3.6.2 bouyer #define _MACHINE_BUS_H_
68 1.3.6.2 bouyer
69 1.3.6.2 bouyer /*
70 1.3.6.2 bouyer * Value for the luna68k bus space tag, not to be used directly by MI code.
71 1.3.6.2 bouyer */
72 1.3.6.2 bouyer #define MACHINE_BUS_SPACE_MEM 0 /* space is mem space */
73 1.3.6.2 bouyer
74 1.3.6.2 bouyer /*
75 1.3.6.2 bouyer * Bus address and size types
76 1.3.6.2 bouyer */
77 1.3.6.2 bouyer typedef u_long bus_addr_t;
78 1.3.6.2 bouyer typedef u_long bus_size_t;
79 1.3.6.2 bouyer
80 1.3.6.2 bouyer /*
81 1.3.6.2 bouyer * Access methods for bus resources and address space.
82 1.3.6.2 bouyer */
83 1.3.6.2 bouyer typedef int bus_space_tag_t;
84 1.3.6.2 bouyer typedef u_long bus_space_handle_t;
85 1.3.6.2 bouyer
86 1.3.6.2 bouyer /*
87 1.3.6.2 bouyer * int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr,
88 1.3.6.2 bouyer * bus_size_t size, int flags, bus_space_handle_t *bshp));
89 1.3.6.2 bouyer *
90 1.3.6.2 bouyer * Map a region of bus space.
91 1.3.6.2 bouyer */
92 1.3.6.2 bouyer
93 1.3.6.2 bouyer #define BUS_SPACE_MAP_CACHEABLE 0x01
94 1.3.6.2 bouyer #define BUS_SPACE_MAP_LINEAR 0x02
95 1.3.6.2 bouyer #define BUS_SPACE_MAP_PREFETCHABLE 0x04
96 1.3.6.2 bouyer
97 1.3.6.2 bouyer int bus_space_map __P((bus_space_tag_t, bus_addr_t, bus_size_t,
98 1.3.6.2 bouyer int, bus_space_handle_t *));
99 1.3.6.2 bouyer
100 1.3.6.2 bouyer /*
101 1.3.6.2 bouyer * void bus_space_unmap __P((bus_space_tag_t t,
102 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t size));
103 1.3.6.2 bouyer *
104 1.3.6.2 bouyer * Unmap a region of bus space.
105 1.3.6.2 bouyer */
106 1.3.6.2 bouyer
107 1.3.6.2 bouyer void bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
108 1.3.6.2 bouyer
109 1.3.6.2 bouyer /*
110 1.3.6.2 bouyer * int bus_space_subregion __P((bus_space_tag_t t,
111 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
112 1.3.6.2 bouyer * bus_space_handle_t *nbshp));
113 1.3.6.2 bouyer *
114 1.3.6.2 bouyer * Get a new handle for a subregion of an already-mapped area of bus space.
115 1.3.6.2 bouyer */
116 1.3.6.2 bouyer
117 1.3.6.2 bouyer int bus_space_subregion __P((bus_space_tag_t t, bus_space_handle_t bsh,
118 1.3.6.2 bouyer bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp));
119 1.3.6.2 bouyer
120 1.3.6.2 bouyer /*
121 1.3.6.2 bouyer * int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t, rstart,
122 1.3.6.2 bouyer * bus_addr_t rend, bus_size_t size, bus_size_t align,
123 1.3.6.2 bouyer * bus_size_t boundary, int flags, bus_addr_t *addrp,
124 1.3.6.2 bouyer * bus_space_handle_t *bshp));
125 1.3.6.2 bouyer *
126 1.3.6.2 bouyer * Allocate a region of bus space.
127 1.3.6.2 bouyer */
128 1.3.6.2 bouyer
129 1.3.6.2 bouyer int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart,
130 1.3.6.2 bouyer bus_addr_t rend, bus_size_t size, bus_size_t align,
131 1.3.6.2 bouyer bus_size_t boundary, int cacheable, bus_addr_t *addrp,
132 1.3.6.2 bouyer bus_space_handle_t *bshp));
133 1.3.6.2 bouyer
134 1.3.6.2 bouyer /*
135 1.3.6.2 bouyer * int bus_space_free __P((bus_space_tag_t t,
136 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t size));
137 1.3.6.2 bouyer *
138 1.3.6.2 bouyer * Free a region of bus space.
139 1.3.6.2 bouyer */
140 1.3.6.2 bouyer
141 1.3.6.2 bouyer void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh,
142 1.3.6.2 bouyer bus_size_t size));
143 1.3.6.2 bouyer
144 1.3.6.2 bouyer /*
145 1.3.6.2 bouyer * u_intN_t bus_space_read_N __P((bus_space_tag_t tag,
146 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset));
147 1.3.6.2 bouyer *
148 1.3.6.2 bouyer * Read a 1, 2, 4, or 8 byte quantity from bus space
149 1.3.6.2 bouyer * described by tag/handle/offset.
150 1.3.6.2 bouyer */
151 1.3.6.2 bouyer
152 1.3.6.2 bouyer #define bus_space_read_1(t, h, o) \
153 1.3.6.2 bouyer ((void) t, (*(volatile u_int8_t *)((h) + 4*(o))))
154 1.3.6.2 bouyer
155 1.3.6.2 bouyer #define bus_space_read_2(t, h, o) \
156 1.3.6.2 bouyer ((void) t, (*(volatile u_int16_t *)((h) + 4*(o))))
157 1.3.6.2 bouyer
158 1.3.6.2 bouyer #define bus_space_read_4(t, h, o) \
159 1.3.6.2 bouyer ((void) t, (*(volatile u_int32_t *)((h) + 4*(o))))
160 1.3.6.2 bouyer
161 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_read_8 */
162 1.3.6.2 bouyer #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
163 1.3.6.2 bouyer #endif
164 1.3.6.2 bouyer
165 1.3.6.2 bouyer /*
166 1.3.6.2 bouyer * void bus_space_read_multi_N __P((bus_space_tag_t tag,
167 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset,
168 1.3.6.2 bouyer * u_intN_t *addr, size_t count));
169 1.3.6.2 bouyer *
170 1.3.6.2 bouyer * Read `count' 1, 2, 4, or 8 byte quantities from bus space
171 1.3.6.2 bouyer * described by tag/handle/offset and copy into buffer provided.
172 1.3.6.2 bouyer */
173 1.3.6.2 bouyer
174 1.3.6.2 bouyer #define bus_space_read_multi_1(t, h, o, a, c) do { \
175 1.3.6.2 bouyer (void) t; \
176 1.3.6.2 bouyer __asm __volatile (" \
177 1.3.6.2 bouyer movl %0,a0 ; \
178 1.3.6.2 bouyer movl %1,a1 ; \
179 1.3.6.2 bouyer movl %2,d0 ; \
180 1.3.6.2 bouyer 1: movb a0@,a1@+ ; \
181 1.3.6.2 bouyer subql #1,d0 ; \
182 1.3.6.2 bouyer jne 1b" : \
183 1.3.6.2 bouyer : \
184 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
185 1.3.6.2 bouyer "a0","a1","d0"); \
186 1.3.6.2 bouyer } while (0)
187 1.3.6.2 bouyer
188 1.3.6.2 bouyer #define bus_space_read_multi_2(t, h, o, a, c) do { \
189 1.3.6.2 bouyer (void) t; \
190 1.3.6.2 bouyer __asm __volatile (" \
191 1.3.6.2 bouyer movl %0,a0 ; \
192 1.3.6.2 bouyer movl %1,a1 ; \
193 1.3.6.2 bouyer movl %2,d0 ; \
194 1.3.6.2 bouyer 1: movw a0@,a1@+ ; \
195 1.3.6.2 bouyer subql #1,d0 ; \
196 1.3.6.2 bouyer jne 1b" : \
197 1.3.6.2 bouyer : \
198 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
199 1.3.6.2 bouyer "a0","a1","d0"); \
200 1.3.6.2 bouyer } while (0)
201 1.3.6.2 bouyer
202 1.3.6.2 bouyer #define bus_space_read_multi_4(t, h, o, a, c) do { \
203 1.3.6.2 bouyer (void) t; \
204 1.3.6.2 bouyer __asm __volatile (" \
205 1.3.6.2 bouyer movl %0,a0 ; \
206 1.3.6.2 bouyer movl %1,a1 ; \
207 1.3.6.2 bouyer movl %2,d0 ; \
208 1.3.6.2 bouyer 1: movl a0@,a1@+ ; \
209 1.3.6.2 bouyer subql #1,d0 ; \
210 1.3.6.2 bouyer jne 1b" : \
211 1.3.6.2 bouyer : \
212 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
213 1.3.6.2 bouyer "a0","a1","d0"); \
214 1.3.6.2 bouyer } while (0)
215 1.3.6.2 bouyer
216 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_read_multi_8 */
217 1.3.6.2 bouyer #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
218 1.3.6.2 bouyer #endif
219 1.3.6.2 bouyer
220 1.3.6.2 bouyer /*
221 1.3.6.2 bouyer * void bus_space_read_region_N __P((bus_space_tag_t tag,
222 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset,
223 1.3.6.2 bouyer * u_intN_t *addr, size_t count));
224 1.3.6.2 bouyer *
225 1.3.6.2 bouyer * Read `count' 1, 2, 4, or 8 byte quantities from bus space
226 1.3.6.2 bouyer * described by tag/handle and starting at `offset' and copy into
227 1.3.6.2 bouyer * buffer provided.
228 1.3.6.2 bouyer */
229 1.3.6.2 bouyer
230 1.3.6.2 bouyer #define bus_space_read_region_1(t, h, o, a, c) do { \
231 1.3.6.2 bouyer (void) t; \
232 1.3.6.2 bouyer __asm __volatile (" \
233 1.3.6.2 bouyer movl %0,a0 ; \
234 1.3.6.2 bouyer movl %1,a1 ; \
235 1.3.6.2 bouyer movl %2,d0 ; \
236 1.3.6.2 bouyer 1: movb a0@+,a1@+ ; \
237 1.3.6.2 bouyer subql #1,d0 ; \
238 1.3.6.2 bouyer jne 1b" : \
239 1.3.6.2 bouyer : \
240 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
241 1.3.6.2 bouyer "a0","a1","d0"); \
242 1.3.6.2 bouyer } while (0)
243 1.3.6.2 bouyer
244 1.3.6.2 bouyer #define bus_space_read_region_2(t, h, o, a, c) do { \
245 1.3.6.2 bouyer (void) t; \
246 1.3.6.2 bouyer __asm __volatile (" \
247 1.3.6.2 bouyer movl %0,a0 ; \
248 1.3.6.2 bouyer movl %1,a1 ; \
249 1.3.6.2 bouyer movl %2,d0 ; \
250 1.3.6.2 bouyer 1: movw a0@+,a1@+ ; \
251 1.3.6.2 bouyer subql #1,d0 ; \
252 1.3.6.2 bouyer jne 1b" : \
253 1.3.6.2 bouyer : \
254 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
255 1.3.6.2 bouyer "a0","a1","d0"); \
256 1.3.6.2 bouyer } while (0)
257 1.3.6.2 bouyer
258 1.3.6.2 bouyer #define bus_space_read_region_4(t, h, o, a, c) do { \
259 1.3.6.2 bouyer (void) t; \
260 1.3.6.2 bouyer __asm __volatile (" \
261 1.3.6.2 bouyer movl %0,a0 ; \
262 1.3.6.2 bouyer movl %1,a1 ; \
263 1.3.6.2 bouyer movl %2,d0 ; \
264 1.3.6.2 bouyer 1: movl a0@+,a1@+ ; \
265 1.3.6.2 bouyer subql #1,d0 ; \
266 1.3.6.2 bouyer jne 1b" : \
267 1.3.6.2 bouyer : \
268 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
269 1.3.6.2 bouyer "a0","a1","d0"); \
270 1.3.6.2 bouyer } while (0)
271 1.3.6.2 bouyer
272 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_read_region_8 */
273 1.3.6.2 bouyer #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
274 1.3.6.2 bouyer #endif
275 1.3.6.2 bouyer
276 1.3.6.2 bouyer /*
277 1.3.6.2 bouyer * void bus_space_write_N __P((bus_space_tag_t tag,
278 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset,
279 1.3.6.2 bouyer * u_intN_t value));
280 1.3.6.2 bouyer *
281 1.3.6.2 bouyer * Write the 1, 2, 4, or 8 byte value `value' to bus space
282 1.3.6.2 bouyer * described by tag/handle/offset.
283 1.3.6.2 bouyer */
284 1.3.6.2 bouyer
285 1.3.6.2 bouyer #define bus_space_write_1(t, h, o, v) \
286 1.3.6.2 bouyer ((void) t, ((void)(*(volatile u_int8_t *)((h) + 4*(o)) = (v))))
287 1.3.6.2 bouyer
288 1.3.6.2 bouyer #define bus_space_write_2(t, h, o, v) \
289 1.3.6.2 bouyer ((void) t, ((void)(*(volatile u_int16_t *)((h) + 4*(o)) = (v))))
290 1.3.6.2 bouyer
291 1.3.6.2 bouyer #define bus_space_write_4(t, h, o, v) \
292 1.3.6.2 bouyer ((void) t, ((void)(*(volatile u_int32_t *)((h) + 4*(o)) = (v))))
293 1.3.6.2 bouyer
294 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_write_8 */
295 1.3.6.2 bouyer #define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
296 1.3.6.2 bouyer #endif
297 1.3.6.2 bouyer
298 1.3.6.2 bouyer /*
299 1.3.6.2 bouyer * void bus_space_write_multi_N __P((bus_space_tag_t tag,
300 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset,
301 1.3.6.2 bouyer * const u_intN_t *addr, size_t count));
302 1.3.6.2 bouyer *
303 1.3.6.2 bouyer * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
304 1.3.6.2 bouyer * provided to bus space described by tag/handle/offset.
305 1.3.6.2 bouyer */
306 1.3.6.2 bouyer
307 1.3.6.2 bouyer #define bus_space_write_multi_1(t, h, o, a, c) do { \
308 1.3.6.2 bouyer (void) t; \
309 1.3.6.2 bouyer __asm __volatile (" \
310 1.3.6.2 bouyer movl %0,a0 ; \
311 1.3.6.2 bouyer movl %1,a1 ; \
312 1.3.6.2 bouyer movl %2,d0 ; \
313 1.3.6.2 bouyer 1: movb a1@+,a0@ ; \
314 1.3.6.2 bouyer subql #1,d0 ; \
315 1.3.6.2 bouyer jne 1b" : \
316 1.3.6.2 bouyer : \
317 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
318 1.3.6.2 bouyer "a0","a1","d0"); \
319 1.3.6.2 bouyer } while (0)
320 1.3.6.2 bouyer
321 1.3.6.2 bouyer #define bus_space_write_multi_2(t, h, o, a, c) do { \
322 1.3.6.2 bouyer (void) t; \
323 1.3.6.2 bouyer __asm __volatile (" \
324 1.3.6.2 bouyer movl %0,a0 ; \
325 1.3.6.2 bouyer movl %1,a1 ; \
326 1.3.6.2 bouyer movl %2,d0 ; \
327 1.3.6.2 bouyer 1: movw a1@+,a0@ ; \
328 1.3.6.2 bouyer subql #1,d0 ; \
329 1.3.6.2 bouyer jne 1b" : \
330 1.3.6.2 bouyer : \
331 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
332 1.3.6.2 bouyer "a0","a1","d0"); \
333 1.3.6.2 bouyer } while (0)
334 1.3.6.2 bouyer
335 1.3.6.2 bouyer #define bus_space_write_multi_4(t, h, o, a, c) do { \
336 1.3.6.2 bouyer (void) t; \
337 1.3.6.2 bouyer __asm __volatile (" \
338 1.3.6.2 bouyer movl %0,a0 ; \
339 1.3.6.2 bouyer movl %1,a1 ; \
340 1.3.6.2 bouyer movl %2,d0 ; \
341 1.3.6.2 bouyer 1: movl a1@+,a0@ ; \
342 1.3.6.2 bouyer subql #1,d0 ; \
343 1.3.6.2 bouyer jne 1b" : \
344 1.3.6.2 bouyer : \
345 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
346 1.3.6.2 bouyer "a0","a1","d0"); \
347 1.3.6.2 bouyer } while (0)
348 1.3.6.2 bouyer
349 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_write_8 */
350 1.3.6.2 bouyer #define bus_space_write_multi_8(t, h, o, a, c) \
351 1.3.6.2 bouyer !!! bus_space_write_multi_8 unimplimented !!!
352 1.3.6.2 bouyer #endif
353 1.3.6.2 bouyer
354 1.3.6.2 bouyer /*
355 1.3.6.2 bouyer * void bus_space_write_region_N __P((bus_space_tag_t tag,
356 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset,
357 1.3.6.2 bouyer * const u_intN_t *addr, size_t count));
358 1.3.6.2 bouyer *
359 1.3.6.2 bouyer * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
360 1.3.6.2 bouyer * to bus space described by tag/handle starting at `offset'.
361 1.3.6.2 bouyer */
362 1.3.6.2 bouyer
363 1.3.6.2 bouyer #define bus_space_write_region_1(t, h, o, a, c) do { \
364 1.3.6.2 bouyer (void) t; \
365 1.3.6.2 bouyer __asm __volatile (" \
366 1.3.6.2 bouyer movl %0,a0 ; \
367 1.3.6.2 bouyer movl %1,a1 ; \
368 1.3.6.2 bouyer movl %2,d0 ; \
369 1.3.6.2 bouyer 1: movb a1@+,a0@+ ; \
370 1.3.6.2 bouyer subql #1,d0 ; \
371 1.3.6.2 bouyer jne 1b" : \
372 1.3.6.2 bouyer : \
373 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
374 1.3.6.2 bouyer "a0","a1","d0"); \
375 1.3.6.2 bouyer } while (0)
376 1.3.6.2 bouyer
377 1.3.6.2 bouyer #define bus_space_write_region_2(t, h, o, a, c) do { \
378 1.3.6.2 bouyer (void) t; \
379 1.3.6.2 bouyer __asm __volatile (" \
380 1.3.6.2 bouyer movl %0,a0 ; \
381 1.3.6.2 bouyer movl %1,a1 ; \
382 1.3.6.2 bouyer movl %2,d0 ; \
383 1.3.6.2 bouyer 1: movw a1@+,a0@+ ; \
384 1.3.6.2 bouyer subql #1,d0 ; \
385 1.3.6.2 bouyer jne 1b" : \
386 1.3.6.2 bouyer : \
387 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
388 1.3.6.2 bouyer "a0","a1","d0"); \
389 1.3.6.2 bouyer } while (0)
390 1.3.6.2 bouyer
391 1.3.6.2 bouyer #define bus_space_write_region_4(t, h, o, a, c) do { \
392 1.3.6.2 bouyer (void) t; \
393 1.3.6.2 bouyer __asm __volatile (" \
394 1.3.6.2 bouyer movl %0,a0 ; \
395 1.3.6.2 bouyer movl %1,a1 ; \
396 1.3.6.2 bouyer movl %2,d0 ; \
397 1.3.6.2 bouyer 1: movl a1@+,a0@+ ; \
398 1.3.6.2 bouyer subql #1,d0 ; \
399 1.3.6.2 bouyer jne 1b" : \
400 1.3.6.2 bouyer : \
401 1.3.6.2 bouyer "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) : \
402 1.3.6.2 bouyer "a0","a1","d0"); \
403 1.3.6.2 bouyer } while (0)
404 1.3.6.2 bouyer
405 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_write_region_8 */
406 1.3.6.2 bouyer #define bus_space_write_region_8 \
407 1.3.6.2 bouyer !!! bus_space_write_region_8 unimplemented !!!
408 1.3.6.2 bouyer #endif
409 1.3.6.2 bouyer
410 1.3.6.2 bouyer /*
411 1.3.6.2 bouyer * void bus_space_set_multi_N __P((bus_space_tag_t tag,
412 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
413 1.3.6.2 bouyer * size_t count));
414 1.3.6.2 bouyer *
415 1.3.6.2 bouyer * Write the 1, 2, 4, or 8 byte value `val' to bus space described
416 1.3.6.2 bouyer * by tag/handle/offset `count' times.
417 1.3.6.2 bouyer */
418 1.3.6.2 bouyer
419 1.3.6.2 bouyer #define bus_space_set_multi_1(t, h, o, val, c) do { \
420 1.3.6.2 bouyer (void) t; \
421 1.3.6.2 bouyer __asm __volatile (" \
422 1.3.6.2 bouyer movl %0,a0 ; \
423 1.3.6.2 bouyer movl %1,d1 ; \
424 1.3.6.2 bouyer movl %2,d0 ; \
425 1.3.6.2 bouyer 1: movb d1,a0@ ; \
426 1.3.6.2 bouyer subql #1,d0 ; \
427 1.3.6.2 bouyer jne 1b" : \
428 1.3.6.2 bouyer : \
429 1.3.6.2 bouyer "r" ((h)+(o)), "g" ((u_long)val), \
430 1.3.6.2 bouyer "g" ((size_t)(c)) : \
431 1.3.6.2 bouyer "a0","d0","d1"); \
432 1.3.6.2 bouyer } while (0)
433 1.3.6.2 bouyer
434 1.3.6.2 bouyer #define bus_space_set_multi_2(t, h, o, val, c) do { \
435 1.3.6.2 bouyer (void) t; \
436 1.3.6.2 bouyer __asm __volatile (" \
437 1.3.6.2 bouyer movl %0,a0 ; \
438 1.3.6.2 bouyer movl %1,d1 ; \
439 1.3.6.2 bouyer movl %2,d0 ; \
440 1.3.6.2 bouyer 1: movw d1,a0@ ; \
441 1.3.6.2 bouyer subql #1,d0 ; \
442 1.3.6.2 bouyer jne 1b" : \
443 1.3.6.2 bouyer : \
444 1.3.6.2 bouyer "r" ((h)+(o)), "g" ((u_long)val), \
445 1.3.6.2 bouyer "g" ((size_t)(c)) : \
446 1.3.6.2 bouyer "a0","d0","d1"); \
447 1.3.6.2 bouyer } while (0)
448 1.3.6.2 bouyer
449 1.3.6.2 bouyer #define bus_space_set_multi_4(t, h, o, val, c) do { \
450 1.3.6.2 bouyer (void) t; \
451 1.3.6.2 bouyer __asm __volatile (" \
452 1.3.6.2 bouyer movl %0,a0 ; \
453 1.3.6.2 bouyer movl %1,d1 ; \
454 1.3.6.2 bouyer movl %2,d0 ; \
455 1.3.6.2 bouyer 1: movl d1,a0@ ; \
456 1.3.6.2 bouyer subql #1,d0 ; \
457 1.3.6.2 bouyer jne 1b" : \
458 1.3.6.2 bouyer : \
459 1.3.6.2 bouyer "r" ((h)+(o)), "g" ((u_long)val), \
460 1.3.6.2 bouyer "g" ((size_t)(c)) : \
461 1.3.6.2 bouyer "a0","d0","d1"); \
462 1.3.6.2 bouyer } while (0)
463 1.3.6.2 bouyer
464 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_set_multi_8 */
465 1.3.6.2 bouyer #define bus_space_set_multi_8 \
466 1.3.6.2 bouyer !!! bus_space_set_multi_8 unimplemented !!!
467 1.3.6.2 bouyer #endif
468 1.3.6.2 bouyer
469 1.3.6.2 bouyer /*
470 1.3.6.2 bouyer * void bus_space_set_region_N __P((bus_space_tag_t tag,
471 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
472 1.3.6.2 bouyer * size_t count));
473 1.3.6.2 bouyer *
474 1.3.6.2 bouyer * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
475 1.3.6.2 bouyer * by tag/handle starting at `offset'.
476 1.3.6.2 bouyer */
477 1.3.6.2 bouyer
478 1.3.6.2 bouyer #define bus_space_set_region_1(t, h, o, val, c) do { \
479 1.3.6.2 bouyer (void) t; \
480 1.3.6.2 bouyer __asm __volatile (" \
481 1.3.6.2 bouyer movl %0,a0 ; \
482 1.3.6.2 bouyer movl %1,d1 ; \
483 1.3.6.2 bouyer movl %2,d0 ; \
484 1.3.6.2 bouyer 1: movb d1,a0@+ ; \
485 1.3.6.2 bouyer subql #1,d0 ; \
486 1.3.6.2 bouyer jne 1b" : \
487 1.3.6.2 bouyer : \
488 1.3.6.2 bouyer "r" ((h)+(o)), "g" ((u_long)val), \
489 1.3.6.2 bouyer "g" ((size_t)(c)) : \
490 1.3.6.2 bouyer "a0","d0","d1"); \
491 1.3.6.2 bouyer } while (0)
492 1.3.6.2 bouyer
493 1.3.6.2 bouyer #define bus_space_set_region_2(t, h, o, val, c) do { \
494 1.3.6.2 bouyer (void) t; \
495 1.3.6.2 bouyer __asm __volatile (" \
496 1.3.6.2 bouyer movl %0,a0 ; \
497 1.3.6.2 bouyer movl %1,d1 ; \
498 1.3.6.2 bouyer movl %2,d0 ; \
499 1.3.6.2 bouyer 1: movw d1,a0@+ ; \
500 1.3.6.2 bouyer subql #1,d0 ; \
501 1.3.6.2 bouyer jne 1b" : \
502 1.3.6.2 bouyer : \
503 1.3.6.2 bouyer "r" ((h)+(o)), "g" ((u_long)val), \
504 1.3.6.2 bouyer "g" ((size_t)(c)) : \
505 1.3.6.2 bouyer "a0","d0","d1"); \
506 1.3.6.2 bouyer } while (0)
507 1.3.6.2 bouyer
508 1.3.6.2 bouyer #define bus_space_set_region_4(t, h, o, val, c) do { \
509 1.3.6.2 bouyer (void) t; \
510 1.3.6.2 bouyer __asm __volatile (" \
511 1.3.6.2 bouyer movl %0,a0 ; \
512 1.3.6.2 bouyer movl %1,d1 ; \
513 1.3.6.2 bouyer movl %2,d0 ; \
514 1.3.6.2 bouyer 1: movl d1,a0@+ ; \
515 1.3.6.2 bouyer subql #1,d0 ; \
516 1.3.6.2 bouyer jne 1b" : \
517 1.3.6.2 bouyer : \
518 1.3.6.2 bouyer "r" ((h)+(o)), "g" ((u_long)val), \
519 1.3.6.2 bouyer "g" ((size_t)(c)) : \
520 1.3.6.2 bouyer "a0","d0","d1"); \
521 1.3.6.2 bouyer } while (0)
522 1.3.6.2 bouyer
523 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_set_region_8 */
524 1.3.6.2 bouyer #define bus_space_set_region_8 \
525 1.3.6.2 bouyer !!! bus_space_set_region_8 unimplemented !!!
526 1.3.6.2 bouyer #endif
527 1.3.6.2 bouyer
528 1.3.6.2 bouyer /*
529 1.3.6.2 bouyer * void bus_space_copy_N __P((bus_space_tag_t tag,
530 1.3.6.2 bouyer * bus_space_handle_t bsh1, bus_size_t off1,
531 1.3.6.2 bouyer * bus_space_handle_t bsh2, bus_size_t off2,
532 1.3.6.2 bouyer * size_t count));
533 1.3.6.2 bouyer *
534 1.3.6.2 bouyer * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
535 1.3.6.2 bouyer * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
536 1.3.6.2 bouyer */
537 1.3.6.2 bouyer
538 1.3.6.2 bouyer #define __MACHINE_copy_region_N(BYTES) \
539 1.3.6.2 bouyer static __inline void __CONCAT(bus_space_copy_region_,BYTES) \
540 1.3.6.2 bouyer __P((bus_space_tag_t, \
541 1.3.6.2 bouyer bus_space_handle_t bsh1, bus_size_t off1, \
542 1.3.6.2 bouyer bus_space_handle_t bsh2, bus_size_t off2, \
543 1.3.6.2 bouyer bus_size_t count)); \
544 1.3.6.2 bouyer \
545 1.3.6.2 bouyer static __inline void \
546 1.3.6.2 bouyer __CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c) \
547 1.3.6.2 bouyer bus_space_tag_t t; \
548 1.3.6.2 bouyer bus_space_handle_t h1, h2; \
549 1.3.6.2 bouyer bus_size_t o1, o2, c; \
550 1.3.6.2 bouyer { \
551 1.3.6.2 bouyer bus_size_t o; \
552 1.3.6.2 bouyer \
553 1.3.6.2 bouyer if ((h1 + o1) >= (h2 + o2)) { \
554 1.3.6.2 bouyer /* src after dest: copy forward */ \
555 1.3.6.2 bouyer for (o = 0; c != 0; c--, o += BYTES) \
556 1.3.6.2 bouyer __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
557 1.3.6.2 bouyer __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
558 1.3.6.2 bouyer } else { \
559 1.3.6.2 bouyer /* dest after src: copy backwards */ \
560 1.3.6.2 bouyer for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \
561 1.3.6.2 bouyer __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
562 1.3.6.2 bouyer __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
563 1.3.6.2 bouyer } \
564 1.3.6.2 bouyer }
565 1.3.6.2 bouyer __MACHINE_copy_region_N(1)
566 1.3.6.2 bouyer __MACHINE_copy_region_N(2)
567 1.3.6.2 bouyer __MACHINE_copy_region_N(4)
568 1.3.6.2 bouyer #if 0 /* Cause a link error for bus_space_copy_8 */
569 1.3.6.2 bouyer #define bus_space_copy_8 \
570 1.3.6.2 bouyer !!! bus_space_copy_8 unimplemented !!!
571 1.3.6.2 bouyer #endif
572 1.3.6.2 bouyer
573 1.3.6.2 bouyer #undef __MACHINE_copy_region_N
574 1.3.6.2 bouyer
575 1.3.6.2 bouyer /*
576 1.3.6.2 bouyer * Bus read/write barrier methods.
577 1.3.6.2 bouyer *
578 1.3.6.2 bouyer * void bus_space_barrier __P((bus_space_tag_t tag,
579 1.3.6.2 bouyer * bus_space_handle_t bsh, bus_size_t offset,
580 1.3.6.2 bouyer * bus_size_t len, int flags));
581 1.3.6.2 bouyer *
582 1.3.6.2 bouyer * Note: the 680x0 does not currently require barriers, but we must
583 1.3.6.2 bouyer * provide the flags to MI code.
584 1.3.6.2 bouyer */
585 1.3.6.2 bouyer #define bus_space_barrier(t, h, o, l, f) \
586 1.3.6.2 bouyer ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
587 1.3.6.2 bouyer #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
588 1.3.6.2 bouyer #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
589 1.3.6.2 bouyer
590 1.3.6.2 bouyer #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
591 1.3.6.2 bouyer
592 1.3.6.2 bouyer #endif /* _MACHINE_BUS_H_ */
593