|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. S9 L6 \' f: X) V& h2 M- [code]EDMA sample test application2 u$ @$ J0 M0 A! r1 o i/ P }
- /*
9 w% L( s( t0 `( z - * edma_test.c" c k' _$ u/ K: ~
- *& u! i" E V" f5 u
- * brief EDMA3 Test Application
* S% z; g" o# {9 _% y0 w! ^ - */ O2 m7 b" X0 e+ R
- * This file contains EDMA3 Test code.0 j3 `% b+ k" C% u0 K
- *
$ C. X1 }7 f5 F - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ v ^7 H: r) ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# t: ~# B" ?8 y: a) m6 n# L+ N9 [
- * TO CHANGE.
9 k0 l" c# N* ~5 V9 e - *
' V+ o4 N( L* f' p7 _. [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 }1 d/ ~5 Y+ N0 @6 O
- *
& l' C% N, E; q) ] - * This program is free software; you can redistribute it and/or. D) f# B" E* n R$ \6 U& U. ~
- * modify it under the terms of the GNU General Public License as
4 }4 H+ N [- U6 F' m: E: a9 p; { - * published by the Free Software Foundation version 2./ Y- M2 B) u: o
- *5 G) @/ U) c9 o/ [! u; [0 V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 z0 Z- j1 F7 l! W - * kind, whether express or implied; without even the implied warranty
/ Q" w( k% N( h1 \- `: b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# H; {6 n) o0 O( t" |: @3 t - * GNU General Public License for more details." h% x$ X/ e) ]. T
- */) c- D, M$ |1 ?0 D( M( x" T
- " f& e* }" ~1 B, H4 }
- #include <linux/module.h>+ P6 F- e) r* g% a
- #include <linux/init.h>' G, j* `( z4 w. W7 z
- #include <linux/errno.h>7 D4 O/ ^0 m% ?; P4 y
- #include <linux/types.h>+ A- I/ h3 H0 o* }8 Q* T6 q7 x
- #include <linux/interrupt.h> L9 S( `4 S* s5 @
- #include <asm/io.h>: @1 V: t/ {& U: n$ w7 L! x5 A
- #include <linux/moduleparam.h>
v7 a: b0 ^/ ~1 v1 o) i, N. k$ z - #include <linux/sysctl.h>- T* v# N. H t
- #include <linux/mm.h>
' D+ H) D9 @3 }/ @ - #include <linux/dma-mapping.h>
9 P. S1 J" y: a, |' |. f* Y- N* n* Y' m7 E - 8 v7 l4 ], X- N# W# \) D
- #include <mach/memory.h>
7 ~: G7 [' i! c - #include <mach/hardware.h>" M7 J0 Y, W$ Z; p1 M7 F3 C
- #include <mach/irqs.h>5 f- W( B/ f1 l8 C" v
- #include <asm/hardware/edma.h>/ {0 j5 Q6 v2 J+ i6 y5 |5 c
- , [% P2 x3 M" |) s6 x2 ^9 c" k- i& ?
- #undef EDMA3_DEBUG7 r8 p/ ?) O$ }
- /*#define EDMA3_DEBUG*/6 Q( q4 K l* r% R. B) s
- 8 g( N: O4 o5 O; V4 W8 ~
- #ifdef EDMA3_DEBUG6 f7 }5 w2 t, V1 j3 ]) A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# W- ^0 C( w5 ]& | - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. f3 L& I- d! } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& E8 z. d. J3 t' u& C1 r$ |% }
- #else
& s" t0 w$ o' ` - #define DMA_PRINTK( x... )
9 R3 l5 M. P' S$ i& e: t, @ - #define DMA_FN_IN8 j6 Z+ E1 C% b9 e% _
- #define DMA_FN_OUT+ z1 P% m. O; g9 z( a8 W. K
- #endif
d8 L) K0 i1 {- Q$ e2 }
6 x( ], \! }; y n! ~- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- q, `9 O. U) b Y) i1 a
- #define STATIC_SHIFT 3
- \# R( j- A- V - #define TCINTEN_SHIFT 20
+ R9 M o2 a- ^' m: s+ H4 y, ~, v& X - #define ITCINTEN_SHIFT 21
) P. {0 r7 h3 U: ] - #define TCCHEN_SHIFT 22
/ V' R6 L4 g; l& y5 e) f0 w& w( f& D - #define ITCCHEN_SHIFT 23$ R6 S/ A4 F0 T. ]# ^7 l8 \, `
- : w1 y# n2 W; C
- static volatile int irqraised1 = 0; w0 c. r7 s5 q, |8 [% ^: m( A
- static volatile int irqraised2 = 0;5 L2 a' |' n( q* _
- + \$ L7 D" a2 b2 w# }' |$ S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 }3 m: L$ H3 U4 ` - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 C6 e! `0 o4 J5 D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 }# @# t# J" ?3 V W: q - / {5 W/ C7 X% m- V
- dma_addr_t dmaphyssrc1 = 0;5 o1 |) [/ c k$ I+ t
- dma_addr_t dmaphyssrc2 = 0;: c7 u; @: N/ y: q" W
- dma_addr_t dmaphysdest1 = 0;
7 C+ {3 f$ `9 M& c' n$ M - dma_addr_t dmaphysdest2 = 0;+ K0 ^1 I( P0 k' v9 H
+ F' d" R. C$ c- char *dmabufsrc1 = NULL;
7 A" S0 b( O5 c. H - char *dmabufsrc2 = NULL;2 T$ [- ` ~( _/ g
- char *dmabufdest1 = NULL;+ U; T* {6 v) e. a4 w1 y+ o
- char *dmabufdest2 = NULL;
2 C( R/ Q) Z0 b x, P9 ?+ t0 [- p - : d% m+ D* R; p+ f: e& ]
- static int acnt = 512;1 {5 [2 Y4 @5 U
- static int bcnt = 8;
; M, y" r+ u" H. y6 u5 f - static int ccnt = 8;
/ y) [2 w* |7 T/ e& X - ; P0 s) k9 v7 W8 Y& y7 x) O4 p/ W
- module_param(acnt, int, S_IRUGO);
: k! O* e! Q8 d6 D+ G! c& \ - module_param(bcnt, int, S_IRUGO);% U" q1 [! z4 Z6 [( e
- module_param(ccnt, int, S_IRUGO);
复制代码
0 Q6 r: ~7 t0 S9 N+ k9 o! k. _2 l
" g4 r; X' x5 J7 R4 } 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 q# ^8 d# i& `& ?+ o7 N
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ {) m" Q1 X& k, d3 o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ ~& ]7 a9 V1 o3 b( T4 C2 T7 y9 r0 B7 Z0 c, ?
, y0 K# s: K" `( d
|
|