|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 q: h( @+ U- F6 o3 H
- [code]EDMA sample test application
- U( B- o( M+ \" X7 ^' J& n3 } - /*/ ^& l+ T+ Z+ f5 T2 t9 Z2 @
- * edma_test.c
1 _6 e. q" z* x& a' z% J9 K - *. V/ _/ v3 i) u4 E% h$ d Y; F
- * brief EDMA3 Test Application
' i; M5 M3 O9 U+ F( s - ** ~& [7 E3 { \, o3 o; O1 c
- * This file contains EDMA3 Test code.
) a2 Y# N5 e" H4 X9 L* t2 _0 a3 Y+ r/ r - *
. H; g% b- ?$ f( O; v3 d: a) v5 } - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 `4 q, f2 E+ O4 \8 s t1 V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 N J5 ^# q* K0 h! _ - * TO CHANGE., I! L2 c- Q5 z6 o+ @# n
- *
- ]8 t( u* d) Q5 ? - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 j# X7 N4 f( N+ J5 ]7 |2 |
- *, T* k9 Z! @1 [, e* ]6 [, j
- * This program is free software; you can redistribute it and/or
% @2 e4 F. b2 ~4 `' E3 A7 D' h - * modify it under the terms of the GNU General Public License as
) u7 L( R+ [/ y2 E - * published by the Free Software Foundation version 2.
! d$ s4 X, P- k - *7 B% p2 P- u2 s2 `! L& i% \: r/ }
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 x- n. C+ T! F+ ]
- * kind, whether express or implied; without even the implied warranty
8 w2 D" M. ^5 O+ y1 R0 k - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 ~+ }6 k; ]- B9 D8 {( C
- * GNU General Public License for more details.
; x- K& `0 O! r6 V3 Q' { - */( y5 \7 C$ l& P
8 D' _9 T `/ \+ {/ G7 P- #include <linux/module.h>
5 A! [- b. s7 N7 R& a1 T9 B# [ - #include <linux/init.h>5 _ s! _; n$ p0 P8 F
- #include <linux/errno.h>. b* B. u: Y; R; Z$ D/ }5 Z9 L
- #include <linux/types.h>
5 y: P" E9 k, p7 y - #include <linux/interrupt.h>& n/ f! @& g% t9 w
- #include <asm/io.h>
! H. |* a9 X5 G6 S2 h& L1 B - #include <linux/moduleparam.h>$ `& f" D+ g& |$ d
- #include <linux/sysctl.h>: M1 [' q7 S9 `+ T$ r
- #include <linux/mm.h>
. `' N! i. u; T7 ]: Y - #include <linux/dma-mapping.h>
' ~* K7 f' J- ?; X
* L$ \4 i" c+ E) P" C* e- #include <mach/memory.h>+ U# D" k+ U; N2 F
- #include <mach/hardware.h>
& j' r1 x$ d% L7 b - #include <mach/irqs.h>
) D( b, T' G4 X- d - #include <asm/hardware/edma.h># c6 t! ?% {3 s
- & G" V9 l. Z4 ^! X; A+ |
- #undef EDMA3_DEBUG5 g4 @7 N/ M0 k# c8 k1 o
- /*#define EDMA3_DEBUG*/
$ Y5 C# }7 U% y) n( K - , Y* Z; }* J/ t2 I8 {
- #ifdef EDMA3_DEBUG
9 Y1 A& S" V3 Z6 \+ `6 c - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* [2 A) v1 M0 U: h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ b/ k% N; d& J e) ^ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). r4 g3 M% V0 G: J% Z
- #else) q2 V6 a) M- d/ y/ t" s! i
- #define DMA_PRINTK( x... )# s- H$ n$ j& Z% t, {; h. _" d
- #define DMA_FN_IN) t9 e/ k/ i: L# N) H4 Q) X$ Y
- #define DMA_FN_OUT
( t4 [+ r% s ~ - #endif
9 \6 C" z' Y& {1 g7 c/ u, L
! {( a* Z4 c/ C0 W$ v9 a- ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& w. | z& e! V( V5 ? - #define STATIC_SHIFT 3$ g: B" Y( Z* D/ o1 q4 l5 y
- #define TCINTEN_SHIFT 20
5 |1 [ @6 s9 s1 {( W; k - #define ITCINTEN_SHIFT 21" Q- |$ s* T% F; g3 Y9 P! ^9 G
- #define TCCHEN_SHIFT 22( Z/ r1 R* y( |3 F* @' P
- #define ITCCHEN_SHIFT 23
. j9 m* t, K/ m: k' t
3 S [ @) \" d) }3 A3 s- static volatile int irqraised1 = 0;
! g: [5 U& o2 H+ u9 W$ z$ C2 B9 o - static volatile int irqraised2 = 0;
3 j! r8 \8 _6 z' o: K - . U2 r9 j7 ?, `6 ^0 v
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- K5 t: C! W+ Q5 Z9 K3 p/ a9 @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ \8 a0 _, f/ j- k r - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 {) T. f! s- T4 |! ]* \+ M$ l! S
% a5 N2 y2 c( b3 s- dma_addr_t dmaphyssrc1 = 0;
8 x/ F! `' I& q S3 g - dma_addr_t dmaphyssrc2 = 0; D# T: z Z3 i g/ `' ]+ b! P ~
- dma_addr_t dmaphysdest1 = 0;2 k: t( L9 f4 F. X2 d, P
- dma_addr_t dmaphysdest2 = 0;2 K) }9 h: N1 Z- g. y
m+ }1 k" E: `' z- char *dmabufsrc1 = NULL;
( T2 L9 t7 O5 y, n% g& g% X - char *dmabufsrc2 = NULL;
. o9 C$ c# @" b2 ~9 r - char *dmabufdest1 = NULL;
4 f8 I: u- ~" G1 I7 }5 I - char *dmabufdest2 = NULL;
" K" b- l7 E% c( H# y
8 U) U6 W& Q' J. y+ y- V' f- static int acnt = 512;
8 q0 i8 Y* E+ g) v2 V9 J - static int bcnt = 8;
' v/ v) H6 |0 [( r8 B3 ? - static int ccnt = 8;
7 O4 K6 Y3 x! M
6 D/ g G7 p' G& i. W2 f, U" N) @ T( L- module_param(acnt, int, S_IRUGO);9 g/ u/ l! q0 D2 [
- module_param(bcnt, int, S_IRUGO);
9 \9 Q: m+ }; e; k$ ~& A; b. O - module_param(ccnt, int, S_IRUGO);
复制代码
5 H- v2 b# L( C7 c' Q& L: i, W" @& Z3 G# A& m7 @8 x
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ A& B& v3 J$ T3 Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, s2 R! Z/ r7 |+ s4 F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 _- m4 m8 B u" s
6 E* C- S% \& g1 V! J! e) s( q4 {. E+ y
|
|