|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( H4 U9 O) w' D0 Z8 Z$ b8 C- [code]EDMA sample test application8 L4 ~3 {/ E' Y7 {, y% ^# L4 ?, K
- /*4 K% y1 t. k6 q/ `
- * edma_test.c
7 b: _) {& V6 V: v - *( |9 n6 B( P8 R& W4 }. p" E, Y
- * brief EDMA3 Test Application
1 P1 ]" y$ \% u" y! [ - *
# I9 G' q9 _ i3 j+ V& y3 o# D - * This file contains EDMA3 Test code.
J0 d L$ K0 X+ A% F) ~; h6 \ - *" D- A9 C/ J7 Y9 P" ~1 a( ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& Y% m' y2 O' U/ ?/ b6 m! |% ?5 T) [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 k& c* G+ ~2 F# ~' M1 G
- * TO CHANGE.# x; Z+ P/ L/ ~ D u+ x) v
- *+ H; K, l7 i+ G) C
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 c9 |2 p* y+ ]" ^: F- T3 y3 y! L2 ` - *
0 Q8 c, Y8 U0 i8 ^5 w# x - * This program is free software; you can redistribute it and/or
" y+ {- p& \ n7 m; ` - * modify it under the terms of the GNU General Public License as) n [% D* a" R/ D9 c. `7 r
- * published by the Free Software Foundation version 2.
1 ?; G" C/ Y+ o/ q( N) n! k - ** _, F3 v; M9 b) c3 H1 l* u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 b) d: D2 c2 T3 n( b( S" n
- * kind, whether express or implied; without even the implied warranty9 v- B, Q! W, V; S/ Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 {/ T! v6 K5 i' N
- * GNU General Public License for more details.& @. g, {! d4 l% h/ @. H
- */# d! p" j3 @& g8 r! u
2 {0 ~6 b9 \# h l3 R- #include <linux/module.h>
6 Q; r8 H+ D+ ?; I - #include <linux/init.h> H& O" y& h, Z
- #include <linux/errno.h>
/ q2 t. Z1 K! G6 _) j - #include <linux/types.h>" ], b% \# Q3 r. `+ J0 V0 V! |
- #include <linux/interrupt.h>3 x( H, A! ]) x# {7 [& f
- #include <asm/io.h>, S8 E9 O/ p5 P2 d; h
- #include <linux/moduleparam.h>8 z! q' s o+ U4 P) i& t0 r
- #include <linux/sysctl.h>
1 r9 R9 {* ]& O M, G' G4 G - #include <linux/mm.h>
$ t# E: g4 V# H/ p' }9 } - #include <linux/dma-mapping.h>
% t/ i6 v% k: u. J - * K. O. Z9 n U, p8 y E$ |
- #include <mach/memory.h>) E& b& u2 p, |$ t5 p
- #include <mach/hardware.h>
: Z) m' `' G2 P5 \, I4 K6 _ - #include <mach/irqs.h>
+ y& N: A; D8 @6 v6 A - #include <asm/hardware/edma.h>. ] M* ~3 U: J/ B% p1 A- I
- 8 ^" |( A$ l$ B, _
- #undef EDMA3_DEBUG% F P3 j9 p* B! \+ _
- /*#define EDMA3_DEBUG*/. _3 N8 c4 K) I5 x) M. k
' M% C4 t5 t1 @: X, L/ j0 F4 |- #ifdef EDMA3_DEBUG4 ?$ D4 H$ m3 z+ `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( l3 Q- b C4 l+ k) ^+ k" w/ [, | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! T. g; T7 D1 q1 @. j
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# {2 j$ `/ d7 ]0 } - #else- s2 M# D; K# \# ~
- #define DMA_PRINTK( x... )
' A. \3 Z' C1 X; h" q4 h - #define DMA_FN_IN
0 v) f P# l2 Z- J; r, a - #define DMA_FN_OUT& s6 m9 G& B( t1 N! s' t
- #endif
7 s% F& @ s3 W
) e: X2 ]" p, D- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) ]% N( x5 E. p+ L$ {+ q9 K
- #define STATIC_SHIFT 3: f4 m+ r7 {. N
- #define TCINTEN_SHIFT 208 t: b3 K0 X+ V+ X
- #define ITCINTEN_SHIFT 21% n( M' y6 Y5 c d. @/ j/ A
- #define TCCHEN_SHIFT 22% m3 A+ K: T h
- #define ITCCHEN_SHIFT 230 n: j6 m" W. |) }0 v3 M* E! b
5 |2 o7 S- U' l1 r- static volatile int irqraised1 = 0;
3 e' T9 ?' n) ^5 M9 h8 T' j - static volatile int irqraised2 = 0;
/ @" Z0 H0 G3 m& L
I0 `6 g" ~, f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. @& T' ^9 @( a4 e& V1 n2 _6 v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 O* d/ D4 X+ x' }) j$ H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. q$ ~7 _& `2 r - : B# a: U+ K% p" d2 q( p, S$ h
- dma_addr_t dmaphyssrc1 = 0;& d8 W& o; O. R7 j7 g
- dma_addr_t dmaphyssrc2 = 0;
. o2 x0 X' L. A2 H1 q - dma_addr_t dmaphysdest1 = 0;# G$ V' B m+ q+ d8 f% Z$ L; ?4 b/ u
- dma_addr_t dmaphysdest2 = 0;
8 ], \! D F$ w- M6 H - ; V+ D- D, K$ H4 ~; `3 H
- char *dmabufsrc1 = NULL;
6 q4 Z9 P1 R& v5 @( y$ V - char *dmabufsrc2 = NULL;8 P& c% w% J" j' S. e- m
- char *dmabufdest1 = NULL;" i# f6 ?; ?/ Y2 E* U+ q$ S
- char *dmabufdest2 = NULL;8 L, {4 j4 z8 H& B5 r. y+ B
- / X, H: M; F) O& |0 i# g: ?+ d
- static int acnt = 512;3 \( i1 l+ j5 L% @! l9 F8 ~
- static int bcnt = 8;
1 f% H; X# G$ V0 H; ]4 W X - static int ccnt = 8;
[, v! H( L c. E9 Q) L% W - K. w+ ]" b2 k7 }# {4 f2 ]0 v
- module_param(acnt, int, S_IRUGO);
) m# v, J* |5 E+ Z) x - module_param(bcnt, int, S_IRUGO);( e W. R" e) u' T: Q4 F
- module_param(ccnt, int, S_IRUGO);
复制代码
* v1 l: y' q! n H( U# }. N5 L' f3 o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 @; w, C; Z9 F9 Z* k
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 `# W* Z4 D5 Q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 j; j7 o3 R" G# i0 z u
* M5 U) W5 _) c3 h8 |0 }; ^' Q* Y- o
: A# ^1 U" o& _! }$ t5 I! D3 V |
|