|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ J6 ~) D0 u2 p" q- [code]EDMA sample test application
! a- T+ u3 F' F' a: Y5 r - /*1 p( W& |9 k, A& S
- * edma_test.c
. L& u8 \% R6 v: H+ [ - *: x: B8 ^& O4 i8 z) H7 d& L
- * brief EDMA3 Test Application
0 K+ l3 c5 W. M. J c& x - *
9 j2 j' \: @( i; p - * This file contains EDMA3 Test code.
# ]* E# @: a4 c2 E+ ^# l - *
% Z1 ~# c5 E8 Z; h; {. D - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" B5 @3 i5 R3 E
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 N5 @1 f" Q8 D, p' j; L - * TO CHANGE.
- j7 E& f! A/ o0 u1 ] - *# @7 X0 U! ?& g: d" z8 n. B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ W/ O5 }1 y/ l7 D: {" C - *
1 k( K. c" ?, T3 k1 W - * This program is free software; you can redistribute it and/or) Q' e9 W l# p! f* I- w
- * modify it under the terms of the GNU General Public License as& L, p. ~6 A+ T' T$ K! M
- * published by the Free Software Foundation version 2.
0 o! ?: s$ I, {9 p9 p: X) F - *: M' m/ D$ k9 j9 i# P0 |% t0 p& N# f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any e0 Z+ E, o2 O, @
- * kind, whether express or implied; without even the implied warranty7 ?/ h( D' m0 ]& W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 H3 [; {2 c& l' G. E
- * GNU General Public License for more details.( C" h% {) ~' Y K
- */: y% M# e" O# l5 ^
- 8 t! g0 A) Q; ^# X, D3 F) L
- #include <linux/module.h>& v5 L7 u) h: Z
- #include <linux/init.h>
3 ^+ p1 X. O+ M& n5 u- T - #include <linux/errno.h>
7 z4 M* J: a. l9 L- z - #include <linux/types.h>4 h% y) j7 @& m- p1 W, [$ L `, K
- #include <linux/interrupt.h>, _/ c: I4 J+ k- h! b
- #include <asm/io.h>
r/ p/ `. l; p" V: }0 ~* G I* a- a - #include <linux/moduleparam.h>
Q7 Z1 M8 y4 p7 { - #include <linux/sysctl.h>
' G, O- _, s1 ^& Q8 c0 k& l5 Y - #include <linux/mm.h>
9 U1 w0 U2 f0 W - #include <linux/dma-mapping.h>
" x1 ^; S( u- h) z' `8 B; n4 ? - 7 l# U5 a% O, Q9 X0 O
- #include <mach/memory.h>
0 x. v/ O4 q2 k - #include <mach/hardware.h>
+ o* X H) X* V* O2 d% Z% N' u - #include <mach/irqs.h>. V u9 ~" Y! u0 Y& e8 M9 g
- #include <asm/hardware/edma.h>' }& w# ]/ Q, A+ s# N1 Z2 k0 `
- 5 q. [/ c& E0 F, z
- #undef EDMA3_DEBUG
2 D% G' ^2 F# F: ` - /*#define EDMA3_DEBUG*/' D* X: t4 r5 I5 L. \+ J& D
1 i' _, B9 {* A* j& V% g3 M- #ifdef EDMA3_DEBUG) q$ u9 e" i9 i
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! W' H& L( b* t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* E' R3 B7 K7 N( v" D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 l0 I0 B: Z5 q. R
- #else& A2 y5 \& H& b( y1 M
- #define DMA_PRINTK( x... )+ `$ h1 ]( O5 p/ i
- #define DMA_FN_IN
8 W/ m1 z8 Y7 k - #define DMA_FN_OUT. Q: A* ^* ^2 `6 C/ u
- #endif
- O0 J6 n2 \) \) ?+ n - : v1 {3 w: g2 k) Z) K2 Z: a; L. T
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( s4 p: Z* F& q: o
- #define STATIC_SHIFT 3
: Y( k- s% s. Q" S( r+ i - #define TCINTEN_SHIFT 20, O- x# \0 y8 X" u# g
- #define ITCINTEN_SHIFT 213 O2 W& q9 L. a
- #define TCCHEN_SHIFT 22$ d/ j+ ]2 \5 d0 t R+ B
- #define ITCCHEN_SHIFT 23! q" U/ Q+ J+ {3 O& h
; O) j+ u# `5 f+ o- static volatile int irqraised1 = 0;# o- ?. I4 k) |) p$ }9 I* `
- static volatile int irqraised2 = 0;2 n: P* V7 k3 q
- ) w* o5 H& [; S. V! |5 V% \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
I% I0 D' V# ~" Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 P6 Y; W7 H# T
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; o, P, f* g! S' m0 I' ]5 X# x8 h - 9 U. h! y8 T7 l4 N- o3 X! L
- dma_addr_t dmaphyssrc1 = 0;
) N" }( u' p. B C H8 Y3 t - dma_addr_t dmaphyssrc2 = 0;) B5 R5 c! s( ]" J
- dma_addr_t dmaphysdest1 = 0;" d$ [' P# x7 b( r/ ` k0 s
- dma_addr_t dmaphysdest2 = 0;0 Z5 l2 J7 Y9 Q7 L! c) P1 L3 a; W' V1 U1 Y
- ) N+ F3 {+ N; b$ W2 |2 x' M
- char *dmabufsrc1 = NULL;
: R1 ]6 x" L8 b- X - char *dmabufsrc2 = NULL;
. X6 P+ C: t t/ x - char *dmabufdest1 = NULL;
& p2 i% u! p' I2 [! Q% s - char *dmabufdest2 = NULL;2 P8 `9 |- D8 a* n
9 o8 D9 T+ d' P# a2 |- static int acnt = 512;% j. h. {% `9 m
- static int bcnt = 8;: g8 H5 V# R. w
- static int ccnt = 8;
/ ?8 ]6 B& x, w4 H( [5 x
7 A) N' J/ |5 @$ L p- B! o2 I- module_param(acnt, int, S_IRUGO);
0 `& q: o8 n$ K4 R5 P* l4 o - module_param(bcnt, int, S_IRUGO);
* K9 |( S, w5 s' g& z! b" } - module_param(ccnt, int, S_IRUGO);
复制代码 , M) J% v3 F$ K, K
. ?8 N6 I" c0 w& }+ ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( S; k8 |4 Y) s3 H4 Y, Rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% a4 v5 N7 m+ d4 J% I6 R
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 u: T* d6 a7 L Q: l! N
d5 r5 u/ b% g" t+ D" l: ^, T1 @4 T/ S2 g& }" M( K
|
|