|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 e5 L- b* U, N- [code]EDMA sample test application
. i6 `& S( Q) Z+ Y8 {6 r - /*7 x l* c) D, y
- * edma_test.c. \. ]5 @* ]$ R# |& l1 s' Z. F# F
- *! N$ _9 Z% j& v
- * brief EDMA3 Test Application- R9 ?. K) J9 K
- *
, W' i0 g* J. f% ~1 H - * This file contains EDMA3 Test code.
$ t# N9 Q! s c# c! u1 u - *+ _0 y. c5 O& C6 z% ?
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' I) b! h* [" g S8 g8 G/ S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 ?; b& p7 _- s' K# m - * TO CHANGE.2 J& D$ K4 ~ f3 t L
- *
- y' e$ O; @ q9 c: z$ h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) A" S/ t: W2 Z3 K& Z- s
- *
* M v% q. I5 Z! T9 o& P7 M - * This program is free software; you can redistribute it and/or" g$ ?# |: R8 f* |8 L
- * modify it under the terms of the GNU General Public License as
9 C: D0 `; ]# p4 _: L/ o - * published by the Free Software Foundation version 2.
% }( U5 w* Q+ l: C - *
: U6 ^! n& L- i+ x$ { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 S# N0 _. u) @( @( `
- * kind, whether express or implied; without even the implied warranty! E0 ]. l- j* ? }
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 G8 y+ n1 O$ B7 A3 S4 ?- ^
- * GNU General Public License for more details.& Z. \% O8 g3 a
- */. A; r: A4 G# `
0 m( N+ i- @/ e- #include <linux/module.h>+ ?1 P! q: ^- b) S' l1 A1 W8 Z
- #include <linux/init.h>$ ], k$ r3 V. C9 p
- #include <linux/errno.h>
/ ~* d7 w; ^0 S5 f) K( _9 m0 u - #include <linux/types.h>
- R0 b! X% w" M9 X m( M2 D - #include <linux/interrupt.h>, V& [0 O. V: r' t
- #include <asm/io.h>* ?7 y: [) c! p b$ Y3 x6 \
- #include <linux/moduleparam.h>
- {4 y: `; E; d6 g- Y - #include <linux/sysctl.h>
( u6 [- J0 \5 A# A7 T; X - #include <linux/mm.h>7 x/ R, I9 p0 M9 l% `" w
- #include <linux/dma-mapping.h>+ S( D! f; o( l
, ?' P H; r: |2 X- #include <mach/memory.h>
4 w P% ]1 A+ M e0 {) e - #include <mach/hardware.h>
& F% C! \* l& n( [. D5 Z5 C - #include <mach/irqs.h>& J2 C* ]# y ^6 u
- #include <asm/hardware/edma.h>% K7 o0 k$ U% x* v5 H5 P
- 9 P7 X( A$ N/ V" l/ y
- #undef EDMA3_DEBUG
. V1 I: j1 \0 n. Y5 c- X/ J - /*#define EDMA3_DEBUG*/
9 d8 L, W+ m6 ]) f4 V& a8 ^ - 0 A5 `: U9 G; `& j! m
- #ifdef EDMA3_DEBUG F3 [ @& \( b& J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), g z+ S, \9 E' Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* W. t" d! K" W2 C2 Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) n* t+ _3 o! b/ V
- #else
: W z3 q7 T2 k9 g& T) a" J - #define DMA_PRINTK( x... )! s/ C- s6 i9 N7 q; F5 U
- #define DMA_FN_IN( o/ N3 \1 L# i4 P# V' r
- #define DMA_FN_OUT1 [% ~3 t2 i0 ^& e! N
- #endif
9 A. L8 y) V0 E) q5 f- ^# \, p - 1 W1 s* R" o1 n. O' p1 B2 p
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): d% c! J1 r( E/ N
- #define STATIC_SHIFT 3( `4 ` }+ j" @- P0 f
- #define TCINTEN_SHIFT 20
5 Y# e) |4 u2 r5 h - #define ITCINTEN_SHIFT 21& M: y. o* H9 T: X
- #define TCCHEN_SHIFT 22
' d1 r( f2 V% b' A - #define ITCCHEN_SHIFT 23
4 U+ _9 f) G8 `8 a, u. V* C7 g
; v$ s* W# G) ^: q2 A T6 X' b+ P7 N- static volatile int irqraised1 = 0;3 M- i* ]( C( K: S$ J7 B" b' k
- static volatile int irqraised2 = 0;
+ X8 I3 Q) @. C1 d- m' X5 Y( z& o
1 _$ e Y9 f# F# N9 g* Z: w- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 V1 s6 C- I5 W3 ~2 C5 f4 W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 M. W1 x9 j! Y0 R( r - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 }, Z$ Q1 @3 S5 x% H
- 4 E: H8 |+ S; Z I v0 a6 D
- dma_addr_t dmaphyssrc1 = 0;
6 }# w2 [7 z4 L M ^) Y& E/ n - dma_addr_t dmaphyssrc2 = 0;
' B: A( r) P0 L - dma_addr_t dmaphysdest1 = 0;2 P, f" s4 V1 ~% ?8 Q v4 {
- dma_addr_t dmaphysdest2 = 0;) X- B1 F T$ C% ?8 F% y+ s* d3 ~8 \
. v& \! o! B( T5 Y+ V: S8 K- char *dmabufsrc1 = NULL;8 {1 I. J1 `* y# f/ y8 E# U
- char *dmabufsrc2 = NULL;7 O) g5 c6 _' }% R6 C
- char *dmabufdest1 = NULL;
% _3 o+ f8 M- q3 l% z - char *dmabufdest2 = NULL;
2 h' P. D8 `: c b - + Q& e* X3 R h- Z
- static int acnt = 512;
& Z! A3 i: F4 r7 B0 Y8 | - static int bcnt = 8;$ z2 h- _% z# I
- static int ccnt = 8;
+ _0 S8 K8 g% V6 K7 g - 4 b5 b: t. Z2 p% ~; y5 b; w4 T8 _
- module_param(acnt, int, S_IRUGO);
% a Y( t. q7 ? - module_param(bcnt, int, S_IRUGO);0 w. \3 J0 u0 ]' y9 P& K
- module_param(ccnt, int, S_IRUGO);
复制代码
& n0 s4 I7 C6 Q% U0 q" D) m* Y
5 z N2 [, p' y, }% K 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# n. V7 ^& ~3 Z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 F7 D& N2 b W7 |2 C0 M- D% e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: T2 X! D4 b% ?! H- y( I, M
8 }" N! U$ L3 u' j5 l
/ |. A4 D# y0 ?+ E3 `( N |
|