|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 l/ E; B E/ q) m- [code]EDMA sample test application: s+ v, Y. }0 h4 Q( @: C" |
- /*% h- v$ Z" O" P; a
- * edma_test.c% T6 i( b2 q3 z! z2 F
- *, o( a& }+ a0 u$ f( ~6 n' n
- * brief EDMA3 Test Application( D* l0 U$ {7 Y/ F5 p
- *
- Z, s! X" B4 n8 T# f. D( U - * This file contains EDMA3 Test code.
* b& ^4 ^& s" D- B! m - *3 A# z3 w M8 [6 w$ V G7 v" L
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! I# s0 E+ |) d. x, b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% Z6 s( `) G3 W: E% U- @& o
- * TO CHANGE., @( U$ Z( n' k( T; h% ]9 F- v6 ~
- *
4 r) O- A, f/ j! x4 P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; ]0 p8 f; {5 T0 W+ | - *
$ P5 u* r. A( _* H( s1 w4 V, L& s r5 O - * This program is free software; you can redistribute it and/or2 M9 I C) }7 E+ V+ A$ \
- * modify it under the terms of the GNU General Public License as6 B; w( _/ m6 ^
- * published by the Free Software Foundation version 2.7 J4 O) S1 a+ m- m) p0 p
- *8 q# G/ q8 D, m9 d) \2 R. H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: P* M) M6 z& \0 ^# |/ D) H$ l
- * kind, whether express or implied; without even the implied warranty( G% R* }3 }. F5 L$ H1 V. a8 a0 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ]9 x5 @; h( O( Y$ i) W. K - * GNU General Public License for more details.5 b; z, _# J5 ?; O" o
- */
6 L. \. y, |+ _# x: T# ]/ G - 4 |, {$ M# i" t! c% I
- #include <linux/module.h>
0 p2 @1 f& p5 ~6 u3 g) x. A - #include <linux/init.h>" X+ ]6 [- @4 N# M0 Z( i9 a
- #include <linux/errno.h>. j6 H) h* k/ z3 g& D7 j/ C0 R6 Q
- #include <linux/types.h>
/ O" R0 v$ x/ e& f6 i; @! h$ H - #include <linux/interrupt.h>
; {# n) J4 S6 y+ S( b0 ?8 B: V - #include <asm/io.h>9 _0 b2 A5 p, T5 |5 j, y. T( m3 T
- #include <linux/moduleparam.h>6 K* a; g* W8 n/ v) d0 j; D0 s
- #include <linux/sysctl.h>
8 `% ?& T5 v0 D3 g - #include <linux/mm.h>
2 V. z" b' Y, |! {$ V - #include <linux/dma-mapping.h>
. z% U) a7 d& A8 k- Q5 p% u
* o/ Y. f* s/ y" h9 E+ |- #include <mach/memory.h>
j# G6 L% P$ T/ f - #include <mach/hardware.h>
8 [0 Q( p5 ~" u: }6 M - #include <mach/irqs.h>5 n' T4 J! e% v! C# m
- #include <asm/hardware/edma.h>" C/ C$ L0 |$ y# S5 _
- 5 Z) T. N/ ?- K' \' J6 L
- #undef EDMA3_DEBUG
' p/ B- k3 A1 l+ f# E - /*#define EDMA3_DEBUG*/ @) F! M: u0 r# Y' D' Q
+ `9 R( O. g8 Z7 K7 t! B- #ifdef EDMA3_DEBUG
: s3 P0 D6 c* h8 f' L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: Q, k4 k( k$ V/ L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% H+ t% Y: ^, C1 h _+ c' {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" @: ?) [& G# \1 Z4 N4 V& i
- #else
3 I& `% Y3 G6 Z0 r; I - #define DMA_PRINTK( x... )
; V' N+ L7 E# W$ t0 D0 i3 Q - #define DMA_FN_IN
i/ g0 ^/ N' m. { F/ S - #define DMA_FN_OUT3 m) R7 q8 [+ i; q" V3 r1 f* [
- #endif) L- C7 ~' R4 o( [: d; v
- 9 c2 g4 P+ I. W7 Y( q: f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, V2 v; K+ m, h$ Z' _+ q2 E( i6 M% V+ G - #define STATIC_SHIFT 3% t4 W! Z* n: _5 z5 v
- #define TCINTEN_SHIFT 20( o$ M8 e; U+ C. m r* E2 p* P
- #define ITCINTEN_SHIFT 21
: @" r, V7 `3 L `1 x - #define TCCHEN_SHIFT 228 q) h5 g( a& {$ s; i/ C
- #define ITCCHEN_SHIFT 23
+ X) f/ n/ o' J& [; P - ( x! M1 C: y2 y1 w0 a
- static volatile int irqraised1 = 0; M1 D. f4 [" m" `) j# T
- static volatile int irqraised2 = 0;
3 Z) B" Z6 d: R7 z% Q+ L
3 m2 h/ Y; h5 u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 X9 e2 i- e- e: N" s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 }9 v9 a" }# K! D+ ]! }+ X1 ^ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: g* @! v8 q/ K( A; I# A/ j
1 G7 V' L' q- E- dma_addr_t dmaphyssrc1 = 0;* v. M) z" p1 H/ P4 E" d1 C4 P
- dma_addr_t dmaphyssrc2 = 0;* j G+ L/ X# u& q' J
- dma_addr_t dmaphysdest1 = 0;3 K* C) G5 r% P
- dma_addr_t dmaphysdest2 = 0;$ P) f3 w3 X: ]
v& Y0 [+ s3 a- char *dmabufsrc1 = NULL;
+ [3 |* a( ^7 L; T: E - char *dmabufsrc2 = NULL;, X1 f6 y8 F6 z% L, C! u; w1 L
- char *dmabufdest1 = NULL;
- h& `* Z1 z+ v2 ^2 B$ j! v - char *dmabufdest2 = NULL;4 ?, B7 h# Y5 q) }" j7 ?
- . d9 E) M9 e" ?
- static int acnt = 512;
4 [8 i& t# L# J3 d0 v% {/ J% } - static int bcnt = 8;( @6 p1 S' A) e h- e
- static int ccnt = 8;
" M; q. |7 t4 O" p# F5 D- P* s$ L - ' g5 y" x9 _- d! L* u" Q! o) h/ ~
- module_param(acnt, int, S_IRUGO); _7 i) D4 I! \- h; H, k6 _
- module_param(bcnt, int, S_IRUGO);
) t! Q. m9 l! K3 d, ~* X( I) L - module_param(ccnt, int, S_IRUGO);
复制代码
& J0 s5 x* s9 [4 ?3 q {! c6 u' H
% \% j" H5 P6 ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 `9 I, h+ B/ o# u* y: m U v, V" Farm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) R" C, g5 Z' t( n% B0 C* V 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 M& H" @( q( E
8 @! c. m' v1 m8 H/ K x
& m9 X. A+ X5 z! i0 N |
|