|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( y4 @3 u$ `! Z6 Y6 ^* d9 q
- [code]EDMA sample test application
2 N# ~+ j! o$ G" I! F- e% { - /*$ m1 ?3 F; A( B, `& s
- * edma_test.c
& Z5 s7 ^& V% K* h x - *
0 U' v7 Z3 w2 j7 i - * brief EDMA3 Test Application
$ x2 v7 w2 O$ d- n- Q( ~+ ? - *
0 n6 t! o! J( Q& G6 p4 }7 ]' s - * This file contains EDMA3 Test code.
: D" i4 s* U6 s( w - *( U$ m3 e! J& K4 m4 @' L* B
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 d6 D# J% P8 s' z7 j. `! r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 h+ i0 J& M+ [( ]9 k V - * TO CHANGE.
. x3 a; S3 S( t5 |, P8 [. M - *7 ^! [# w9 S1 P `# O5 v0 b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" e* ^$ q) I6 B: ~9 q( K" Z/ l
- *$ a' R: a5 ~' Y8 F5 l
- * This program is free software; you can redistribute it and/or
! V: e* g) {6 |# S- T4 ` - * modify it under the terms of the GNU General Public License as
5 A* N* z3 \1 h5 A- h, _ - * published by the Free Software Foundation version 2.) h& T5 F* d$ r6 ]7 u5 r! Z
- *! [7 P1 O8 s& B- Z& ]
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* o4 X) K/ i8 Q3 ]6 \+ @+ n
- * kind, whether express or implied; without even the implied warranty8 \0 A- P; P) W6 k% B4 M: Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ F# G& r9 @( J% E' n3 g - * GNU General Public License for more details.
% [5 ^9 G' M: [ - */! N$ N: A+ ~: ?3 X% k! U
6 n' |6 P! ?' X$ A/ [8 ~- #include <linux/module.h>0 q8 [# X7 }% D! K2 H1 m A
- #include <linux/init.h>
" |0 M& z ]1 A3 \% y - #include <linux/errno.h>/ j1 [% k& U5 D5 z& q( Z
- #include <linux/types.h>; q4 d/ z, q+ s5 ~% f* {
- #include <linux/interrupt.h>
5 r/ ^, }" P6 h$ { - #include <asm/io.h>
" R1 }: f: J+ j% p0 w, } - #include <linux/moduleparam.h>$ q& o5 d" P4 e7 m: [, M) g" Y( l* _' d
- #include <linux/sysctl.h>
8 q5 W4 G( R9 h; f* ~3 r' q+ z - #include <linux/mm.h>, ?- |( Z g& f( F% t
- #include <linux/dma-mapping.h>) c7 j6 {+ C; ?' _) h
) s; n; e5 N3 x' E- #include <mach/memory.h>
" M7 q1 V- T3 g - #include <mach/hardware.h>
6 o# |9 N) G& q! Y+ y( f" p6 F - #include <mach/irqs.h>) ~8 j: w# ^8 ~- s7 c, u; X, |+ E" y
- #include <asm/hardware/edma.h>
( j# a7 F5 y. I {! @% D
2 z8 O0 L c- M9 S+ [' H0 y- #undef EDMA3_DEBUG* \* z: C1 x6 ^9 c; }4 G- b! U
- /*#define EDMA3_DEBUG*/
$ {# s# w1 B+ o6 d1 | - 8 G+ j# f( q! `+ Q. g
- #ifdef EDMA3_DEBUG
! A; Z; r0 o1 c" ]$ b - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
[: I% x+ |$ ^: j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 k8 a; s, \3 }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( P( x9 f: B+ | - #else
$ h( J$ ]9 r2 m3 F7 m3 K - #define DMA_PRINTK( x... )8 E. M4 _) ?- K6 G2 h9 U( f3 `; D3 X4 x
- #define DMA_FN_IN
; x" V ~1 a: X% V) u - #define DMA_FN_OUT M# o& _ _5 J1 f3 q1 Z; `( O
- #endif5 g/ M2 B8 e- B$ C
5 \0 w) L8 u& A: a6 C# U3 p) z- #define MAX_DMA_TRANSFER_IN_BYTES (32768) U) q2 o: D) P3 |% X `, r
- #define STATIC_SHIFT 3
e/ v4 y' T7 N+ L5 ] - #define TCINTEN_SHIFT 20
0 T- o0 }) Y# ]% G. M$ h5 y" Y - #define ITCINTEN_SHIFT 217 G4 }5 @& F% P& S0 r" d, W
- #define TCCHEN_SHIFT 22+ k9 S" b( C6 N) c! J8 Y5 N
- #define ITCCHEN_SHIFT 23
( I3 P7 C4 y/ R( C: x$ G/ n! ^ - 4 E5 ]2 r' `9 m2 V# d$ @
- static volatile int irqraised1 = 0;
: j/ z- e+ B. z( }' F9 j! j) i - static volatile int irqraised2 = 0;
) i- i+ i* i' N: o
, k( g4 ~2 P( a: t) ~/ n3 d* Z! f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 t% w5 b0 w7 _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' u. P. E) J* t' D! {4 K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" T, u! L- Q) E) V% z - 1 O3 ]+ O2 }# h4 o
- dma_addr_t dmaphyssrc1 = 0;
% g( @/ Y' g$ W9 K1 C+ ]. x - dma_addr_t dmaphyssrc2 = 0;+ y1 D) A0 H7 B6 j. E; _" L/ v
- dma_addr_t dmaphysdest1 = 0;
9 J# g! T# u( T4 v! y) q - dma_addr_t dmaphysdest2 = 0;" D; N- g4 j/ e9 I# p# X" C5 M& x
' M2 V: v! J/ {0 |, O [% ^- char *dmabufsrc1 = NULL;* E, i3 R0 a* [
- char *dmabufsrc2 = NULL;
5 z2 ]$ |. K' f' ?' F% D - char *dmabufdest1 = NULL;
- m% V4 a5 w% {9 @$ b- E - char *dmabufdest2 = NULL;
1 k: P- b& ^+ P2 h5 f) S
& u* J. l3 d; l" j! h1 y- z- static int acnt = 512;
( S. `0 ?& b4 I* m$ u5 J8 B - static int bcnt = 8;" Y1 c8 Q" e: m$ _
- static int ccnt = 8;
( X4 }8 M+ @- X2 r; j9 v - 4 \3 @2 c0 o3 o+ C# j
- module_param(acnt, int, S_IRUGO);2 ~7 O. |0 {% S% l: q1 k; _ t
- module_param(bcnt, int, S_IRUGO);, k6 J3 y* b$ X5 F" ~% p* |2 R" P
- module_param(ccnt, int, S_IRUGO);
复制代码
( W8 Z" r2 H$ B# j2 [, Y& x
/ d9 t. o, X. T$ | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 v) S% D0 v) y0 J' M8 w
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; T& Q/ x: d( ^. }/ O) o& }$ R0 w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 y# N: _0 R. G7 Q
1 V3 x) r5 o9 k: @: k* o0 g* f
' \* Y5 q4 t) q. C3 k4 _ |
|