Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / sgimips / include / bus.h
blob88fd4ccca734afc77bc73083a8b64d3c78542344
1 /* $NetBSD: bus.h,v 1.27 2008/04/28 20:23:34 martin Exp $ */
3 /*
4 * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _SGIMIPS_BUS_H_
34 #define _SGIMIPS_BUS_H_
36 #include <mips/locore.h>
38 #define __BUS_SPACE_HAS_STREAM_METHODS
41 * Utility macros; do not use outside this file.
43 #define __PB_TYPENAME_PREFIX(BITS) ___CONCAT(u_int,BITS)
44 #define __PB_TYPENAME(BITS) ___CONCAT(__PB_TYPENAME_PREFIX(BITS),_t)
47 * Bus address and size types
49 typedef uint64_t bus_addr_t;
50 typedef uint64_t bus_size_t;
53 * Access methods for bus resources and address space.
55 typedef int bus_space_tag_t;
56 typedef u_long bus_space_handle_t;
59 * Values for sgimips bus space tag, not to be used directly by MI code.
61 #define SGIMIPS_BUS_SPACE_NORMAL 0
62 #define SGIMIPS_BUS_SPACE_IP6_DPCLOCK 1
63 #define SGIMIPS_BUS_SPACE_HPC 2
64 #define SGIMIPS_BUS_SPACE_MEM 3
65 #define SGIMIPS_BUS_SPACE_MACE 4
66 #define SGIMIPS_BUS_SPACE_IO 5
67 #define SGIMIPS_BUS_SPACE_CRIME 6
69 /* Initialization for bus_dmamap_sync, which differs from MIPS1 to MIPS3 */
71 void sgimips_bus_dma_init(void);
74 * int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
75 * bus_size_t size, int flags, bus_space_handle_t *bshp);
77 * Map a region of bus space.
80 #define BUS_SPACE_MAP_CACHEABLE 0x01
81 #define BUS_SPACE_MAP_LINEAR 0x02
82 #define BUS_SPACE_MAP_PREFETCHABLE 0x04
84 int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t,
85 int, bus_space_handle_t *);
87 paddr_t bus_space_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int);
90 * void bus_space_unmap(bus_space_tag_t t,
91 * bus_space_handle_t bsh, bus_size_t size);
93 * Unmap a region of bus space.
96 void bus_space_unmap (bus_space_tag_t, bus_space_handle_t, bus_size_t);
99 * int bus_space_subregion(bus_space_tag_t t,
100 * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
101 * bus_space_handle_t *nbshp);
103 * Get a new handle for a subregion of an already-mapped area of bus space.
106 int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
107 bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
110 * int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart,
111 * bus_addr_t rend, bus_size_t size, bus_size_t align,
112 * bus_size_t boundary, int flags, bus_addr_t *addrp,
113 * bus_space_handle_t *bshp);
115 * Allocate a region of bus space.
118 int bus_space_alloc (bus_space_tag_t t, bus_addr_t rstart,
119 bus_addr_t rend, bus_size_t size, bus_size_t align,
120 bus_size_t boundary, int cacheable, bus_addr_t *addrp,
121 bus_space_handle_t *bshp);
124 * int bus_space_free (bus_space_tag_t t,
125 * bus_space_handle_t bsh, bus_size_t size);
127 * Free a region of bus space.
130 void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
131 bus_size_t size);
134 * Get kernel virtual address of mapped bus space
136 void * bus_space_vaddr(bus_space_tag_t t, bus_space_handle_t bsh);
139 * u_intN_t bus_space_read_N(bus_space_tag_t tag,
140 * bus_space_handle_t bsh, bus_size_t offset);
142 * Read a 1, 2, 4, or 8 byte quantity from bus space
143 * described by tag/handle/offset.
146 u_int8_t bus_space_read_1(bus_space_tag_t, bus_space_handle_t, bus_size_t);
147 u_int16_t bus_space_read_2(bus_space_tag_t, bus_space_handle_t, bus_size_t);
148 u_int32_t bus_space_read_4(bus_space_tag_t, bus_space_handle_t, bus_size_t);
149 u_int64_t bus_space_read_8(bus_space_tag_t, bus_space_handle_t, bus_size_t);
152 * u_intN_t bus_space_read_stream_N(bus_space_tag_t tag,
153 * bus_space_handle_t bsh, bus_size_t offset);
155 * Read a 1, 2, 4, or 8 byte quantity from bus space
156 * described by tag/handle/offset, but w/o any byte order changes.
159 #define bus_space_read_stream_1 bus_space_read_1
160 u_int16_t bus_space_read_stream_2(bus_space_tag_t, bus_space_handle_t,
161 bus_size_t);
162 u_int32_t bus_space_read_stream_4(bus_space_tag_t, bus_space_handle_t,
163 bus_size_t);
164 #if 0
165 #define bus_space_read_stream_8 bus_space_read_stream_8 not implemented!!!
166 #endif
169 * void bus_space_read_multi_N(bus_space_tag_t tag,
170 * bus_space_handle_t bsh, bus_size_t offset,
171 * u_intN_t *addr, size_t count);
173 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
174 * described by tag/handle/offset and copy into buffer provided.
177 #define __SGIMIPS_bus_space_read_multi(BYTES,BITS) \
178 static __inline void __CONCAT(bus_space_read_multi_,BYTES) \
179 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
180 __PB_TYPENAME(BITS) *, size_t); \
182 static __inline void \
183 __CONCAT(bus_space_read_multi_,BYTES)(t, h, o, a, c) \
184 bus_space_tag_t t; \
185 bus_space_handle_t h; \
186 bus_size_t o; \
187 __PB_TYPENAME(BITS) *a; \
188 size_t c; \
191 while (c--) \
192 *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \
195 __SGIMIPS_bus_space_read_multi(1,8)
196 __SGIMIPS_bus_space_read_multi(2,16)
197 __SGIMIPS_bus_space_read_multi(4,32)
199 #if 0 /* Cause a link error for bus_space_read_multi_8 */
200 #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
201 #endif
203 #undef __SGIMIPS_bus_space_read_multi
205 #define __SGIMIPS_bus_space_read_multi_stream(BYTES,BITS) \
206 static __inline void __CONCAT(bus_space_read_multi_stream_,BYTES) \
207 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
208 __PB_TYPENAME(BITS) *, size_t); \
210 static __inline void \
211 __CONCAT(bus_space_read_multi_stream_,BYTES)(t, h, o, a, c) \
212 bus_space_tag_t t; \
213 bus_space_handle_t h; \
214 bus_size_t o; \
215 __PB_TYPENAME(BITS) *a; \
216 size_t c; \
219 while (c--) \
220 *a++ = __CONCAT(bus_space_read_stream_,BYTES)(t, h, o); \
224 #define bus_space_read_multi_stream_1 bus_space_read_multi_1
225 __SGIMIPS_bus_space_read_multi_stream(2,16)
226 __SGIMIPS_bus_space_read_multi_stream(4,32)
228 #if 0
229 #define bus_space_read_multi_stream_8 \
230 bus_space_read_multi_stream_8 not implemented!!!
231 #endif
233 #undef __SGIMIPS_bus_space_read_multi_stream
236 * void bus_space_read_region_N(bus_space_tag_t tag,
237 * bus_space_handle_t bsh, bus_size_t offset,
238 * u_intN_t *addr, size_t count);
240 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
241 * described by tag/handle and starting at `offset' and copy into
242 * buffer provided.
245 #define __SGIMIPS_bus_space_read_region(BYTES,BITS) \
246 static __inline void __CONCAT(bus_space_read_region_,BYTES) \
247 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
248 __PB_TYPENAME(BITS) *, size_t); \
250 static __inline void \
251 __CONCAT(bus_space_read_region_,BYTES)(t, h, o, a, c) \
252 bus_space_tag_t t; \
253 bus_space_handle_t h; \
254 bus_size_t o; \
255 __PB_TYPENAME(BITS) *a; \
256 size_t c; \
259 while (c--) { \
260 *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \
261 o += BYTES; \
265 __SGIMIPS_bus_space_read_region(1,8)
266 __SGIMIPS_bus_space_read_region(2,16)
267 __SGIMIPS_bus_space_read_region(4,32)
269 #if 0 /* Cause a link error for bus_space_read_region_8 */
270 #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
271 #endif
273 #undef __SGIMIPS_bus_space_read_region
276 * void bus_space_read_region_stream_N(bus_space_tag_t tag,
277 * bus_space_handle_t bsh, bus_size_t offset,
278 * u_intN_t *addr, size_t count);
280 * Read `count' 1, 2, 4, or 8 byte quantities from bus space
281 * described by tag/handle and starting at `offset' and copy into
282 * buffer provided. No byte order translation is done.
285 #define __SGIMIPS_bus_space_read_region_stream(BYTES,BITS) \
286 static __inline void __CONCAT(bus_space_read_region_stream_,BYTES) \
287 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
288 __PB_TYPENAME(BITS) *, size_t); \
290 static __inline void \
291 __CONCAT(bus_space_read_region_stream_,BYTES)(t, h, o, a, c) \
292 bus_space_tag_t t; \
293 bus_space_handle_t h; \
294 bus_size_t o; \
295 __PB_TYPENAME(BITS) *a; \
296 size_t c; \
299 while (c--) { \
300 *a++ = __CONCAT(bus_space_read_stream_,BYTES)(t, h, o); \
301 o += BYTES; \
305 #define bus_space_read_reigion_stream_1 bus_space_read_reigion_1
306 __SGIMIPS_bus_space_read_region_stream(2,16)
307 __SGIMIPS_bus_space_read_region_stream(4,32)
309 #if 0 /* Cause a link error for bus_space_read_region_stream_8 */
310 #define bus_space_read_region_stream_8 \
311 !!! bus_space_read_region_stream_8 unimplemented !!!
312 #endif
314 #undef __SGIMIPS_bus_space_read_region_stream
317 * void bus_space_write_N(bus_space_tag_t tag,
318 * bus_space_handle_t bsh, bus_size_t offset,
319 * u_intN_t value);
321 * Write the 1, 2, 4, or 8 byte value `value' to bus space
322 * described by tag/handle/offset.
325 void bus_space_write_1(bus_space_tag_t, bus_space_handle_t, bus_size_t,
326 u_int8_t);
327 void bus_space_write_2(bus_space_tag_t, bus_space_handle_t, bus_size_t,
328 u_int16_t);
329 void bus_space_write_4(bus_space_tag_t, bus_space_handle_t, bus_size_t,
330 u_int32_t);
331 void bus_space_write_8(bus_space_tag_t, bus_space_handle_t, bus_size_t,
332 u_int64_t);
335 * void bus_space_write_stream_N(bus_space_tag_t tag,
336 * bus_space_handle_t bsh, bus_size_t offset,
337 * u_intN_t value);
339 * Write the 1, 2, 4, or 8 byte value `value' to bus space
340 * described by tag/handle/offset. Do not adjust byte order.
343 #define bus_space_write_stream_1 bus_space_write_1
344 void bus_space_write_stream_2(bus_space_tag_t, bus_space_handle_t,
345 bus_size_t, u_int16_t);
346 void bus_space_write_stream_4(bus_space_tag_t, bus_space_handle_t,
347 bus_size_t, u_int32_t);
349 #if 0
350 #define bus_space_write_stream_8 bus_space_write_stream_8 not implemented!!!
351 #endif
354 * void bus_space_write_multi_N(bus_space_tag_t tag,
355 * bus_space_handle_t bsh, bus_size_t offset,
356 * const u_intN_t *addr, size_t count);
358 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
359 * provided to bus space described by tag/handle/offset.
362 #define __SGIMIPS_bus_space_write_multi(BYTES,BITS) \
363 static __inline void __CONCAT(bus_space_write_multi_,BYTES) \
364 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
365 const __PB_TYPENAME(BITS) *, size_t); \
367 static __inline void \
368 __CONCAT(bus_space_write_multi_,BYTES)(t, h, o, a, c) \
369 bus_space_tag_t t; \
370 bus_space_handle_t h; \
371 bus_size_t o; \
372 const __PB_TYPENAME(BITS) *a; \
373 size_t c; \
376 while (c--) \
377 __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \
380 __SGIMIPS_bus_space_write_multi(1,8)
381 __SGIMIPS_bus_space_write_multi(2,16)
382 __SGIMIPS_bus_space_write_multi(4,32)
384 #if 0 /* XXX Use MIPS3 64-bit loads */
385 #define bus_space_write_multi_8(t, h, o, a, c) \
386 !!! bus_space_write_multi_8 unimplimented !!!
387 #endif
389 #undef __SGIMIPS_bus_space_write_multi
391 #define __SGIMIPS_bus_space_write_multi_stream(BYTES,BITS) \
392 static __inline void __CONCAT(bus_space_write_multi_stream_,BYTES) \
393 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
394 const __PB_TYPENAME(BITS) *, size_t); \
396 static __inline void \
397 __CONCAT(bus_space_write_multi_stream_,BYTES)(t, h, o, a, c) \
398 bus_space_tag_t t; \
399 bus_space_handle_t h; \
400 bus_size_t o; \
401 const __PB_TYPENAME(BITS) *a; \
402 size_t c; \
405 while (c--) \
406 __CONCAT(bus_space_write_stream_,BYTES)(t, h, o, *a++); \
409 #define bus_space_write_multi_stream_1 bus_space_write_multi_1
410 __SGIMIPS_bus_space_write_multi_stream(2,16)
411 __SGIMIPS_bus_space_write_multi_stream(4,32)
413 #if 0
414 #define bus_space_write_multi_stream_8 \
415 bus_space_write_multi_stream_8 not implemented!!!
416 #endif
418 #undef __SGIMIPS_bus_space_write_multi_stream
421 * void bus_space_write_region_N(bus_space_tag_t tag,
422 * bus_space_handle_t bsh, bus_size_t offset,
423 * const u_intN_t *addr, size_t count);
425 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
426 * to bus space described by tag/handle starting at `offset'.
429 #define __SGIMIPS_bus_space_write_region(BYTES,BITS) \
430 static __inline void __CONCAT(bus_space_write_region_,BYTES) \
431 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
432 const __PB_TYPENAME(BITS) *, size_t); \
434 static __inline void \
435 __CONCAT(bus_space_write_region_,BYTES)(t, h, o, a, c) \
436 bus_space_tag_t t; \
437 bus_space_handle_t h; \
438 bus_size_t o; \
439 const __PB_TYPENAME(BITS) *a; \
440 size_t c; \
443 while (c--) { \
444 __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \
445 o += BYTES; \
449 __SGIMIPS_bus_space_write_region(1,8)
450 __SGIMIPS_bus_space_write_region(2,16)
451 __SGIMIPS_bus_space_write_region(4,32)
453 #if 0 /* Cause a link error for bus_space_write_region_8 */
454 #define bus_space_write_region_8 \
455 !!! bus_space_write_region_8 unimplemented !!!
456 #endif
458 #undef __SGIMIPS_bus_space_write_region
461 * void bus_space_write_region_stream_N(bus_space_tag_t tag,
462 * bus_space_handle_t bsh, bus_size_t offset,
463 * const u_intN_t *addr, size_t count);
465 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
466 * to bus space described by tag/handle starting at `offset', but without
467 * byte-order translation
470 #define __SGIMIPS_bus_space_write_region_stream(BYTES,BITS) \
471 static __inline void __CONCAT(bus_space_write_region_stream_,BYTES) \
472 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
473 const __PB_TYPENAME(BITS) *, size_t); \
475 static __inline void \
476 __CONCAT(bus_space_write_region_stream_,BYTES)(t, h, o, a, c) \
477 bus_space_tag_t t; \
478 bus_space_handle_t h; \
479 bus_size_t o; \
480 const __PB_TYPENAME(BITS) *a; \
481 size_t c; \
484 while (c--) { \
485 __CONCAT(bus_space_write_stream_,BYTES)(t, h, o, *a++); \
486 o += BYTES; \
490 #define bus_space_write_region_stream_1 bus_space_write_region_1
491 __SGIMIPS_bus_space_write_region_stream(2,16)
492 __SGIMIPS_bus_space_write_region_stream(4,32)
494 #if 0 /* Cause a link error for bus_space_write_region_8 */
495 #define bus_space_write_region_stream_8 \
496 !!! bus_space_write_region_stream_8 unimplemented !!!
497 #endif
499 #undef __SGIMIPS_bus_space_write_region_stream
502 * void bus_space_set_multi_N(bus_space_tag_t tag,
503 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
504 * size_t count);
506 * Write the 1, 2, 4, or 8 byte value `val' to bus space described
507 * by tag/handle/offset `count' times.
510 #define __SGIMIPS_bus_space_set_multi(BYTES,BITS) \
511 static __inline void __CONCAT(bus_space_set_multi_,BYTES) \
512 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
513 __PB_TYPENAME(BITS), size_t); \
515 static __inline void \
516 __CONCAT(bus_space_set_multi_,BYTES)(t, h, o, v, c) \
517 bus_space_tag_t t; \
518 bus_space_handle_t h; \
519 bus_size_t o; \
520 __PB_TYPENAME(BITS) v; \
521 size_t c; \
524 while (c--) \
525 __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \
528 __SGIMIPS_bus_space_set_multi(1,8)
529 __SGIMIPS_bus_space_set_multi(2,16)
530 __SGIMIPS_bus_space_set_multi(4,32)
532 #if 0 /* Cause a link error for bus_space_set_multi_8 */
533 #define bus_space_set_multi_8 \
534 !!! bus_space_set_multi_8 unimplemented !!!
535 #endif
537 #undef __SGIMIPS_bus_space_set_multi
540 * void bus_space_set_region_N(bus_space_tag_t tag,
541 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val,
542 * size_t count);
544 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
545 * by tag/handle starting at `offset'.
548 #define __SGIMIPS_bus_space_set_region(BYTES,BITS) \
549 static __inline void __CONCAT(bus_space_set_region_,BYTES) \
550 (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
551 __PB_TYPENAME(BITS), size_t); \
553 static __inline void \
554 __CONCAT(bus_space_set_region_,BYTES)(t, h, o, v, c) \
555 bus_space_tag_t t; \
556 bus_space_handle_t h; \
557 bus_size_t o; \
558 __PB_TYPENAME(BITS) v; \
559 size_t c; \
562 while (c--) { \
563 __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \
564 o += BYTES; \
568 __SGIMIPS_bus_space_set_region(1,8)
569 __SGIMIPS_bus_space_set_region(2,16)
570 __SGIMIPS_bus_space_set_region(4,32)
572 #if 0 /* Cause a link error for bus_space_set_region_8 */
573 #define bus_space_set_region_8 \
574 !!! bus_space_set_region_8 unimplemented !!!
575 #endif
577 #undef __SGIMIPS_bus_space_set_region
580 * void bus_space_copy_region_N(bus_space_tag_t tag,
581 * bus_space_handle_t bsh1, bus_size_t off1,
582 * bus_space_handle_t bsh2, bus_size_t off2,
583 * bus_size_t count);
585 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
586 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
589 #define __SGIMIPS_copy_region(BYTES) \
590 static __inline void __CONCAT(bus_space_copy_region_,BYTES) \
591 (bus_space_tag_t, \
592 bus_space_handle_t bsh1, bus_size_t off1, \
593 bus_space_handle_t bsh2, bus_size_t off2, \
594 bus_size_t count); \
596 static __inline void \
597 __CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c) \
598 bus_space_tag_t t; \
599 bus_space_handle_t h1, h2; \
600 bus_size_t o1, o2, c; \
602 bus_size_t o; \
604 if ((h1 + o1) >= (h2 + o2)) { \
605 /* src after dest: copy forward */ \
606 for (o = 0; c != 0; c--, o += BYTES) \
607 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
608 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
609 } else { \
610 /* dest after src: copy backwards */ \
611 for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \
612 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
613 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
617 __SGIMIPS_copy_region(1)
618 __SGIMIPS_copy_region(2)
619 __SGIMIPS_copy_region(4)
621 #if 0 /* Cause a link error for bus_space_copy_region_8 */
622 #define bus_space_copy_region_8 \
623 !!! bus_space_copy_region_8 unimplemented !!!
624 #endif
626 #undef __SGIMIPS_copy_region
629 * Bus read/write barrier methods.
631 * void bus_space_barrier(bus_space_tag_t tag,
632 * bus_space_handle_t bsh, bus_size_t offset,
633 * bus_size_t len, int flags);
635 * On the MIPS, we just flush the write buffer.
637 #define bus_space_barrier(t, h, o, l, f) \
638 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f), \
639 wbflush()))
640 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
641 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
643 #undef __PB_TYPENAME_PREFIX
644 #undef __PB_TYPENAME
646 #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
649 * Flags used in various bus DMA methods.
651 #define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
652 #define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
653 #define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
654 #define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
655 #define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
656 #define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
657 #define BUS_DMA_BUS2 0x020
658 #define BUS_DMA_BUS3 0x040
659 #define BUS_DMA_BUS4 0x080
660 #define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
661 #define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
662 #define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
664 #define SGIMIPS_DMAMAP_COHERENT 0x10000 /* no cache flush necessary on sync */
666 /* Forwards needed by prototypes below. */
667 struct mbuf;
668 struct uio;
671 * Operations performed by bus_dmamap_sync().
673 #define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
674 #define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
675 #define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
676 #define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
678 typedef struct sgimips_bus_dma_tag *bus_dma_tag_t;
679 typedef struct sgimips_bus_dmamap *bus_dmamap_t;
681 #define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0)
684 * bus_dma_segment_t
686 * Describes a single contiguous DMA transaction. Values
687 * are suitable for programming into DMA registers.
689 struct sgimips_bus_dma_segment {
690 bus_addr_t ds_addr; /* DMA address */
691 bus_size_t ds_len; /* length of transfer */
692 vaddr_t _ds_vaddr; /* virtual address, 0 if invalid */
694 typedef struct sgimips_bus_dma_segment bus_dma_segment_t;
697 * bus_dma_tag_t
699 * A machine-dependent opaque type describing the implementation of
700 * DMA for a given bus.
703 struct sgimips_bus_dma_tag {
705 * XXX soren O2: 0x40000000
706 * ikke endnu (bus.c)
708 #if 0
709 bus_addr_t _wbase; /* DMA window base */
710 bus_addr_t _wbase_swap; /* DMA window base (byteswapped) */
711 #endif
714 * DMA mapping methods.
716 int (*_dmamap_create)(bus_dma_tag_t, bus_size_t, int,
717 bus_size_t, bus_size_t, int, bus_dmamap_t *);
718 void (*_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t);
719 int (*_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *,
720 bus_size_t, struct proc *, int);
721 int (*_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t,
722 struct mbuf *, int);
723 int (*_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t,
724 struct uio *, int);
725 int (*_dmamap_load_raw)(bus_dma_tag_t, bus_dmamap_t,
726 bus_dma_segment_t *, int, bus_size_t, int);
727 void (*_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t);
728 void (*_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t,
729 bus_addr_t, bus_size_t, int);
732 * DMA memory utility functions.
734 int (*_dmamem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t,
735 bus_size_t, bus_dma_segment_t *, int, int *, int);
736 void (*_dmamem_free)(bus_dma_tag_t,
737 bus_dma_segment_t *, int);
738 int (*_dmamem_map)(bus_dma_tag_t, bus_dma_segment_t *,
739 int, size_t, void **, int);
740 void (*_dmamem_unmap)(bus_dma_tag_t, void *, size_t);
741 paddr_t (*_dmamem_mmap)(bus_dma_tag_t, bus_dma_segment_t *,
742 int, off_t, int, int);
745 #define bus_dmamap_create(t, s, n, m, b, f, p) \
746 (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
747 #define bus_dmamap_destroy(t, p) \
748 (*(t)->_dmamap_destroy)((t), (p))
749 #define bus_dmamap_load(t, m, b, s, p, f) \
750 (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
751 #define bus_dmamap_load_mbuf(t, m, b, f) \
752 (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
753 #define bus_dmamap_load_uio(t, m, u, f) \
754 (*(t)->_dmamap_load_uio)((t), (m), (u), (f))
755 #define bus_dmamap_load_raw(t, m, sg, n, s, f) \
756 (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
757 #define bus_dmamap_unload(t, p) \
758 (*(t)->_dmamap_unload)((t), (p))
759 #define bus_dmamap_sync(t, p, o, l, ops) \
760 (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops))
762 #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
763 (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
764 #define bus_dmamem_free(t, sg, n) \
765 (*(t)->_dmamem_free)((t), (sg), (n))
766 #define bus_dmamem_map(t, sg, n, s, k, f) \
767 (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
768 #define bus_dmamem_unmap(t, k, s) \
769 (*(t)->_dmamem_unmap)((t), (k), (s))
770 #define bus_dmamem_mmap(t, sg, n, o, p, f) \
771 (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
773 #define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP
774 #define bus_dmatag_destroy(t)
777 * bus_dmamap_t
779 * Describes a DMA mapping.
781 struct sgimips_bus_dmamap {
783 * PRIVATE MEMBERS: not for use my machine-independent code.
785 bus_size_t _dm_size; /* largest DMA transfer mappable */
786 int _dm_segcnt; /* number of segs this map can map */
787 bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
788 bus_size_t _dm_boundary; /* don't cross this */
789 int _dm_flags; /* misc. flags */
790 struct vmspace *_dm_vmspace; /* vmspace that owns the mapping */
793 * PUBLIC MEMBERS: these are used by machine-independent code.
795 bus_size_t dm_maxsegsz; /* largest possible segment */
796 bus_size_t dm_mapsize; /* size of the mapping */
797 int dm_nsegs; /* # valid segments in mapping */
798 bus_dma_segment_t dm_segs[1]; /* segments; variable length */
801 #ifdef _SGIMIPS_BUS_DMA_PRIVATE
803 int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
804 bus_size_t, int, bus_dmamap_t *);
805 void _bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
806 int _bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
807 bus_size_t, struct proc *, int);
808 int _bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
809 struct mbuf *, int);
810 int _bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t,
811 struct uio *, int);
812 int _bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
813 bus_dma_segment_t *, int, bus_size_t, int);
814 void _bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
815 void _bus_dmamap_sync_mips1(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
816 bus_size_t, int);
817 void _bus_dmamap_sync_mips3(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
818 bus_size_t, int);
820 int _bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size,
821 bus_size_t alignment, bus_size_t boundary,
822 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
823 void _bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs,
824 int nsegs);
825 int _bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs,
826 int nsegs, size_t size, void **kvap, int flags);
827 void _bus_dmamem_unmap(bus_dma_tag_t tag, void *kva,
828 size_t size);
829 paddr_t _bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs,
830 int nsegs, off_t off, int prot, int flags);
832 int _bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size,
833 bus_size_t alignment, bus_size_t boundary,
834 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
835 vaddr_t low, vaddr_t high);
837 extern struct sgimips_bus_dma_tag sgimips_default_bus_dma_tag;
838 #endif /* _SGIMIPS_BUS_DMA_PRIVATE */
840 #endif /* _SGIMIPS_BUS_H_ */