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