1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 #ifndef _I386_BUS_H_
74 #define _I386_BUS_H_
75
76 #include <machine/pio.h>
77
78
79
80
81 #define I386_BUS_SPACE_IO 0
82 #define I386_BUS_SPACE_MEM 1
83
84
85
86
87 typedef u_long bus_addr_t;
88 typedef u_long bus_size_t;
89
90
91
92
93 typedef int bus_space_tag_t;
94 typedef u_long bus_space_handle_t;
95
96 int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
97 bus_size_t size, int cacheable, bus_space_handle_t *bshp);
98
99 int _bus_space_map(bus_space_tag_t t, bus_addr_t addr,
100 bus_size_t size, int cacheable, bus_space_handle_t *bshp);
101 void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
102 bus_size_t size);
103
104 void _bus_space_unmap(bus_space_tag_t, bus_space_handle_t,
105 bus_size_t, bus_addr_t *);
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);
108
109 int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
110 bus_addr_t rend, bus_size_t size, bus_size_t align,
111 bus_size_t boundary, int cacheable, bus_addr_t *addrp,
112 bus_space_handle_t *bshp);
113 void bus_space_free(bus_space_tag_t t, bus_space_handle_t bsh,
114 bus_size_t size);
115
116
117
118
119
120
121
122
123
124 #define bus_space_read_1(t, h, o) \
125 ((t) == I386_BUS_SPACE_IO ? (inb((h) + (o))) : \
126 (*(volatile u_int8_t *)((h) + (o))))
127
128 #define bus_space_read_2(t, h, o) \
129 ((t) == I386_BUS_SPACE_IO ? (inw((h) + (o))) : \
130 (*(volatile u_int16_t *)((h) + (o))))
131
132 #define bus_space_read_4(t, h, o) \
133 ((t) == I386_BUS_SPACE_IO ? (inl((h) + (o))) : \
134 (*(volatile u_int32_t *)((h) + (o))))
135
136 #if 0
137 #define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
138 #endif
139
140
141
142
143
144
145
146
147
148
149 #define bus_space_read_multi_1(t, h, o, a, cnt) do { \
150 if ((t) == I386_BUS_SPACE_IO) { \
151 insb((h) + (o), (a), (cnt)); \
152 } else {void *_addr=(a); int _cnt=(cnt); \
153 __asm __volatile(" \
154 cld ; \
155 1: movb (%2),%%al ; \
156 stosb ; \
157 loop 1b" : \
158 "+D" (_addr), "+c" (_cnt) : "r" ((h) + (o)) : \
159 "%eax", "memory", "cc"); \
160 } \
161 } while (0)
162
163 #define bus_space_read_multi_2(t, h, o, a, cnt) do { \
164 if ((t) == I386_BUS_SPACE_IO) { \
165 insw((h) + (o), (a), (cnt)); \
166 } else {void *_addr=(a); int _cnt=(cnt); \
167 __asm __volatile(" \
168 cld ; \
169 1: movw (%2),%%ax ; \
170 stosw ; \
171 loop 1b" : \
172 "+D" (_addr), "+c" (_cnt) : "r" ((h) + (o)) : \
173 "%eax", "memory", "cc"); \
174 } \
175 } while (0)
176
177 #define bus_space_read_multi_4(t, h, o, a, cnt) do { \
178 if ((t) == I386_BUS_SPACE_IO) { \
179 insl((h) + (o), (a), (cnt)); \
180 } else {void *_addr=(a); int _cnt=(cnt); \
181 __asm __volatile(" \
182 cld ; \
183 1: movl (%2),%%eax ; \
184 stosl ; \
185 loop 1b" : \
186 "+D" (_addr), "+c" (_cnt) : "r" ((h) + (o)) : \
187 "%eax", "memory", "cc"); \
188 } \
189 } while (0)
190
191 #if 0
192 #define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!!
193 #endif
194
195
196
197
198
199
200
201
202
203
204
205
206 #define bus_space_read_raw_multi_2(t, h, o, a, c) \
207 bus_space_read_multi_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
208 #define bus_space_read_raw_multi_4(t, h, o, a, c) \
209 bus_space_read_multi_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
210
211 #if 0
212 #define bus_space_read_raw_multi_8 \
213 !!! bus_space_read_raw_multi_8 unimplemented !!!
214 #endif
215
216
217
218
219
220
221
222
223
224
225
226 #define bus_space_read_region_1(t, h, o, a, cnt) do { \
227 int _cnt = (cnt); void *_addr = (a); int _port = (h)+(o); \
228 if ((t) == I386_BUS_SPACE_IO) { \
229 __asm __volatile(" \
230 cld ; \
231 1: inb %w2,%%al ; \
232 stosb ; \
233 incl %2 ; \
234 loop 1b" : \
235 "+D" (_addr), "+c" (_cnt), "+d" (_port) :: \
236 "%eax", "memory", "cc"); \
237 } else \
238 i386_space_copy(_port, _addr, 1, _cnt); \
239 } while (0)
240
241 #define bus_space_read_region_2(t, h, o, a, cnt) do { \
242 int _cnt = (cnt); void *_addr = (a); int _port = (h)+(o); \
243 if ((t) == I386_BUS_SPACE_IO) { \
244 __asm __volatile(" \
245 cld ; \
246 1: inw %w2,%%ax ; \
247 stosw ; \
248 addl $2,%2 ; \
249 loop 1b" : \
250 "+D" (_addr), "+c" (_cnt), "+d" (_port) :: \
251 "%eax", "memory", "cc"); \
252 } else \
253 i386_space_copy(_port, _addr, 2, _cnt); \
254 } while (0)
255
256 #define bus_space_read_region_4(t, h, o, a, cnt) do { \
257 int _cnt = (cnt); void *_addr = (a); int _port = (h)+(o); \
258 if ((t) == I386_BUS_SPACE_IO) { \
259 __asm __volatile(" \
260 cld ; \
261 1: inl %w2,%%eax ; \
262 stosl ; \
263 addl $4,%2 ; \
264 loop 1b" : \
265 "+D" (_addr), "+c" (_cnt), "+d" (_port) :: \
266 "%eax", "memory", "cc"); \
267 } else \
268 i386_space_copy(_port, _addr, 4, _cnt); \
269 } while (0)
270
271 #if 0
272 #define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!!
273 #endif
274
275
276
277
278
279
280
281
282
283
284
285
286
287 #define bus_space_read_raw_region_2(t, h, o, a, c) \
288 bus_space_read_region_2((t), (h), (o), (u_int16_t *)(a), (c) >> 1)
289 #define bus_space_read_raw_region_4(t, h, o, a, c) \
290 bus_space_read_region_4((t), (h), (o), (u_int32_t *)(a), (c) >> 2)
291
292 #if 0
293 #define bus_space_read_raw_region_8 \
294 !!! bus_space_read_raw_region_8 unimplemented !!!
295 #endif
296
297
298
299
300
301
302
303
304
305
306 #define bus_space_write_1(t, h, o, v) do { \
307 if ((t) == I386_BUS_SPACE_IO) \
308 outb((h) + (o), (v)); \
309 else \
310 ((void)(*(volatile u_int8_t *)((h) + (o)) = (v))); \
311 } while (0)
312
313 #define bus_space_write_2(t, h, o, v) do { \
314 if ((t) == I386_BUS_SPACE_IO) \
315 outw((h) + (o), (v)); \
316 else \
317 ((void)(*(volatile u_int16_t *)((h) + (o)) = (v))); \
318 } while (0)
319
320 #define bus_space_write_4(t, h, o, v) do { \
321 if ((t) == I386_BUS_SPACE_IO) \
322 outl((h) + (o), (v)); \
323 else \
324 ((void)(*(volatile u_int32_t *)((h) + (o)) = (v))); \
325 } while (0)
326
327 #if 0
328 #define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
329 #endif
330
331
332
333
334
335
336
337
338
339
340 #define bus_space_write_multi_1(t, h, o, a, cnt) do { \
341 if ((t) == I386_BUS_SPACE_IO) { \
342 outsb((h) + (o), (a), (cnt)); \
343 } else {const void *_addr=(a); int _cnt=(cnt); \
344 __asm __volatile(" \
345 cld ; \
346 1: lodsb ; \
347 movb %%al,(%2) ; \
348 loop 1b" : \
349 "+S" (_addr), "+c" (_cnt) : "r" ((h) + (o)) : \
350 "%eax", "memory", "cc"); \
351 } \
352 } while (0)
353
354 #define bus_space_write_multi_2(t, h, o, a, cnt) do { \
355 if ((t) == I386_BUS_SPACE_IO) { \
356 outsw((h) + (o), (a), (cnt)); \
357 } else {const void *_addr=(a); int _cnt=(cnt); \
358 __asm __volatile(" \
359 cld ; \
360 1: lodsw ; \
361 movw %%ax,(%2) ; \
362 loop 1b" : \
363 "+S" (_addr), "+c" (_cnt) : "r" ((h) + (o)) : \
364 "%eax", "memory", "cc"); \
365 } \
366 } while (0)
367
368 #define bus_space_write_multi_4(t, h, o, a, cnt) do { \
369 if ((t) == I386_BUS_SPACE_IO) { \
370 outsl((h) + (o), (a), (cnt)); \
371 } else {const void *_addr=(a); int _cnt=(cnt); \
372 __asm __volatile(" \
373 cld ; \
374 1: lodsl ; \
375 movl %%eax,(%2) ; \
376 loop 1b" : \
377 "+S" (_addr), "+c" (_cnt) : "r" ((h) + (o)) : \
378 "%eax", "memory", "cc"); \
379 } \
380 } while (0)
381
382 #if 0
383 #define bus_space_write_multi_8(t, h, o, a, c) \
384 !!! bus_space_write_multi_8 unimplemented !!!
385 #endif
386
387
388
389
390
391
392
393
394
395
396
397
398 #define bus_space_write_raw_multi_2(t, h, o, a, c) \
399 bus_space_write_multi_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)
400 #define bus_space_write_raw_multi_4(t, h, o, a, c) \
401 bus_space_write_multi_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
402
403 #if 0
404 #define bus_space_write_raw_multi_8 \
405 !!! bus_space_write_raw_multi_8 unimplemented !!!
406 #endif
407
408
409
410
411
412
413
414
415
416
417 #define bus_space_write_region_1(t, h, o, a, cnt) do { \
418 int _port = (h)+(o); const void *_addr=(a); int _cnt=(cnt); \
419 if ((t) == I386_BUS_SPACE_IO) { \
420 __asm __volatile(" \
421 cld ; \
422 1: lodsb ; \
423 outb %%al,%w0 ; \
424 incl %0 ; \
425 loop 1b" : \
426 "+d" (_port), "+S" (_addr), "+c" (_cnt) :: \
427 "%eax", "memory", "cc"); \
428 } else \
429 i386_space_copy(_addr, _port, 1, _cnt); \
430 } while (0)
431
432 #define bus_space_write_region_2(t, h, o, a, cnt) do { \
433 int _port = (h)+(o); const void *_addr=(a); int _cnt=(cnt); \
434 if ((t) == I386_BUS_SPACE_IO) { \
435 __asm __volatile(" \
436 cld ; \
437 1: lodsw ; \
438 outw %%ax,%w0 ; \
439 addl $2,%0 ; \
440 loop 1b" : \
441 "+d" (_port), "+S" (_addr), "+c" (_cnt) :: \
442 "%eax", "memory", "cc"); \
443 } else \
444 i386_space_copy(_addr, _port, 2, _cnt); \
445 } while (0)
446
447 #define bus_space_write_region_4(t, h, o, a, cnt) do { \
448 int _port = (h)+(o); const void *_addr=(a); int _cnt=(cnt); \
449 if ((t) == I386_BUS_SPACE_IO) { \
450 __asm __volatile(" \
451 cld ; \
452 1: lodsl ; \
453 outl %%eax,%w0 ; \
454 addl $4,%0 ; \
455 loop 1b" : \
456 "+d" (_port), "+S" (_addr), "+c" (_cnt) :: \
457 "%eax", "memory", "cc"); \
458 } else \
459 i386_space_copy(_addr, _port, 4, _cnt); \
460 } while (0)
461
462 #if 0
463 #define bus_space_write_region_8 \
464 !!! bus_space_write_region_8 unimplemented !!!
465 #endif
466
467
468
469
470
471
472
473
474
475
476
477
478
479 #define bus_space_write_raw_region_2(t, h, o, a, c) \
480 bus_space_write_region_2((t), (h), (o), (const u_int16_t *)(a), (c) >> 1)
481 #define bus_space_write_raw_region_4(t, h, o, a, c) \
482 bus_space_write_region_4((t), (h), (o), (const u_int32_t *)(a), (c) >> 2)
483
484 #if 0
485 #define bus_space_write_raw_region_8 \
486 !!! bus_space_write_raw_region_8 unimplemented !!!
487 #endif
488
489
490
491
492
493
494
495
496
497
498 #define bus_space_set_multi_1(t, h, o, v, cnt) do { \
499 int _cnt=(cnt); \
500 if ((t) == I386_BUS_SPACE_IO) { \
501 __asm __volatile(" \
502 cld ; \
503 1: outb %b2, %w1 ; \
504 loop 1b" : \
505 "+c" (_cnt) : "d" ((h) + (o)), "a" ((v)) : \
506 "cc"); \
507 } else { \
508 __asm __volatile(" \
509 cld ; \
510 1: movb %b2, (%1) ; \
511 loop 1b" : \
512 "+c" (_cnt) : "D" ((h) + (o)), "a" ((v)) : \
513 "cc", "memory"); \
514 } \
515 } while (0)
516
517 #define bus_space_set_multi_2(t, h, o, v, cnt) do { \
518 int _cnt=(cnt); \
519 if ((t) == I386_BUS_SPACE_IO) { \
520 __asm __volatile(" \
521 cld ; \
522 1: outw %w2, %w1 ; \
523 loop 1b" : \
524 "+c" (_cnt) : "d" ((h) + (o)), "a" ((v)) : \
525 "cc"); \
526 } else { \
527 __asm __volatile(" \
528 cld ; \
529 1: movw %w2, (%1) ; \
530 loop 1b" : \
531 "+c" (_cnt) : "D" ((h) + (o)), "a" ((v)) : \
532 "cc", "memory"); \
533 } \
534 } while (0)
535
536 #define bus_space_set_multi_4(t, h, o, v, cnt) do { \
537 int _cnt=(cnt); \
538 if ((t) == I386_BUS_SPACE_IO) { \
539 __asm __volatile(" \
540 cld ; \
541 1: outl %2,%w1 ; \
542 loop 1b" : \
543 "+c" (_cnt) : "d" ((h) + (o)), "a" ((v)) : \
544 "cc"); \
545 } else { \
546 __asm __volatile(" \
547 cld ; \
548 1: movl %2,(%1) ; \
549 loop 1b" : \
550 "+c" (_cnt) : "D" ((h) + (o)), "a" ((v)) : \
551 "cc", "memory"); \
552 } \
553 } while (0)
554
555 #if 0
556 #define bus_space_set_multi_8 \
557 !!! bus_space_set_multi_8 unimplemented !!!
558 #endif
559
560
561
562
563
564
565
566
567
568
569 #define bus_space_set_region_1(t, h, o, v, cnt) do { \
570 int _port = (h)+(o); int _cnt = (cnt); \
571 if ((t) == I386_BUS_SPACE_IO) { \
572 __asm __volatile(" \
573 1: outb %%al,%w0 ; \
574 incl %0 ; \
575 loop 1b" : \
576 "+d" (_port), "+c" (_cnt) : "a" ((v)) : \
577 "cc"); \
578 } else { \
579 __asm __volatile(" \
580 cld ; \
581 repne ; \
582 stosb" : \
583 "+D" (_port), "+c" (_cnt) : "a" ((v)) : \
584 "memory", "cc"); \
585 } \
586 } while (0)
587
588 #define bus_space_set_region_2(t, h, o, v, cnt) do { \
589 int _port = (h)+(o); int _cnt = (cnt); \
590 if ((t) == I386_BUS_SPACE_IO) { \
591 __asm __volatile(" \
592 1: outw %%ax,%w0 ; \
593 addl $2, %0 ; \
594 loop 1b" : \
595 "+d" (_port), "+c" (_cnt) : "a" ((v)) : \
596 "cc"); \
597 } else { \
598 __asm __volatile(" \
599 cld ; \
600 repne ; \
601 stosw" : \
602 "+D" (_port), "+c" (_cnt) : "a" ((v)) : \
603 "memory", "cc"); \
604 } \
605 } while (0)
606
607 #define bus_space_set_region_4(t, h, o, v, cnt) do { \
608 int _port = (h)+(o); int _cnt = (cnt); \
609 if ((t) == I386_BUS_SPACE_IO) { \
610 __asm __volatile(" \
611 1: outl %%eax,%w0 ; \
612 addl $4, %0 ; \
613 loop 1b" : \
614 "+d" (_port), "+c" (_cnt) : "a" ((v)) : \
615 "cc"); \
616 } else { \
617 __asm __volatile(" \
618 cld ; \
619 repne ; \
620 stosl" : \
621 "+D" (_port), "+c" (_cnt) : "a" ((v)) : \
622 "memory", "cc"); \
623 } \
624 } while (0)
625
626 #if 0
627 #define bus_space_set_region_8 \
628 !!! bus_space_set_region_8 unimplemented !!!
629 #endif
630
631
632
633
634
635
636
637
638
639
640
641 #define bus_space_copy_1(t, h1, o1, h2, o2, cnt) do { \
642 int _port1 = (h1)+(o1); int _port2 = (h2)+(o2); int _cnt=(cnt); \
643 if ((t) == I386_BUS_SPACE_IO) { \
644 __asm __volatile(" \
645 1: movl %k1,%%edx ; \
646 inb %%dx,%%al ; \
647 movl %k0,%%edx ; \
648 outb %%al,%%dx ; \
649 incl %0 ; \
650 incl %1 ; \
651 loop 1b" : \
652 "+D" (_port2), "+S" (_port1), "+c" ((_cnt)) :: \
653 "%edx", "%eax", "cc"); \
654 } else \
655 i386_space_copy(_port1, _port2, 1, _cnt); \
656 } while (0)
657
658 #define bus_space_copy_2(t, h1, o1, h2, o2, cnt) do { \
659 int _port1 = (h1)+(o1); int _port2 = (h2)+(o2); int _cnt=(cnt); \
660 if ((t) == I386_BUS_SPACE_IO) { \
661 __asm __volatile(" \
662 1: movl %k1,%%edx ; \
663 inw %%dx,%%ax ; \
664 movl %k0,%%edx ; \
665 outw %%ax,%%dx ; \
666 addl $2, %0 ; \
667 addl $2, %1 ; \
668 loop 1b" : \
669 "+D" (_port2), "+ES" (_port1), "+c" ((_cnt)) :: \
670 "%edx", "%eax", "cc"); \
671 } else \
672 i386_space_copy(_port1, _port2, 2, _cnt); \
673 } while (0)
674
675 #define bus_space_copy_4(t, h1, o1, h2, o2, cnt) do { \
676 int _port1 = (h1)+(o1); int _port2 = (h2)+(o2); int _cnt=(cnt); \
677 if ((t) == I386_BUS_SPACE_IO) { \
678 __asm __volatile(" \
679 1: movl %k1,%%edx ; \
680 inl %%dx,%%eax ; \
681 movl %k0,%%edx ; \
682 outl %%eax,%%dx ; \
683 addl $4, %0 ; \
684 addl $4, %1 ; \
685 loop 1b" : \
686 "+D" (_port2), "+ES" (_port1), "+c" ((_cnt)) :: \
687 "%edx", "%eax", "cc"); \
688 } else \
689 i386_space_copy(_port1, _port2, 4, _cnt); \
690 } while (0)
691
692 #if 0
693 #define bus_space_copy_8 \
694 !!! bus_space_copy_8 unimplemented !!!
695 #endif
696
697 #define i386_space_copy1(a1, a2, cnt, movs, df) \
698 __asm __volatile(df "\n\trep\n\t" movs : \
699 "+S" (a1), "+D" (a2), "+c" (cnt) :: "memory", "cc");
700
701 #define i386_space_copy(a1, a2, sz, cnt) do { \
702 if ((void *)(a1) < (void *)(a2)) { \
703 a1 += ((cnt) - 1) * (sz); a2 += ((cnt) - 1) * (sz); \
704 switch (sz) { \
705 case 1: i386_space_copy1(a1,a2,cnt,"movsb","std");break;\
706 case 2: i386_space_copy1(a1,a2,cnt,"movsw","std");break;\
707 case 4: i386_space_copy1(a1,a2,cnt,"movsl","std");break;\
708 } \
709 } else \
710 switch (sz) { \
711 case 1: i386_space_copy1(a1,a2,cnt,"movsb","cld");break;\
712 case 2: i386_space_copy1(a1,a2,cnt,"movsw","cld");break;\
713 case 4: i386_space_copy1(a1,a2,cnt,"movsl","cld");break;\
714 } \
715 } while (0)
716
717
718
719
720
721
722
723
724
725
726
727 #define bus_space_barrier(t, h, o, l, f) \
728 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
729 #define BUS_SPACE_BARRIER_READ 0x01
730 #define BUS_SPACE_BARRIER_WRITE 0x02
731
732 #define BUS_BARRIER_READ BUS_SPACE_BARRIER_READ
733 #define BUS_BARRIER_WRITE BUS_SPACE_BARRIER_WRITE
734
735
736
737
738 #define BUS_DMA_WAITOK 0x000
739 #define BUS_DMA_NOWAIT 0x001
740 #define BUS_DMA_ALLOCNOW 0x002
741 #define BUS_DMA_COHERENT 0x004
742 #define BUS_DMA_BUS1 0x010
743 #define BUS_DMA_BUS2 0x020
744 #define BUS_DMA_BUS3 0x040
745 #define BUS_DMA_24BIT 0x080
746 #define BUS_DMA_STREAMING 0x100
747 #define BUS_DMA_READ 0x200
748 #define BUS_DMA_WRITE 0x400
749
750
751 struct mbuf;
752 struct proc;
753 struct uio;
754
755
756
757
758 #define BUS_DMASYNC_PREREAD 0x01
759 #define BUS_DMASYNC_POSTREAD 0x02
760 #define BUS_DMASYNC_PREWRITE 0x04
761 #define BUS_DMASYNC_POSTWRITE 0x08
762
763 typedef struct i386_bus_dma_tag *bus_dma_tag_t;
764 typedef struct i386_bus_dmamap *bus_dmamap_t;
765
766
767
768
769
770
771
772 struct i386_bus_dma_segment {
773 bus_addr_t ds_addr;
774 bus_size_t ds_len;
775 };
776 typedef struct i386_bus_dma_segment bus_dma_segment_t;
777
778
779
780
781
782
783
784
785 struct i386_bus_dma_tag {
786 void *_cookie;
787
788
789
790
791 int (*_dmamap_create)(bus_dma_tag_t, bus_size_t, int,
792 bus_size_t, bus_size_t, int, bus_dmamap_t *);
793 void (*_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t);
794 int (*_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *,
795 bus_size_t, struct proc *, int);
796 int (*_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t,
797 struct mbuf *, int);
798 int (*_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t,
799 struct uio *, int);
800 int (*_dmamap_load_raw)(bus_dma_tag_t, bus_dmamap_t,
801 bus_dma_segment_t *, int, bus_size_t, int);
802 void (*_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t);
803 void (*_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t,
804 bus_addr_t, bus_size_t, int);
805
806
807
808
809 int (*_dmamem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t,
810 bus_size_t, bus_dma_segment_t *, int, int *, int);
811 void (*_dmamem_free)(bus_dma_tag_t,
812 bus_dma_segment_t *, int);
813 int (*_dmamem_map)(bus_dma_tag_t, bus_dma_segment_t *,
814 int, size_t, caddr_t *, int);
815 void (*_dmamem_unmap)(bus_dma_tag_t, caddr_t, size_t);
816 paddr_t (*_dmamem_mmap)(bus_dma_tag_t, bus_dma_segment_t *,
817 int, off_t, int, int);
818 };
819
820 #define bus_dmamap_create(t, s, n, m, b, f, p) \
821 (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p))
822 #define bus_dmamap_destroy(t, p) \
823 (*(t)->_dmamap_destroy)((t), (p))
824 #define bus_dmamap_load(t, m, b, s, p, f) \
825 (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f))
826 #define bus_dmamap_load_mbuf(t, m, b, f) \
827 (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f))
828 #define bus_dmamap_load_uio(t, m, u, f) \
829 (*(t)->_dmamap_load_uio)((t), (m), (u), (f))
830 #define bus_dmamap_load_raw(t, m, sg, n, s, f) \
831 (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
832 #define bus_dmamap_unload(t, p) \
833 (*(t)->_dmamap_unload)((t), (p))
834 #define bus_dmamap_sync(t, p, o, l, ops) \
835 (void)((t)->_dmamap_sync ? \
836 (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
837
838 #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \
839 (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
840 #define bus_dmamem_free(t, sg, n) \
841 (*(t)->_dmamem_free)((t), (sg), (n))
842 #define bus_dmamem_map(t, sg, n, s, k, f) \
843 (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f))
844 #define bus_dmamem_unmap(t, k, s) \
845 (*(t)->_dmamem_unmap)((t), (k), (s))
846 #define bus_dmamem_mmap(t, sg, n, o, p, f) \
847 (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f))
848
849
850
851
852
853
854 struct i386_bus_dmamap {
855
856
857
858 bus_size_t _dm_size;
859 int _dm_segcnt;
860 bus_size_t _dm_maxsegsz;
861 bus_size_t _dm_boundary;
862 int _dm_flags;
863
864 void *_dm_cookie;
865
866
867
868
869 bus_size_t dm_mapsize;
870 int dm_nsegs;
871 bus_dma_segment_t dm_segs[1];
872 };
873
874 #ifdef _I386_BUS_DMA_PRIVATE
875 int _bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
876 bus_size_t, int, bus_dmamap_t *);
877 void _bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
878 int _bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *,
879 bus_size_t, struct proc *, int);
880 int _bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t,
881 struct mbuf *, int);
882 int _bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t,
883 struct uio *, int);
884 int _bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t,
885 bus_dma_segment_t *, int, bus_size_t, int);
886 void _bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
887 void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
888 bus_size_t, int);
889
890 int _bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size,
891 bus_size_t alignment, bus_size_t boundary,
892 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
893 void _bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs,
894 int nsegs);
895 int _bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs,
896 int nsegs, size_t size, caddr_t *kvap, int flags);
897 void _bus_dmamem_unmap(bus_dma_tag_t tag, caddr_t kva,
898 size_t size);
899 paddr_t _bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs,
900 int nsegs, off_t off, int prot, int flags);
901
902 int _bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size,
903 bus_size_t alignment, bus_size_t boundary,
904 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
905 paddr_t low, paddr_t high);
906 #endif
907
908 #endif