|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 R2 z+ v: e* h+ T1 ] g- [code]EDMA sample test application
: r: q- J" ]1 i! {2 h% @+ X/ \ - /*( q+ N2 v& M! Y) g
- * edma_test.c9 {* @# R* g" O! P
- *
) E$ [% P) A+ c - * brief EDMA3 Test Application' U+ r0 v# e6 i' }1 a3 z" h
- *
8 T+ E+ O! p0 \0 E* i* Y' d" _4 J - * This file contains EDMA3 Test code., R: G/ w3 |( X$ J6 X- O9 Z' {
- *' T0 O- k/ s7 p3 T/ r: v0 ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 J- `9 w9 ^4 k- ]% s9 p - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) B& R1 f2 }7 D7 p S
- * TO CHANGE.7 y- S. [. U( T3 t M8 q" M
- *
, T- N2 R, }3 |% m( S - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, J# }" D; H( J* f4 r
- *8 i. c" |# _( K% f: C# U
- * This program is free software; you can redistribute it and/or
9 J0 c2 q" w; Y# P. h: M1 n4 ^. h6 x - * modify it under the terms of the GNU General Public License as
u. n% l `+ _ - * published by the Free Software Foundation version 2., c" ?0 y/ K9 B/ D! v# y j
- *
5 _# w/ G' y. V$ N+ U: |( L. B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% K! F! d( q* I% |( G - * kind, whether express or implied; without even the implied warranty
" m9 t; Q. i. ~& _8 Q1 x* a - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* f1 A: Q! C5 A8 [# g
- * GNU General Public License for more details.0 Y- s7 @! u8 p4 \1 _& V0 p0 ?* `
- */
" z( ~4 c8 f/ }$ D
. n' m8 \: }. |8 g4 a, p- #include <linux/module.h>
* Z; f5 U7 {, h7 O - #include <linux/init.h>
. {; f9 n$ |7 \' | - #include <linux/errno.h>; K+ E$ X) Q/ Q' q1 X, Y
- #include <linux/types.h>, X) {/ q$ z" G7 S
- #include <linux/interrupt.h>3 m5 Q: Q- t9 }3 ^( M3 R& G
- #include <asm/io.h>
- B$ V: l7 q" |. U; _( K* k - #include <linux/moduleparam.h>
" u" C: L0 z5 R+ S9 {0 w - #include <linux/sysctl.h>0 v. w4 K, t% s/ a, d
- #include <linux/mm.h>
! {2 r; G7 }" P5 `# m7 a H - #include <linux/dma-mapping.h>
* M% C+ E" S# P4 t5 n
0 m4 p# |# q) m: [" K- #include <mach/memory.h>
: b! G$ b$ _7 b" ^7 o; F - #include <mach/hardware.h>
: X, A& B. o- ^! x$ R. C; X - #include <mach/irqs.h>' T; C5 O3 |" x/ B' [5 m3 Q4 G
- #include <asm/hardware/edma.h>
8 i+ o w% u4 K0 e4 h - " j# J% E' c, s( I4 H- B
- #undef EDMA3_DEBUG
2 I: n# r8 h2 z! v% _6 w. W - /*#define EDMA3_DEBUG*/
0 B% C4 x; }$ I7 K
0 }( J9 K; S1 k* U& q- #ifdef EDMA3_DEBUG
- h' b* j5 \& q8 [, l4 m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 B- w( J# e+ {5 R7 z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( L0 q1 W9 h) ^ q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, z( v6 ^; s- R- p9 G - #else
8 M: e$ L! W- {, j7 R; M) h1 E - #define DMA_PRINTK( x... ); P" ?( j+ U* c5 o) V
- #define DMA_FN_IN
, z0 K1 P4 o; c7 Q7 s9 P - #define DMA_FN_OUT
% s) _$ F7 u* w2 ^9 }. e% U+ d) Y8 P$ I - #endif
2 x9 k$ v7 b t8 i' F2 b4 g
3 m# N- w# d! R" n3 E3 l U) W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
O) ]: T! O. P' k, N# N - #define STATIC_SHIFT 3
" c" z2 t- ~4 f' D: A - #define TCINTEN_SHIFT 20. J% w! J1 Q2 D. c7 ]% K
- #define ITCINTEN_SHIFT 21! w; Q5 L) g: h# E% k) G* g& w
- #define TCCHEN_SHIFT 22
1 U5 w7 T% a& v- x5 @, h6 a - #define ITCCHEN_SHIFT 23
8 |8 c' \6 q* u - % N! h/ x2 [! c( ]% ]
- static volatile int irqraised1 = 0;
/ m; a5 Z; j! W2 }/ A. ^ - static volatile int irqraised2 = 0;( H5 Y+ c% b0 R& W0 Q) Y8 E
- 8 ]# C# \( @4 f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; M& g9 Z( A4 U9 y& @4 U7 L4 B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 ]" _* L2 Z& O# K1 E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! p( w0 |1 C6 P) C/ F% j
9 ]4 N E5 E2 J A h- dma_addr_t dmaphyssrc1 = 0;
* U9 s$ `1 R; q& H/ m - dma_addr_t dmaphyssrc2 = 0;
1 x2 w: T+ `! a) p C - dma_addr_t dmaphysdest1 = 0;# z5 l3 @3 k# t4 [
- dma_addr_t dmaphysdest2 = 0;% \# L. |9 X& x- W0 m% _& g3 o
$ u1 g/ ?- C3 j/ F- char *dmabufsrc1 = NULL;
$ I8 w9 e8 H' i - char *dmabufsrc2 = NULL;
7 }8 i5 y6 T8 |& X - char *dmabufdest1 = NULL;! c# B7 k1 n7 y8 k' w! @1 }
- char *dmabufdest2 = NULL;
7 Y, o; {! d: K2 O T, [: e
+ B' @# d$ j/ T, x( [5 |5 V1 X: c0 E- static int acnt = 512;" H& C& ?( h8 [5 C
- static int bcnt = 8;7 b! F' K+ h+ S
- static int ccnt = 8;8 S7 T1 W6 n0 |7 x6 X& j" Q
- + J, q$ ~* ?" V' M4 E
- module_param(acnt, int, S_IRUGO);4 Q: C; V' f) R/ r! w! ]0 X- h* ~
- module_param(bcnt, int, S_IRUGO);% u" U1 W; f+ a
- module_param(ccnt, int, S_IRUGO);
复制代码
% t' D O3 C& g6 o5 Y
( N# [; H( q5 M* q) E$ p# P! R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& D I4 W6 [, N) U1 Y! J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' q- ^' h$ S3 ^( r( O' m* ?+ m 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. N9 Y' u4 @ a. u" }9 C6 }
8 \# f/ r `! D) d1 E# Z" H; y1 T2 T) S
|
|