|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- f# p4 B1 p# T' K3 g; d- [code]EDMA sample test application. f! g9 V* X) q n. q* t% R
- /*
, }# A% N/ l2 F8 |6 a - * edma_test.c
o1 p% o' S* V: R - *$ l9 m+ h( a$ B& e, o) v
- * brief EDMA3 Test Application; C" v4 Q9 ~/ {; Q( y9 w' T% e
- *
9 C, A6 l/ q& l/ y. D - * This file contains EDMA3 Test code.
$ C; t+ g6 c# X - *
2 J$ @4 r, v( o" }3 R; \9 t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 c. J" e0 C) N" U% z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) _4 n- A; k0 q - * TO CHANGE.
$ o; T' _( T( i) Y - *
% o7 j) Z) `, c y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# H, c/ q1 T. k3 [2 L% ^$ V
- *
0 q: Z. h# {8 G) c( [5 S2 c - * This program is free software; you can redistribute it and/or
F; v8 _1 L$ Y' x0 j - * modify it under the terms of the GNU General Public License as) h# T, Y# R ]! ?
- * published by the Free Software Foundation version 2.
* K/ Y0 f- {( t. ]! W* N/ M - *
- p+ L8 i) u+ c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( h& h4 {1 K* `$ r C& E
- * kind, whether express or implied; without even the implied warranty& ?5 _ x9 Y" N7 Q1 ]" l- u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 B' z- a" W8 I% T. j
- * GNU General Public License for more details.' ~/ H: y% z: ?# D
- */
+ P3 Y7 h7 W- t1 X. J! p* M O - . n$ w; Q0 s( K+ K4 \3 O! M" u
- #include <linux/module.h>+ R0 J& V$ |/ X$ l& Z! ~8 P
- #include <linux/init.h>
1 Q6 e+ n, W) G - #include <linux/errno.h>5 X7 B3 b" z z
- #include <linux/types.h>" G. H# i4 q+ \5 m6 u. I% W
- #include <linux/interrupt.h>
9 z/ |6 P' c$ o- M5 Z+ N- H4 J& t - #include <asm/io.h>
6 {1 y( E3 o: ~/ q* i0 n" L - #include <linux/moduleparam.h>
( T ?, {% `+ L: J$ b - #include <linux/sysctl.h>, G/ u- m$ F, ^: |# Y7 J
- #include <linux/mm.h>* Q* `0 l. |/ `, ]+ g( d1 i
- #include <linux/dma-mapping.h>8 V& f: ]# x( U4 E
- 8 ^: {/ \- d% ]! O3 ?
- #include <mach/memory.h>
* f3 q% \9 L# R! U( A2 Z# H - #include <mach/hardware.h>4 U# r5 ^4 j! g1 O6 {- [5 d3 b" B
- #include <mach/irqs.h>. Q' ^2 U( \, h4 F7 G0 A6 g7 j& i0 S! Q
- #include <asm/hardware/edma.h>
" P, @/ B6 [! _9 T
& \( [9 J2 [4 N1 ^/ {3 z4 i1 N- #undef EDMA3_DEBUG9 \% Z8 z; k1 Q1 k% l
- /*#define EDMA3_DEBUG*/* w+ P7 |# w' c: |2 v
- ! Y/ q: P' ~4 E9 l7 k4 m; G
- #ifdef EDMA3_DEBUG
+ M: x" l7 M, Z8 u% g" E- \( w - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), O5 a4 O- Z2 D6 b t6 s
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 X, S0 Y' z# w# u: o/ n* l - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ f8 I" R6 a+ l - #else
& o4 u9 A) q: _ u2 z - #define DMA_PRINTK( x... ); N( r( J/ R6 G9 p$ f/ z$ {
- #define DMA_FN_IN
w6 h- ?/ `6 c: t - #define DMA_FN_OUT6 c. a( `/ d U% R* |+ n# H
- #endif
1 j& G8 ]. |: J( M - % z) t8 {4 w9 Y8 P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 w |( O4 D" j4 m$ P - #define STATIC_SHIFT 3
5 e5 @) K+ |. O# P p% S' V - #define TCINTEN_SHIFT 20 {# c0 @. g9 M: X
- #define ITCINTEN_SHIFT 21
7 @+ p5 t3 N$ ?! Z# s - #define TCCHEN_SHIFT 22- O- {3 z! _) ~. q- Y3 }8 s/ z
- #define ITCCHEN_SHIFT 23
4 F& U+ X; d7 I+ I9 s& `4 c
* C- L$ b3 e; v! B$ n6 B- static volatile int irqraised1 = 0;8 @# ^" T) `4 x1 m9 h8 s+ K. W
- static volatile int irqraised2 = 0;
/ F$ e' q# }8 P# W8 T
5 ^7 _$ O7 v$ G n# ?1 K- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 h& O9 T6 n! c) @
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& [" S. t: K7 S6 ~! y- r2 v - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' _' i0 W0 C$ L( r) V$ H
- 9 ` W I1 I: R# y# ]6 k
- dma_addr_t dmaphyssrc1 = 0;
4 A$ S1 ]5 u; w# ~; K' ~7 Y - dma_addr_t dmaphyssrc2 = 0;* U' Y9 O! @5 E M
- dma_addr_t dmaphysdest1 = 0;
; B4 U; d& H( g9 Z) }& e5 o - dma_addr_t dmaphysdest2 = 0;
/ G/ J# K. B2 O' x x0 E2 _
% s% n+ _: ]' U6 i5 V- char *dmabufsrc1 = NULL;) @/ U1 h3 L; j x
- char *dmabufsrc2 = NULL;1 @ `0 |! g, f H& E$ I
- char *dmabufdest1 = NULL;* u9 j8 M" Q& U( o7 W" x( d; r
- char *dmabufdest2 = NULL;
$ k) c- ]5 Y( `$ I: Y) q& X# B. K t - , R: N' S( r0 c. b0 n: i+ J) v+ I
- static int acnt = 512;
* `2 \3 y2 l9 B; m6 b: A - static int bcnt = 8;+ Z8 E6 C K0 E; ^$ v
- static int ccnt = 8;
5 ?+ l- J9 }9 Q5 l$ C
5 D1 f3 r; ~$ S t3 z' E- module_param(acnt, int, S_IRUGO);" z, H0 @: K6 d: z# t9 z( n
- module_param(bcnt, int, S_IRUGO);6 F- H. w& r3 [) g( A: j. H
- module_param(ccnt, int, S_IRUGO);
复制代码 * }& V2 K: @& l! }
- j0 W) q/ z+ w; v 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! _( u- S, o: @0 Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* s6 i) _6 |6 T2 Y4 @4 N& n, I
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 @' X5 n4 T9 o3 e( x
6 V9 A" s1 r; { ^, a$ u4 t! }2 }
2 ?4 _. i. p: M' C9 {( C1 m( Y5 [$ B& x |
|