Annotation of src/sys/arch/newsmips/include/bus.h, Revision 1.19.38.1
1.19.38.1! mrg 1: /* $NetBSD: bus.h,v 1.20 2012/02/12 16:34:10 matt Exp $ */
1.1 onoe 2:
3: /*
1.3 thorpej 4: * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
1.1 onoe 5: * All rights reserved.
6: *
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.
10: *
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.
19: *
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.
31: */
32:
33: #ifndef _NEWSMIPS_BUS_H_
34: #define _NEWSMIPS_BUS_H_
35:
36: #include <mips/locore.h>
37:
38: /*
39: * Utility macros; do not use outside this file.
40: */
1.10 tsutsui 41: #define __PB_TYPENAME_PREFIX(BITS) ___CONCAT(uint,BITS)
1.1 onoe 42: #define __PB_TYPENAME(BITS) ___CONCAT(__PB_TYPENAME_PREFIX(BITS),_t)
43:
44: /*
45: * Bus address and size types
46: */
47: typedef u_long bus_addr_t;
48: typedef u_long bus_size_t;
49:
50: /*
51: * Access methods for bus resources and address space.
52: */
53: typedef int bus_space_tag_t;
54: typedef u_long bus_space_handle_t;
55:
56: /*
57: * int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
58: * bus_size_t size, int flags, bus_space_handle_t *bshp);
59: *
60: * Map a region of bus space.
61: */
62:
63: #define BUS_SPACE_MAP_CACHEABLE 0x01
64: #define BUS_SPACE_MAP_LINEAR 0x02
65: #define BUS_SPACE_MAP_PREFETCHABLE 0x04
66:
67: int bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t,
68: int, bus_space_handle_t *);
69:
70: /*
71: * void bus_space_unmap(bus_space_tag_t t,
72: * bus_space_handle_t bsh, bus_size_t size);
73: *
74: * Unmap a region of bus space.
75: */
76:
77: void bus_space_unmap (bus_space_tag_t, bus_space_handle_t, bus_size_t);
78:
79: /*
80: * int bus_space_subregion(bus_space_tag_t t,
81: * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
82: * bus_space_handle_t *nbshp);
83: *
84: * Get a new handle for a subregion of an already-mapped area of bus space.
85: */
86:
87: int bus_space_subregion(bus_space_tag_t t, bus_space_handle_t bsh,
88: bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp);
89:
90: /*
91: * int bus_space_alloc(bus_space_tag_t t, bus_addr_t, rstart,
92: * bus_addr_t rend, bus_size_t size, bus_size_t align,
93: * bus_size_t boundary, int flags, bus_addr_t *addrp,
94: * bus_space_handle_t *bshp);
95: *
96: * Allocate a region of bus space.
97: */
98:
99: int bus_space_alloc (bus_space_tag_t t, bus_addr_t rstart,
100: bus_addr_t rend, bus_size_t size, bus_size_t align,
101: bus_size_t boundary, int cacheable, bus_addr_t *addrp,
102: bus_space_handle_t *bshp);
103:
104: /*
105: * int bus_space_free (bus_space_tag_t t,
106: * bus_space_handle_t bsh, bus_size_t size);
107: *
108: * Free a region of bus space.
109: */
110:
111: void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
112: bus_size_t size);
113:
114: /*
1.9 tsutsui 115: * uintN_t bus_space_read_N(bus_space_tag_t tag,
1.1 onoe 116: * bus_space_handle_t bsh, bus_size_t offset);
117: *
118: * Read a 1, 2, 4, or 8 byte quantity from bus space
119: * described by tag/handle/offset.
120: */
121:
122: #define bus_space_read_1(t, h, o) \
1.9 tsutsui 123: ((void) t, (*(volatile uint8_t *)((h) + (o))))
1.1 onoe 124:
125: #define bus_space_read_2(t, h, o) \
1.9 tsutsui 126: ((void) t, (*(volatile uint16_t *)((h) + (o))))
1.1 onoe 127:
128: #define bus_space_read_4(t, h, o) \
1.9 tsutsui 129: ((void) t, (*(volatile uint32_t *)((h) + (o))))
1.1 onoe 130:
131: #if 0 /* Cause a link error for bus_space_read_8 */
132: #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
133: #endif
134:
135: /*
136: * void bus_space_read_multi_N(bus_space_tag_t tag,
137: * bus_space_handle_t bsh, bus_size_t offset,
1.9 tsutsui 138: * uintN_t *addr, size_t count);
1.1 onoe 139: *
140: * Read `count' 1, 2, 4, or 8 byte quantities from bus space
141: * described by tag/handle/offset and copy into buffer provided.
142: */
143:
144: #define __NEWSMIPS_bus_space_read_multi(BYTES,BITS) \
1.14 perry 145: static __inline void __CONCAT(bus_space_read_multi_,BYTES) \
1.1 onoe 146: (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
147: __PB_TYPENAME(BITS) *, size_t); \
148: \
1.14 perry 149: static __inline void \
1.19.38.1! mrg 150: __CONCAT(bus_space_read_multi_,BYTES)( \
! 151: bus_space_tag_t t, \
! 152: bus_space_handle_t h, \
! 153: bus_size_t o, \
! 154: __PB_TYPENAME(BITS) *a, \
! 155: size_t c) \
1.1 onoe 156: { \
157: \
158: while (c--) \
159: *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \
160: }
161:
162: __NEWSMIPS_bus_space_read_multi(1,8)
163: __NEWSMIPS_bus_space_read_multi(2,16)
164: __NEWSMIPS_bus_space_read_multi(4,32)
165:
166: #if 0 /* Cause a link error for bus_space_read_multi_8 */
167: #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
168: #endif
169:
170: #undef __NEWSMIPS_bus_space_read_multi
171:
172: /*
173: * void bus_space_read_region_N(bus_space_tag_t tag,
174: * bus_space_handle_t bsh, bus_size_t offset,
1.9 tsutsui 175: * uintN_t *addr, size_t count);
1.1 onoe 176: *
177: * Read `count' 1, 2, 4, or 8 byte quantities from bus space
178: * described by tag/handle and starting at `offset' and copy into
179: * buffer provided.
180: */
181:
182: #define __NEWSMIPS_bus_space_read_region(BYTES,BITS) \
1.14 perry 183: static __inline void __CONCAT(bus_space_read_region_,BYTES) \
1.1 onoe 184: (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
185: __PB_TYPENAME(BITS) *, size_t); \
186: \
1.14 perry 187: static __inline void \
1.19.38.1! mrg 188: __CONCAT(bus_space_read_region_,BYTES)( \
! 189: bus_space_tag_t t, \
! 190: bus_space_handle_t h, \
! 191: bus_size_t o, \
! 192: __PB_TYPENAME(BITS) *a, \
! 193: size_t c) \
1.1 onoe 194: { \
195: \
196: while (c--) { \
197: *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \
198: o += BYTES; \
199: } \
200: }
201:
202: __NEWSMIPS_bus_space_read_region(1,8)
203: __NEWSMIPS_bus_space_read_region(2,16)
204: __NEWSMIPS_bus_space_read_region(4,32)
205:
206: #if 0 /* Cause a link error for bus_space_read_region_8 */
207: #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
208: #endif
209:
210: #undef __NEWSMIPS_bus_space_read_region
211:
212: /*
213: * void bus_space_write_N(bus_space_tag_t tag,
214: * bus_space_handle_t bsh, bus_size_t offset,
1.9 tsutsui 215: * uintN_t value);
1.1 onoe 216: *
217: * Write the 1, 2, 4, or 8 byte value `value' to bus space
218: * described by tag/handle/offset.
219: */
220:
221: #define bus_space_write_1(t, h, o, v) \
222: do { \
223: (void) t; \
1.9 tsutsui 224: *(volatile uint8_t *)((h) + (o)) = (v); \
1.1 onoe 225: } while (0)
226:
227: #define bus_space_write_2(t, h, o, v) \
228: do { \
229: (void) t; \
1.9 tsutsui 230: *(volatile uint16_t *)((h) + (o)) = (v); \
1.1 onoe 231: } while (0)
232:
233: #define bus_space_write_4(t, h, o, v) \
234: do { \
235: (void) t; \
1.9 tsutsui 236: *(volatile uint32_t *)((h) + (o)) = (v); \
1.1 onoe 237: } while (0)
238:
239: #if 0 /* Cause a link error for bus_space_write_8 */
240: #define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
241: #endif
242:
243: /*
244: * void bus_space_write_multi_N(bus_space_tag_t tag,
245: * bus_space_handle_t bsh, bus_size_t offset,
1.9 tsutsui 246: * const uintN_t *addr, size_t count);
1.1 onoe 247: *
248: * Write `count' 1, 2, 4, or 8 byte quantities from the buffer
249: * provided to bus space described by tag/handle/offset.
250: */
251:
252: #define __NEWSMIPS_bus_space_write_multi(BYTES,BITS) \
1.14 perry 253: static __inline void __CONCAT(bus_space_write_multi_,BYTES) \
1.1 onoe 254: (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
255: const __PB_TYPENAME(BITS) *, size_t); \
256: \
1.14 perry 257: static __inline void \
1.19.38.1! mrg 258: __CONCAT(bus_space_write_multi_,BYTES)( \
! 259: bus_space_tag_t t, \
! 260: bus_space_handle_t h, \
! 261: bus_size_t o, \
! 262: const __PB_TYPENAME(BITS) *a, \
! 263: size_t c) \
1.1 onoe 264: { \
265: \
266: while (c--) \
267: __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \
268: }
269:
270: __NEWSMIPS_bus_space_write_multi(1,8)
271: __NEWSMIPS_bus_space_write_multi(2,16)
272: __NEWSMIPS_bus_space_write_multi(4,32)
273:
274: #if 0 /* Cause a link error for bus_space_write_8 */
275: #define bus_space_write_multi_8(t, h, o, a, c) \
276: !!! bus_space_write_multi_8 unimplimented !!!
277: #endif
278:
279: #undef __NEWSMIPS_bus_space_write_multi
280:
281: /*
282: * void bus_space_write_region_N(bus_space_tag_t tag,
283: * bus_space_handle_t bsh, bus_size_t offset,
1.9 tsutsui 284: * const uintN_t *addr, size_t count);
1.1 onoe 285: *
286: * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided
287: * to bus space described by tag/handle starting at `offset'.
288: */
289:
290: #define __NEWSMIPS_bus_space_write_region(BYTES,BITS) \
1.14 perry 291: static __inline void __CONCAT(bus_space_write_region_,BYTES) \
1.1 onoe 292: (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
293: const __PB_TYPENAME(BITS) *, size_t); \
294: \
1.14 perry 295: static __inline void \
1.19.38.1! mrg 296: __CONCAT(bus_space_write_region_,BYTES)( \
! 297: bus_space_tag_t t, \
! 298: bus_space_handle_t h, \
! 299: bus_size_t o, \
! 300: const __PB_TYPENAME(BITS) *a, \
! 301: size_t c) \
1.1 onoe 302: { \
303: \
304: while (c--) { \
305: __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \
306: o += BYTES; \
307: } \
308: }
309:
310: __NEWSMIPS_bus_space_write_region(1,8)
311: __NEWSMIPS_bus_space_write_region(2,16)
312: __NEWSMIPS_bus_space_write_region(4,32)
313:
314: #if 0 /* Cause a link error for bus_space_write_region_8 */
315: #define bus_space_write_region_8 \
316: !!! bus_space_write_region_8 unimplemented !!!
317: #endif
318:
319: #undef __NEWSMIPS_bus_space_write_region
320:
321: /*
322: * void bus_space_set_multi_N(bus_space_tag_t tag,
1.9 tsutsui 323: * bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
1.1 onoe 324: * size_t count);
325: *
326: * Write the 1, 2, 4, or 8 byte value `val' to bus space described
327: * by tag/handle/offset `count' times.
328: */
329:
330: #define __NEWSMIPS_bus_space_set_multi(BYTES,BITS) \
1.14 perry 331: static __inline void __CONCAT(bus_space_set_multi_,BYTES) \
1.1 onoe 332: (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
333: __PB_TYPENAME(BITS), size_t); \
334: \
1.14 perry 335: static __inline void \
1.19.38.1! mrg 336: __CONCAT(bus_space_set_multi_,BYTES)( \
! 337: bus_space_tag_t t, \
! 338: bus_space_handle_t h, \
! 339: bus_size_t o, \
! 340: __PB_TYPENAME(BITS) v, \
! 341: size_t c) \
1.1 onoe 342: { \
343: \
344: while (c--) \
345: __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \
346: }
347:
348: __NEWSMIPS_bus_space_set_multi(1,8)
349: __NEWSMIPS_bus_space_set_multi(2,16)
350: __NEWSMIPS_bus_space_set_multi(4,32)
351:
352: #if 0 /* Cause a link error for bus_space_set_multi_8 */
353: #define bus_space_set_multi_8 \
354: !!! bus_space_set_multi_8 unimplemented !!!
355: #endif
356:
357: #undef __NEWSMIPS_bus_space_set_multi
358:
359: /*
360: * void bus_space_set_region_N(bus_space_tag_t tag,
1.9 tsutsui 361: * bus_space_handle_t bsh, bus_size_t offset, uintN_t val,
1.1 onoe 362: * size_t count);
363: *
364: * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described
365: * by tag/handle starting at `offset'.
366: */
367:
368: #define __NEWSMIPS_bus_space_set_region(BYTES,BITS) \
1.14 perry 369: static __inline void __CONCAT(bus_space_set_region_,BYTES) \
1.1 onoe 370: (bus_space_tag_t, bus_space_handle_t, bus_size_t, \
371: __PB_TYPENAME(BITS), size_t); \
372: \
1.14 perry 373: static __inline void \
1.19.38.1! mrg 374: __CONCAT(bus_space_set_region_,BYTES)( \
! 375: bus_space_tag_t t, \
! 376: bus_space_handle_t h, \
! 377: bus_size_t o, \
! 378: __PB_TYPENAME(BITS) v, \
! 379: size_t c) \
1.1 onoe 380: { \
381: \
382: while (c--) { \
383: __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \
384: o += BYTES; \
385: } \
386: }
387:
388: __NEWSMIPS_bus_space_set_region(1,8)
389: __NEWSMIPS_bus_space_set_region(2,16)
390: __NEWSMIPS_bus_space_set_region(4,32)
391:
392: #if 0 /* Cause a link error for bus_space_set_region_8 */
393: #define bus_space_set_region_8 \
394: !!! bus_space_set_region_8 unimplemented !!!
395: #endif
396:
397: #undef __NEWSMIPS_bus_space_set_region
398:
399: /*
400: * void bus_space_copy_region_N(bus_space_tag_t tag,
401: * bus_space_handle_t bsh1, bus_size_t off1,
402: * bus_space_handle_t bsh2, bus_size_t off2,
403: * bus_size_t count);
404: *
405: * Copy `count' 1, 2, 4, or 8 byte values from bus space starting
406: * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2.
407: */
408:
409: #define __NEWSMIPS_copy_region(BYTES) \
1.14 perry 410: static __inline void __CONCAT(bus_space_copy_region_,BYTES) \
1.1 onoe 411: (bus_space_tag_t, \
412: bus_space_handle_t bsh1, bus_size_t off1, \
413: bus_space_handle_t bsh2, bus_size_t off2, \
414: bus_size_t count); \
415: \
1.14 perry 416: static __inline void \
1.19.38.1! mrg 417: __CONCAT(bus_space_copy_region_,BYTES)( \
! 418: bus_space_tag_t t, \
! 419: bus_space_handle_t h1, \
! 420: bus_size_t o1, \
! 421: bus_space_handle_t h2, \
! 422: bus_size_t o2, \
! 423: bus_size_t c) \
1.1 onoe 424: { \
425: bus_size_t o; \
426: \
427: if ((h1 + o1) >= (h2 + o2)) { \
428: /* src after dest: copy forward */ \
429: for (o = 0; c != 0; c--, o += BYTES) \
430: __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
431: __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
432: } else { \
433: /* dest after src: copy backwards */ \
434: for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \
435: __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \
436: __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \
437: } \
438: }
439:
440: __NEWSMIPS_copy_region(1)
441: __NEWSMIPS_copy_region(2)
442: __NEWSMIPS_copy_region(4)
443:
444: #if 0 /* Cause a link error for bus_space_copy_region_8 */
445: #define bus_space_copy_region_8 \
446: !!! bus_space_copy_region_8 unimplemented !!!
447: #endif
448:
449: #undef __NEWSMIPS_copy_region
450:
451: /*
452: * Bus read/write barrier methods.
453: *
454: * void bus_space_barrier(bus_space_tag_t tag,
455: * bus_space_handle_t bsh, bus_size_t offset,
456: * bus_size_t len, int flags);
457: *
458: * On the MIPS, we just flush the write buffer.
459: */
460: #define bus_space_barrier(t, h, o, l, f) \
1.16 tsutsui 461: ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f), \
462: wbflush()))
1.1 onoe 463: #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
464: #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
465:
466: #undef __PB_TYPENAME_PREFIX
467: #undef __PB_TYPENAME
468:
469: #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t)
470:
471: /*
472: * Flags used in various bus DMA methods.
473: */
1.4 thorpej 474: #define BUS_DMA_WAITOK 0x000 /* safe to sleep (pseudo-flag) */
475: #define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
476: #define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
477: #define BUS_DMA_COHERENT 0x004 /* hint: map memory DMA coherent */
478: #define BUS_DMA_STREAMING 0x008 /* hint: sequential, unidirectional */
479: #define BUS_DMA_BUS1 0x010 /* placeholders for bus functions... */
480: #define BUS_DMA_BUS2 0x020
481: #define BUS_DMA_BUS3 0x040
482: #define BUS_DMA_BUS4 0x080
483: #define BUS_DMA_READ 0x100 /* mapping is device -> memory only */
484: #define BUS_DMA_WRITE 0x200 /* mapping is memory -> device only */
1.7 kent 485: #define BUS_DMA_NOCACHE 0x400 /* hint: map non-cached memory */
1.1 onoe 486:
1.6 simonb 487: #define NEWSMIPS_DMAMAP_COHERENT 0x10000 /* no cache flush necessary on sync */
488: #define NEWSMIPS_DMAMAP_MAPTBL 0x20000 /* use DMA maping table */
1.1 onoe 489:
490: /* Forwards needed by prototypes below. */
491: struct mbuf;
492: struct uio;
493:
494: /*
495: * Operations performed by bus_dmamap_sync().
496: */
497: #define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
498: #define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
499: #define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
500: #define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
501:
502: typedef struct newsmips_bus_dma_tag *bus_dma_tag_t;
503: typedef struct newsmips_bus_dmamap *bus_dmamap_t;
1.8 fvdl 504:
505: #define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0)
1.1 onoe 506:
507: /*
508: * bus_dma_segment_t
509: *
510: * Describes a single contiguous DMA transaction. Values
511: * are suitable for programming into DMA registers.
512: */
513: struct newsmips_bus_dma_segment {
514: bus_addr_t ds_addr; /* DMA address */
515: bus_size_t ds_len; /* length of transfer */
516: bus_addr_t _ds_vaddr; /* virtual address, 0 if invalid */
517: };
518: typedef struct newsmips_bus_dma_segment bus_dma_segment_t;
519:
520: /*
521: * bus_dma_tag_t
522: *
523: * A machine-dependent opaque type describing the implementation of
524: * DMA for a given bus.
525: */
526:
527: struct newsmips_bus_dma_tag {
528: /*
529: * DMA mapping methods.
530: */
531: int (*_dmamap_create)(bus_dma_tag_t, bus_size_t, int,
532: bus_size_t, bus_size_t, int, bus_dmamap_t *);
533: void (*_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t);
534: int (*_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *,
535: bus_size_t, struct proc *, int);
536: int (*_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t,
537: struct mbuf *, int);
538: int (*_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t,
539: struct uio *, int);
540: int (*_dmamap_load_raw)(bus_dma_tag_t, bus_dmamap_t,
541: bus_dma_segment_t *, int, bus_size_t, int);
542: void (*_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t);
543: void (*_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t,
544: bus_addr_t, bus_size_t, int);
545:
546: /*
547: * DMA memory utility functions.
548: */
549: int (*_dmamem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t,
550: bus_size_t, bus_dma_segment_t *, int, int *, int);
551: void (*_dmamem_free)(bus_dma_tag_t,
552: bus_dma_segment_t *, int);
553: int (*_dmamem_map)(bus_dma_tag_t, bus_dma_segment_t *,
1.18 christos 554: int, size_t, void **, int);
555: void (*_dmamem_unmap)(bus_dma_tag_t, void *, size_t);
1.1 onoe 556: paddr_t (*_dmamem_mmap)(bus_dma_tag_t, bus_dma_segment_t *,
557: int, off_t, int, int);
558:
559: /*
560: * NEWSMIPS quirks.
561: * This is NOT a constant. Slot dependent information is
562: * required to flush DMA cache correctly.
563: */
564: int _slotno;
565: bus_space_tag_t _slotbaset;
566: bus_space_handle_t _slotbaseh;
567: };
568:
569: #define bus_dmamap_create(t, s, n, m, b, f, p) \
570: (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
571: #define bus_dmamap_destroy(t, p) \
572: (*(t)->_dmamap_destroy)((t), (p))
573: #define bus_dmamap_load(t, m, b, s, p, f) \
574: (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
575: #define bus_dmamap_load_mbuf(t, m, b, f) \
576: (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
577: #define bus_dmamap_load_uio(t, m, u, f) \
578: (*(t)->_dmamap_load_uio)((t), (m), (u), (f))
579: #define bus_dmamap_load_raw(t, m, sg, n, s, f) \
580: (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
581: #define bus_dmamap_unload(t, p) \
582: (*(t)->_dmamap_unload)((t), (p))
583: #define bus_dmamap_sync(t, p, o, l, ops) \
584: (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops))
585:
586: #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
587: (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
588: #define bus_dmamem_free(t, sg, n) \
589: (*(t)->_dmamem_free)((t), (sg), (n))
590: #define bus_dmamem_map(t, sg, n, s, k, f) \
591: (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
592: #define bus_dmamem_unmap(t, k, s) \
593: (*(t)->_dmamem_unmap)((t), (k), (s))
594: #define bus_dmamem_mmap(t, sg, n, o, p, f) \
595: (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
596:
1.17 mrg 597: #define bus_dmatag_subregion(t, mna, mxa, nt, f) EOPNOTSUPP
598: #define bus_dmatag_destroy(t)
599:
1.1 onoe 600: /*
601: * bus_dmamap_t
602: *
603: * Describes a DMA mapping.
604: */
605: struct newsmips_bus_dmamap {
606: /*
607: * PRIVATE MEMBERS: not for use my machine-independent code.
608: */
609: bus_size_t _dm_size; /* largest DMA transfer mappable */
610: int _dm_segcnt; /* number of segs this map can map */
1.11 matt 611: bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */
1.1 onoe 612: bus_size_t _dm_boundary; /* don't cross this */
613: int _dm_flags; /* misc. flags */
1.2 onoe 614: int _dm_maptbl; /* DMA mapping table index */
615: int _dm_maptblcnt; /* number of DMA mapping table */
1.15 yamt 616: struct vmspace *_dm_vmspace; /* vmspace that owns the mapping */
1.1 onoe 617:
618: /*
619: * PUBLIC MEMBERS: these are used by machine-independent code.
620: */
1.11 matt 621: bus_size_t dm_maxsegsz; /* largest possible segment */
1.1 onoe 622: bus_size_t dm_mapsize; /* size of the mapping */
623: int dm_nsegs; /* # valid segments in mapping */
624: bus_dma_segment_t dm_segs[1]; /* segments; variable length */
625: };
626:
627: #ifdef _NEWSMIPS_BUS_DMA_PRIVATE
1.5 thorpej 628: void newsmips_bus_dma_init(void);
629:
1.1 onoe 630: int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
631: bus_size_t, int, bus_dmamap_t *);
632: void _bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
633: int _bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
634: bus_size_t, struct proc *, int);
635: int _bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
636: struct mbuf *, int);
637: int _bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t,
638: struct uio *, int);
639: int _bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
640: bus_dma_segment_t *, int, bus_size_t, int);
641: void _bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
1.5 thorpej 642: void _bus_dmamap_sync_r3k(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
643: bus_size_t, int);
644: void _bus_dmamap_sync_r4k(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
1.1 onoe 645: bus_size_t, int);
646:
647: int _bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size,
648: bus_size_t alignment, bus_size_t boundary,
649: bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
650: void _bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs,
651: int nsegs);
652: int _bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs,
1.18 christos 653: int nsegs, size_t size, void **kvap, int flags);
654: void _bus_dmamem_unmap(bus_dma_tag_t tag, void *kva,
1.1 onoe 655: size_t size);
656: paddr_t _bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs,
657: int nsegs, off_t off, int prot, int flags);
658:
659: int _bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size,
660: bus_size_t alignment, bus_size_t boundary,
661: bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
662: vaddr_t low, vaddr_t high);
663:
664: extern struct newsmips_bus_dma_tag newsmips_default_bus_dma_tag;
665: #endif /* _NEWSMIPS_BUS_DMA_PRIVATE */
666:
667: #endif /* _NEWSMIPS_BUS_H_ */
CVSweb <webmaster@jp.NetBSD.org>