|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 M! y w9 T6 w* K8 C- r5 N4 i- [code]EDMA sample test application
1 H% f1 \$ @- E: \; U1 i1 @$ v - /*2 R3 ?6 G% n9 v3 a: P1 l
- * edma_test.c* ~ n" K+ p" D [
- *
4 x+ o/ ~7 R( ?, |0 [& O6 M9 K% ? - * brief EDMA3 Test Application' U7 A# r5 M9 F# T
- *
- j: l- H% N8 w% ]: U - * This file contains EDMA3 Test code.
) D& P- }& P' f* n& C* O - *
! V9 z; n. i# w - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 X0 l I# Z2 b) E
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ N; H- O# J& T - * TO CHANGE.
7 J) K' I1 |7 O7 f* J3 x O. z - *$ p. L& t( m# I1 ], ]6 G6 o' [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: I. Z1 x' H$ Q4 D
- *6 s4 h# z+ d! K9 h0 x( j
- * This program is free software; you can redistribute it and/or
0 `; Z: e E: R0 ?8 \% w" X! A* | - * modify it under the terms of the GNU General Public License as
! }7 B" ]+ p& s# H4 } - * published by the Free Software Foundation version 2.: k/ A! i: F) u4 j. K
- *
" E2 T0 [' o$ }) f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 J5 B; r! S/ g2 _ p/ f& [
- * kind, whether express or implied; without even the implied warranty' q' E5 U7 Z1 S: l1 z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% Z, _! N$ l* { D% }5 H9 E5 ?, e - * GNU General Public License for more details.) }+ v4 }5 |; j& u9 t
- */
4 x2 N0 L) Z+ \+ ?, X; U
8 P- V; `% m6 G- #include <linux/module.h>
& d7 b" R1 P; s: l - #include <linux/init.h>3 P/ N: }! @3 w t2 ^
- #include <linux/errno.h># A8 C! ?- Y& f- h! i& t( b
- #include <linux/types.h>; i- S( b5 C* ~$ B) v t& f
- #include <linux/interrupt.h>
6 K3 `0 I0 H" ^! U, K1 W8 d - #include <asm/io.h>
9 W6 E1 I! L, Z! g" f' P - #include <linux/moduleparam.h># u4 {8 D* K) c- b) y2 u" H+ F
- #include <linux/sysctl.h>
) L1 u( d6 x. r4 m1 G9 @% v - #include <linux/mm.h>- \" S& Z7 y% p) s- w6 v9 u9 g
- #include <linux/dma-mapping.h>5 X6 X8 G! P. f! ~" a
- ( u+ z6 H: f- k* x# S. J
- #include <mach/memory.h>
( T4 Y$ t3 b& F6 ^; V" i! Z9 B - #include <mach/hardware.h>
5 e$ B) |/ q$ W6 e0 x - #include <mach/irqs.h>
* _1 I1 G& g! d$ p2 w: C8 [) N - #include <asm/hardware/edma.h>" M2 p' Q7 Z! c4 a/ C
- - V6 J: _/ u& D! r8 l! b
- #undef EDMA3_DEBUG
& u) A; E! O' m1 f. { - /*#define EDMA3_DEBUG*/
n7 b, L7 X3 |2 b/ R$ A& G
- @3 K+ q* R' ?- #ifdef EDMA3_DEBUG8 q/ V5 _( x9 c' u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), H% r; g. N2 n) p2 W# F9 h
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 ?. T. b" ?4 i* L$ b: S; Y# O/ T
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ o* ?: l2 F# g3 c
- #else( m4 f" J8 {+ ]& r! y/ m. S% v
- #define DMA_PRINTK( x... )1 `1 U2 Z4 k, J
- #define DMA_FN_IN6 @0 o' x+ Q- Q9 J( P
- #define DMA_FN_OUT
" ]1 F. _" p( l: z& y ?7 J2 x- A - #endif
8 W2 c4 K, X% ]. l( F( H - 2 C# }# n" G1 ^# g# {$ y# [% u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( P3 m, d4 a5 q0 R: i& w0 E - #define STATIC_SHIFT 3
8 t# e$ L5 v8 I! O/ f - #define TCINTEN_SHIFT 20
7 D4 C3 u8 I2 c6 s/ e5 k - #define ITCINTEN_SHIFT 213 S; I' T! l% D7 P4 l% r
- #define TCCHEN_SHIFT 22
$ T! `; b/ ^$ ~9 }9 ~ - #define ITCCHEN_SHIFT 230 v' b) D2 G0 e# B. b S3 s
- % f1 \8 {; T" J8 B. x4 U
- static volatile int irqraised1 = 0;+ [7 |; G& Y3 c/ {% ]$ E* w' a* V$ \
- static volatile int irqraised2 = 0;( Z5 G5 U) _ l/ T k
- 7 j5 g3 w$ s. l L) ^" E* Q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, Q- q, V1 I2 }; L2 C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. j2 a- E, G: P- G: O, c - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 |3 v. Q3 P7 i+ [. ^0 _, X
% Z6 i5 d1 ~0 q, [, {3 A- dma_addr_t dmaphyssrc1 = 0;5 g; k: w& B2 ~0 ?: M# r
- dma_addr_t dmaphyssrc2 = 0;! J2 ~9 |. ~% i
- dma_addr_t dmaphysdest1 = 0;, U$ g8 A5 h' U9 S
- dma_addr_t dmaphysdest2 = 0;
+ f1 J- f S9 d* i# m* j
0 I3 P/ V) k! O6 f0 K8 `- char *dmabufsrc1 = NULL;
0 E) v% c2 \- m2 J - char *dmabufsrc2 = NULL;8 J5 t8 j& G9 D t: r' D
- char *dmabufdest1 = NULL;
) j" X( o, w: B - char *dmabufdest2 = NULL;# w! N2 Q$ s+ b5 } h
! J' S. n) J$ c9 F- static int acnt = 512;2 w. s8 P# b! Y
- static int bcnt = 8;
; z+ \. y6 s/ |! H$ k - static int ccnt = 8; [9 c1 u, j9 s5 f7 W% f
- % t! j. O0 F p% ]. H
- module_param(acnt, int, S_IRUGO);+ i, Q& Q! J" e9 Q$ f1 r6 Z7 E
- module_param(bcnt, int, S_IRUGO);7 ?/ m, Q+ }5 z; l6 F& ]
- module_param(ccnt, int, S_IRUGO);
复制代码
3 _" c+ B, V* X/ A/ h6 S4 i& @+ D R. \( _1 t2 I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 [- s. b8 L9 a0 P, R5 B! I" parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( L# M+ P7 i) }! b2 R f( V7 B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 Y' }# q! {9 ~) l
& ~6 H# [) Y! W& T: G2 p
6 n# z# p/ o6 P4 O2 x( t |
|