|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : \" U( H" _% }5 J
- [code]EDMA sample test application
. K% m6 F! ?2 l6 x - /*
- m* |3 A+ u& c4 X7 H - * edma_test.c
: H7 a( a2 l8 G# F - *
. K7 r4 m, e( i( w1 x& n& e - * brief EDMA3 Test Application4 D6 L6 q0 N% \8 B$ u! ~! N* |0 ^
- *, V8 c. {2 s- n
- * This file contains EDMA3 Test code.1 E, f5 Z* m6 {( a8 ~3 x
- *
, X" |% U) p2 [) L7 I9 J1 D/ Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 w* q: A2 @; _& y! a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 Z/ d# V4 F) @1 r
- * TO CHANGE.
( |0 {0 ?3 `, M3 G a, D x& O - ** _& r( J e7 N9 f; L
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 p& |8 Z) e2 p. m - *
) X) c3 @4 a, {3 w$ _/ k( s% d I; S. e - * This program is free software; you can redistribute it and/or& z- f8 c( g) Z* N. U; X6 A" }
- * modify it under the terms of the GNU General Public License as' y$ y- [8 [' O* E1 T% r" r
- * published by the Free Software Foundation version 2.
: m$ L8 z" d' A! N6 | - *3 \/ d8 _3 X7 z. C6 B T- q8 W/ R
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( L. p8 u6 B- B! O( d. K) K* ~ - * kind, whether express or implied; without even the implied warranty
6 H' w0 i* T% x0 N% f L - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 L% e+ J$ i [8 |: n - * GNU General Public License for more details.- A6 R4 m3 E1 ~9 ^; e4 J
- */+ q) y) Q- W" |- o' W) l
: X% Q" A' N, q" P8 ~/ B& V- #include <linux/module.h>, ]9 _7 B+ V; R0 p# U7 O& y* D
- #include <linux/init.h>
9 _% H3 o" N( p# P/ T - #include <linux/errno.h>
4 Q5 O- ]' Q6 h& Z+ ]4 ~ - #include <linux/types.h>$ {5 ?4 V! o) u' T, s5 c" w2 n
- #include <linux/interrupt.h>
0 f8 B# o/ k1 m4 s) k - #include <asm/io.h>
! j. w9 F p( h, H0 ` - #include <linux/moduleparam.h>* `/ [% Q, Q+ w; \& I7 Q: m. a
- #include <linux/sysctl.h>
9 q1 r5 E. T: X - #include <linux/mm.h>
5 S! q {$ w3 l9 @ - #include <linux/dma-mapping.h>
- A; V# \5 h1 q- ^! N
* ], d$ S# y! v0 t7 D. v: u7 H- #include <mach/memory.h>. o" `3 F- ^2 v" u5 P8 g
- #include <mach/hardware.h>! U, |2 ~1 s' j# h, B
- #include <mach/irqs.h>
9 ]+ Q3 [) \. a& x7 A: p# r& U$ a2 W - #include <asm/hardware/edma.h>9 r, |* d1 [" ]. Y8 k/ O% G
- ! t. ~- g" H2 P8 A" b
- #undef EDMA3_DEBUG6 f6 b) k$ D' E. `# e
- /*#define EDMA3_DEBUG*/
7 w) x+ t8 y1 R8 Z# m, Z7 i* j - / y* h/ m8 ~, m! r+ N- |7 a
- #ifdef EDMA3_DEBUG& Q. I2 G- Z3 f* _5 q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ g7 I9 u+ d1 t) q; c2 `6 K: K- r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 F" p. |1 {* Y. a - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 r( n2 t' g0 F, A/ {+ j
- #else
4 T6 N# _2 P( x# a; G5 p: l - #define DMA_PRINTK( x... )
# q+ Y L# w. P7 c% f& o% f: L - #define DMA_FN_IN7 i0 G5 i3 j9 H& a" T0 F" a+ T
- #define DMA_FN_OUT; y1 `# X5 t1 @: e/ k
- #endif1 o# |& a& S7 j' T
* D4 T! C+ }9 E7 L/ Y9 R" a+ I- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 T. |) C- d# v- F: U* N" }: ]
- #define STATIC_SHIFT 3
; I" L' i! k" N- Z% u6 i - #define TCINTEN_SHIFT 20
& f% D: W. D! G! e5 F - #define ITCINTEN_SHIFT 21: W5 b% N; `3 T
- #define TCCHEN_SHIFT 22
2 y5 G) ^# S5 c$ T/ G) d( t) S - #define ITCCHEN_SHIFT 230 V$ o Z" G: D5 E1 r. |
- + l8 x# o9 x/ n0 O5 U- h& C
- static volatile int irqraised1 = 0;
6 Q0 c9 _) O: E* M% _7 |4 E* P - static volatile int irqraised2 = 0;- f6 ^9 N6 U: D- I) u
- G" d6 U6 j# X; M7 T. w; s/ R
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, _1 v) l7 {( w4 K _8 {
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 U0 l* {; u* i& b- L; k
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) ?2 X" a$ j8 D* L" O8 l/ h
- , d$ R6 V* p0 \* y: \1 U2 P
- dma_addr_t dmaphyssrc1 = 0;: L Y4 {3 q% b# z0 G
- dma_addr_t dmaphyssrc2 = 0;
4 o* y: O; m: ?6 O" Z+ u - dma_addr_t dmaphysdest1 = 0;
' m3 ?3 H1 e; E - dma_addr_t dmaphysdest2 = 0;
1 a: q- Y, I0 I8 q& ] - ! h. f( z) t; L2 ]% i
- char *dmabufsrc1 = NULL;# n3 s* `1 T' D
- char *dmabufsrc2 = NULL;3 v; ~. n8 ~+ n# u, b9 D$ D
- char *dmabufdest1 = NULL;! ~' d' s! k n% {2 ~* G
- char *dmabufdest2 = NULL;8 f$ x) z: w A( s# v% k
% \: W# V0 G0 c3 `2 z: a+ W2 Z, R- static int acnt = 512;) Q( p9 H% w" L8 {# R/ Q' t
- static int bcnt = 8;
h; @1 G) O& `- \8 o% h7 k: V) f4 D - static int ccnt = 8;. N/ u$ x8 i2 H+ U1 s- a- Y
- - o5 \2 o( f6 h$ }
- module_param(acnt, int, S_IRUGO);
7 z5 ?" G9 b& z6 ^; C& E* { b) h - module_param(bcnt, int, S_IRUGO);
# m+ R4 d0 c8 I - module_param(ccnt, int, S_IRUGO);
复制代码 $ l" h/ \+ }4 ~9 g3 B3 R; ^: U
3 w( p6 h5 m7 q* i9 t0 k+ p 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) h& O2 q9 T/ e: H: E- larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 ^" r Z/ g- I6 q. G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 X( I/ r( C4 S( R" e0 p& n( A9 m9 k2 Y9 O
; s1 M- q; r7 V: v/ N( t
|
|