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