|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) ?4 s2 M/ Z# e8 k- f' u" z
- [code]EDMA sample test application
# i8 N" V* h7 }6 }& w+ j1 d - /*
4 j- t. N2 N' f( V6 K$ j - * edma_test.c, x& B$ c: P6 ~
- *
. r) Z" {" C0 ?/ U, _+ _' y' L( V - * brief EDMA3 Test Application) B7 B9 R1 e' w* Q4 a3 `
- *5 t" F$ {2 e' d H0 Q: I
- * This file contains EDMA3 Test code.1 K% O% |4 ?- C6 ^7 t E$ ]6 I% O
- *
0 e" F. z1 g2 m' k$ I* q0 ^5 z- U - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) P& N- l7 z6 C' E% _- L' Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( k2 K* H, P3 f! n - * TO CHANGE.
3 d: \% I. a* _1 w( ` - *
+ ~. Q. w) H6 n4 t/ D& m. h/ K+ a# d, a - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ ~# T. Q/ I& |2 s) }( l$ u; F
- *
$ Q: z7 k3 [8 F' i - * This program is free software; you can redistribute it and/or
4 R7 I/ m( ^- s1 k# Z - * modify it under the terms of the GNU General Public License as3 u1 K( m$ ^/ W0 s# s o4 Z& X4 s
- * published by the Free Software Foundation version 2.
7 t! H3 i5 \0 D" j, D - *1 e' n& o9 P3 q8 h7 `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 e( K+ _1 Q0 N5 u
- * kind, whether express or implied; without even the implied warranty
, x5 F! u* a: g, V$ C- h+ g' y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 I. r Y4 U9 {2 H* c - * GNU General Public License for more details.: x6 m4 F2 V u, E v, h! Y% d" {! t
- */
. Z. [ z1 d6 t" z" N$ ] - " E0 X% L/ T7 g2 s( t% w8 h8 Z
- #include <linux/module.h>
! Z# L7 v2 O' {5 Z5 o2 M8 t# f - #include <linux/init.h>8 V) t1 Q0 Z l) g$ O+ k% p2 n; I
- #include <linux/errno.h>' Y t" F+ P) i- x+ Q
- #include <linux/types.h>1 Q3 A/ r' D* c
- #include <linux/interrupt.h>
; c1 h& X& e+ _4 ^ - #include <asm/io.h>
2 Y. i' \* d! E$ C7 Q6 \ - #include <linux/moduleparam.h>
# W+ x( {' P( P4 j( E" U; B. V - #include <linux/sysctl.h>
# [8 Y; Y: [# l Y( ?! `, J - #include <linux/mm.h>
; i, k8 t! ]4 ~8 m. | - #include <linux/dma-mapping.h>- P/ D" K9 k, a! C
1 E( L/ s7 J& S3 D- #include <mach/memory.h>& A8 P& x! q2 C; u
- #include <mach/hardware.h># {# M0 Y# c4 T, }1 a5 |7 g6 y
- #include <mach/irqs.h>
, w- f; q; _ H Y+ P - #include <asm/hardware/edma.h>! |. {" h& `' a7 j! q
2 {7 ^. q0 m2 g) D9 j- #undef EDMA3_DEBUG8 b; S% h( U3 j4 e4 ?
- /*#define EDMA3_DEBUG*/; L0 v& G8 |2 n
- 3 T1 {# x! b- K: a! J
- #ifdef EDMA3_DEBUG9 I2 t$ f7 I& S5 w5 p* ]" s' t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' O+ K4 D# h/ w& g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ ]1 V; J9 C. |5 S8 H( m - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* `% ]- ]" g4 I* |- a6 W9 p/ U
- #else7 K3 p: v: D9 ~
- #define DMA_PRINTK( x... )
+ ~" p/ \! [) m+ O% z/ b/ O7 J - #define DMA_FN_IN
$ ~8 [& r8 |: Y/ t: b( q3 i - #define DMA_FN_OUT! Z U1 {( s" @9 J ^* h$ X
- #endif8 T, [- B: D% O' M* E( J/ f
- 1 I" z I# @; N0 P) j' c. \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 |& N' \' X3 c" I$ h6 W - #define STATIC_SHIFT 3
4 F6 d+ n/ A% o# ?8 N8 A) N; D - #define TCINTEN_SHIFT 20
( [+ g/ P( i* i. y+ d: ^ - #define ITCINTEN_SHIFT 21
% Y$ n1 n0 e6 L3 F) ^1 B( _ ~ - #define TCCHEN_SHIFT 22
/ M, C6 [0 t$ e! d6 v4 Z - #define ITCCHEN_SHIFT 23
! L: g, d$ x; Y5 r; n - 0 C) x+ t9 ^. W9 I6 z. n
- static volatile int irqraised1 = 0;
3 p3 b( M, `# J. n% e0 {* M5 u' \+ P - static volatile int irqraised2 = 0;- ]( F# k2 L7 B7 l9 J" H
- ) f' d2 m0 d1 g1 U2 t
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! |1 Y" f+ b1 d1 i4 C* [* V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) l' |9 n# F' Q' S7 [% o - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 A8 i6 r6 r; K' t, I2 E7 j+ W - 7 q, K) H! ]5 Y4 q4 M
- dma_addr_t dmaphyssrc1 = 0;5 x& \2 @$ J0 O& S* {( Z6 A; `
- dma_addr_t dmaphyssrc2 = 0;
6 d- V. w2 G! q% a - dma_addr_t dmaphysdest1 = 0;" s- m7 }0 _. L. V5 z
- dma_addr_t dmaphysdest2 = 0;/ O. ?) n$ m7 y; w' i& h
. x3 j4 b8 F& Q- s2 q* B- char *dmabufsrc1 = NULL;
' x. j$ o. e. s q - char *dmabufsrc2 = NULL;6 T" }5 e9 {$ r( r3 Y Z+ m2 O R. q f
- char *dmabufdest1 = NULL;7 p2 X; ^' P4 j2 C e+ g/ C. A
- char *dmabufdest2 = NULL;% H' Z% p9 `! L8 w. H8 t8 t; B- P/ Y
. q1 a; l: \3 H8 ]7 k: h- static int acnt = 512;3 B& N* D; t9 _+ R" f! a9 Y
- static int bcnt = 8;
. ?) i9 j% M; W: G3 c - static int ccnt = 8;
) U0 e* V# I8 n0 T* q - , M# \% T) g- B) v C, q
- module_param(acnt, int, S_IRUGO);. R1 I1 Y& A5 j. k; t: [
- module_param(bcnt, int, S_IRUGO);
: l' S" B$ i) L- t/ b3 J; F - module_param(ccnt, int, S_IRUGO);
复制代码 ! N* g& E- H/ `/ [* R
7 z! ?9 i/ y( U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ q* y/ t& G4 O& tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: Q! Q# Y# y2 O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( p- W& U5 b! ~ e! _' H6 \$ S1 C0 k5 Y) V5 |0 Q* ?4 c8 }
+ Q2 Y% N7 i* u: S; D/ v+ ` |
|