|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
Q" j" h+ }5 T: C- [code]EDMA sample test application
3 p2 z* B q1 m# M! V3 D - /*% F) J% q6 } f
- * edma_test.c
( N9 T$ G1 p$ L/ G - *. ?" O- o% b: c+ p+ @7 J& c
- * brief EDMA3 Test Application6 Z. m6 `" @, Q; i" p5 f$ _4 x" y( x
- *6 O( u7 X4 S$ @+ D- e9 t/ P
- * This file contains EDMA3 Test code.
, h7 J+ }7 ?" @1 k$ f* s - *3 _. ~8 C& P1 ^# ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 j* M; w$ C- X- q3 t, a7 ~ L - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' l% C2 K, Q+ ~' l/ t
- * TO CHANGE.# j7 e1 E: I1 K/ X6 R' ~
- *
' F2 R+ f) S( @8 R - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ U1 Z4 {: V( ^( f6 w
- *9 `* F" {! U7 H; T: [
- * This program is free software; you can redistribute it and/or7 `% T/ D7 p7 B7 a6 p! a
- * modify it under the terms of the GNU General Public License as
/ S& ]' w$ g) c' M( x - * published by the Free Software Foundation version 2.
$ m4 A2 e4 l' k& n( E0 y - *
2 E- H4 a1 j$ W H! u5 @' _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 Q- b" b. P) L6 V) r
- * kind, whether express or implied; without even the implied warranty; x6 {$ A5 D1 D2 Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 _" X4 J3 Z/ v8 L( Q
- * GNU General Public License for more details.- b( a7 @- Z, [
- */
% r1 P ~4 z ?* m0 p! U1 o) Y - 0 m; x& v+ r* H4 J6 w
- #include <linux/module.h>
# e1 t4 q3 H& v8 _( R, m9 N - #include <linux/init.h>
2 d; m$ B9 b; ]( x - #include <linux/errno.h>1 K1 Q; g; @: V% [; W" _3 d/ g
- #include <linux/types.h>8 e% O5 R% ` u X) y% j, G% s4 d
- #include <linux/interrupt.h>
% f; {0 G% k3 f: W7 S - #include <asm/io.h>8 w3 J' h+ R3 e" [) A) j2 p
- #include <linux/moduleparam.h>
* T- ~! n* v. O1 q+ [ u - #include <linux/sysctl.h># H& U+ M2 F' O' c' a
- #include <linux/mm.h>
* ?- @0 Y$ `+ z - #include <linux/dma-mapping.h>0 j: c L, ^+ H7 G4 Z
- 8 `2 _4 Y0 `! x( o0 i( G
- #include <mach/memory.h>
: Y1 v2 {$ c) |1 E - #include <mach/hardware.h>/ J( S. P! i" z! O0 _4 n( K
- #include <mach/irqs.h>( _& R4 L3 p; P; R% [3 k1 x8 r0 V
- #include <asm/hardware/edma.h>+ s" n+ D: v8 }4 V& W
- ) m6 n5 \* ^% |# V& q5 Y2 H; H
- #undef EDMA3_DEBUG
( y" [7 X4 N( f! d5 u3 Q3 n1 l - /*#define EDMA3_DEBUG*/
+ s/ w7 R2 B$ b- ?8 n1 J' R
6 g% r* t) E6 S4 o- #ifdef EDMA3_DEBUG' P- p1 [# T7 n( e0 E) U/ m& d
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( |- n7 \" m) E9 u9 D4 f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 F/ }* @: \( x, Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 n9 @9 W5 T! A
- #else
+ Z' g' v- m6 p# u! X( K8 k - #define DMA_PRINTK( x... ): g3 T7 X6 h4 A6 Z. v# L& M: a
- #define DMA_FN_IN5 p% q9 j- M+ \
- #define DMA_FN_OUT; [& a6 `- i: @# L# Z2 l% d; L
- #endif
* t( h4 q* Y; M
* I) }: e3 S+ y+ R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) @2 \& p" U: W. `- y1 S8 _ - #define STATIC_SHIFT 3
; U" |0 _6 d- V" T4 ]" e - #define TCINTEN_SHIFT 20
5 J5 o' g, c6 n! Q( Z( a - #define ITCINTEN_SHIFT 21
9 w9 G/ t5 |8 ]( E - #define TCCHEN_SHIFT 22
* `; E" l% v+ H* p/ {" A o - #define ITCCHEN_SHIFT 235 X* y4 p" T9 V+ X
- : N! r/ h) ~3 J& P
- static volatile int irqraised1 = 0;- x( A9 \! d: p% y" s
- static volatile int irqraised2 = 0;/ k* J2 G) c: ?6 f& A' q; G
. y8 ~6 a }! C1 W- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. K7 Q/ x; {! s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' e5 |4 Q: m# Z G9 e& T - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
z+ I9 L" D1 {: }" [! R$ N; e! t3 p - 9 ~* g7 R; ?- N y+ w, N+ Z
- dma_addr_t dmaphyssrc1 = 0;
0 W+ a/ i# x: `: R& s+ _* o - dma_addr_t dmaphyssrc2 = 0;, H1 L0 [" _: [1 B! X& A
- dma_addr_t dmaphysdest1 = 0;
5 M$ I- n( l3 n; L- Q; v - dma_addr_t dmaphysdest2 = 0;
. ~+ ]2 \1 }0 H0 x* z
* l" Y5 h3 N0 q$ j; q' B' |2 f8 H# p# L- char *dmabufsrc1 = NULL;
1 L, }% F t$ G# y" v% ? - char *dmabufsrc2 = NULL;
1 [5 M; K* N0 B7 O% m! P. {( I( e - char *dmabufdest1 = NULL;
7 M) z# g& ]% x/ [: ` - char *dmabufdest2 = NULL;
2 i2 D n2 x4 m7 |) M - m& Y9 n4 I+ j- {, e
- static int acnt = 512;( I* y- P, ]) q" N
- static int bcnt = 8;
1 q H* J& f6 x+ X Z - static int ccnt = 8;
3 j8 P) a8 ~9 W0 y. k4 z0 n2 o - v# |5 D2 z3 b+ M$ f% ~5 B
- module_param(acnt, int, S_IRUGO);6 |; M" D/ ?( f6 s2 Y* D
- module_param(bcnt, int, S_IRUGO);( ~7 K3 O% V- Y9 f+ G
- module_param(ccnt, int, S_IRUGO);
复制代码
5 {5 c* @# V7 W$ f
" o& c- [, Z' l5 g3 v$ Z$ n 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) R2 g1 z9 d* V6 x- Y7 ~( iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 V0 D" `# F8 D; W! {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ R* ^9 K1 \. a! t' D
8 J$ S- w. {! k% Q/ N6 _* d& D- e, c' D6 B& @- V
|
|