|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& e z6 Z. T) I# W- [code]EDMA sample test application
; i* p6 \& b- h# h5 I/ ` - /*+ K# v! W+ y+ E
- * edma_test.c: L$ l) J$ T5 G/ e: G
- *& M4 A/ x# S. E2 P" u$ a" R8 t) n
- * brief EDMA3 Test Application
. R+ u3 v: ^$ ` - *$ Q3 b U; L! g
- * This file contains EDMA3 Test code.
* I6 Q0 O% {3 E8 U% b% d3 a - *& f3 l [4 M7 }1 V4 u
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 W# n( c9 m6 A4 q# u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ t. F' t# H5 G* N6 d. @. m( P8 x
- * TO CHANGE.' b0 C0 n% [! N" {2 Z6 x8 c2 I
- *" @; R' t! ^! k( o! B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 _- a, s# J: m
- *6 b; K6 L/ ]0 Z( v0 f$ r/ c
- * This program is free software; you can redistribute it and/or1 Q" f h; A. m/ [
- * modify it under the terms of the GNU General Public License as
; v+ r. J8 V7 v# T0 {$ ~ - * published by the Free Software Foundation version 2.
1 a6 u( M7 u: [* p* M7 I - *2 b+ W& f8 A v
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 t/ b; J2 r J& | - * kind, whether express or implied; without even the implied warranty
& K* l! i* z8 W - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- x. G% [6 w5 g8 e& H, D - * GNU General Public License for more details.7 O% h5 ]' s2 x, I- {8 I
- */! ~/ T( Y1 l1 M) j0 J
- # Z1 P3 H M! m1 E0 ]2 W7 n" g
- #include <linux/module.h>! X( t! \$ L) ` w8 w( t E4 J
- #include <linux/init.h>
" }+ o: {, P6 X: x# Q+ G - #include <linux/errno.h>
+ Q( P8 k( E! t5 a9 q - #include <linux/types.h>6 A9 y2 J0 ^4 U0 n9 o3 O/ b8 @
- #include <linux/interrupt.h>
/ [3 o/ A3 u6 L0 u. x - #include <asm/io.h>& I' S. e! A9 }+ m3 r7 H z
- #include <linux/moduleparam.h>! n1 m; S( P6 {. @% x2 ]& L
- #include <linux/sysctl.h>
6 @) }$ E! z! M3 @6 } - #include <linux/mm.h>4 Y% E* x2 k4 ~
- #include <linux/dma-mapping.h>
4 `0 a: o3 G# f* t/ I6 ]1 a, |! l - ( T0 F# T3 `' B+ N6 C3 [/ M& e) O; A
- #include <mach/memory.h>' O& a# ]( F5 S' _- l
- #include <mach/hardware.h>
9 g5 [( A5 v1 v# t3 O7 {0 ^ - #include <mach/irqs.h>$ Y/ G% L6 X, k( `. s
- #include <asm/hardware/edma.h>
/ q' x" R7 Q9 ^, i) V: {" K7 A
0 w; t6 m' k9 c" x; d- #undef EDMA3_DEBUG9 d ]- H2 V; l* `6 c
- /*#define EDMA3_DEBUG*/3 h3 W0 T& e7 u) L& T3 Y& B' @0 l }
- ; v# w `* H6 \" a
- #ifdef EDMA3_DEBUG
+ H1 x+ F" m/ W+ H! v. x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 N K1 Z- z- R
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ `* Y- a _( j8 @/ w5 F
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 J; G% U! \4 S }3 g' D4 ` - #else* a0 J% }1 h0 a: b
- #define DMA_PRINTK( x... )) R N6 _& }+ r# C8 q1 V6 k/ n
- #define DMA_FN_IN
* S( J$ m! a1 I0 f7 ^$ z; b1 K - #define DMA_FN_OUT2 p7 K! ^- u& Q* P4 b& k: E2 F: x% A
- #endif2 `6 u$ V: v9 C% S! e2 E$ c; t! j0 J
A+ v3 k* B: B8 W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ [9 _7 e5 A" ]8 Z" V/ u' { - #define STATIC_SHIFT 3; k" Q" ]* S/ l0 {
- #define TCINTEN_SHIFT 20
% W" ]0 z1 B2 Z2 J5 r- i - #define ITCINTEN_SHIFT 21
' t% g1 L! ?3 ? - #define TCCHEN_SHIFT 22
2 x" V' _9 `- N6 g* y$ y+ d - #define ITCCHEN_SHIFT 23, |0 I0 I! ]0 C% ~* s8 I& @/ n
6 R4 q% n4 t* }9 F- static volatile int irqraised1 = 0;
$ ^4 B0 ~8 l9 r# K2 u- J: y - static volatile int irqraised2 = 0;
/ v: Q4 N& e- S" V- A - ; x! C# U& q6 Q! q7 G( d: z0 L8 Y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 P$ y8 a" w2 A/ ?5 F - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 ^$ t! y1 y7 a; B7 C/ N. G- ~) U( e$ w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 u) D5 s& O' v" l0 ~. B - # s# j. [9 p0 T6 @& N& ]
- dma_addr_t dmaphyssrc1 = 0;& S! e% {& P0 D, c2 E6 S0 H+ w3 j
- dma_addr_t dmaphyssrc2 = 0;1 \- D; T" o, v. V
- dma_addr_t dmaphysdest1 = 0;
; I, m4 p3 Y2 t" O+ x% m8 ~! Y - dma_addr_t dmaphysdest2 = 0;: i8 U& q8 h/ W2 Q6 |0 u3 \: @4 A
+ A* P. Z( M/ a- char *dmabufsrc1 = NULL;
1 q" U; h. R- T4 S. Q - char *dmabufsrc2 = NULL;$ H9 F. y9 {0 S
- char *dmabufdest1 = NULL;
) @0 ?5 J# g6 S$ ^5 Y' S- ? - char *dmabufdest2 = NULL;
/ k; c& N- N8 L1 _4 G8 B - - p: D' _8 a" K4 A. A5 K
- static int acnt = 512;
) v! l* w' C) E6 `. [ - static int bcnt = 8;
# w$ G! c( D3 T; i( | - static int ccnt = 8;( }# D3 z7 ?$ ?' e9 }; P
) @! E5 u, U) n6 \0 P$ r, y- module_param(acnt, int, S_IRUGO);* @% k; j9 |: `
- module_param(bcnt, int, S_IRUGO);2 n& s9 b) y, R" S
- module_param(ccnt, int, S_IRUGO);
复制代码
6 K9 \2 w) j! L' z3 D. E2 }6 ^* P' f$ h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 v( {/ T* o: U# S9 A1 m8 B
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, e7 a' o5 Q; o) W$ i3 L. e 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) K, i+ E8 [/ J+ E* `+ z. M# v
- B: m+ t( f; |& d$ v/ T
% w* a* z5 `6 S+ u
|
|