|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 J$ {; x/ x' }1 p0 k
- [code]EDMA sample test application
; g( e7 m% M. e; R - /*5 f6 A- W9 f* @4 B( ~
- * edma_test.c4 `7 J: R* Q% R( X& `! r
- *& M k% _' z2 j2 [
- * brief EDMA3 Test Application+ i B- _! s' {4 v
- *
9 S o |* z2 ~, k% d - * This file contains EDMA3 Test code./ R7 f" ~* p+ X! T+ i8 W
- *
; W# f/ x2 q5 b/ ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 y F8 m, ~4 f$ o( |" R4 u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 T& J1 L5 s' t2 ]5 L- j; g$ s - * TO CHANGE.
8 B( c0 Y9 r( m* @4 \ - *0 |% x g g# q2 W, b2 K, H
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 v4 q) l4 _6 ]' H7 E o# G% d
- *& I) Z! a8 r# _3 }
- * This program is free software; you can redistribute it and/or
1 z8 R/ U! B- y; \1 X" ~9 C - * modify it under the terms of the GNU General Public License as
) i" m5 y q9 O5 g$ g - * published by the Free Software Foundation version 2.+ |* r: p9 I% x
- *
6 u2 w+ i& L: o. a( C2 @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 I5 [2 q' |1 L5 H - * kind, whether express or implied; without even the implied warranty
& B( _; h$ E$ V# m' R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ q" L) @% P) b - * GNU General Public License for more details.
0 E+ w1 t5 Q+ {! S( C! q+ p* T - */" P0 c8 K2 S% G9 i5 s; j6 Q
- / R) Z/ h- d" t1 k1 V1 n( @
- #include <linux/module.h>
3 L l5 r4 L" d' u/ q2 Y$ I - #include <linux/init.h>. Q/ M$ n7 K1 i& j6 a9 i( U
- #include <linux/errno.h>6 Z' i! P9 H5 W! o
- #include <linux/types.h>( V, p1 Q; H# g0 \
- #include <linux/interrupt.h>& p3 C! q% I: d; ?
- #include <asm/io.h>, U) l8 o" S N+ O, c
- #include <linux/moduleparam.h>- {2 _- O3 d) _" X/ P1 K
- #include <linux/sysctl.h>
% S8 O% Y& s3 t& M1 R4 O9 o - #include <linux/mm.h>$ P, {, V+ m) q3 P
- #include <linux/dma-mapping.h>5 U c: R2 O+ ^( t4 j m B$ o
- - p3 m. R4 o) o, A3 Y" A. G1 F
- #include <mach/memory.h>' y# X8 |' H. _+ L
- #include <mach/hardware.h>) A) i5 p" `1 [) \$ n
- #include <mach/irqs.h>% j- \2 a$ g. \
- #include <asm/hardware/edma.h>; _7 m% m7 y6 Z4 g0 m. K# [
- & j7 t u5 _0 j( q
- #undef EDMA3_DEBUG
& O3 b2 L ~( a( ^) K0 k" O/ d1 k) ? - /*#define EDMA3_DEBUG*/! ?/ e+ A* d0 y$ c0 r/ q
+ \% Q5 _: D( ~- #ifdef EDMA3_DEBUG
) @: D# [( y- T9 E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; C6 p; g B( p- W4 ]2 k - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 i9 a2 d9 N; ]" ? a" u; ~
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
J5 |) i* W4 w* S& f. m& p - #else
4 a K- v0 v7 u6 I - #define DMA_PRINTK( x... )
, P6 P( s: P' Y5 I5 i - #define DMA_FN_IN. S5 U% v/ i3 Q2 {6 M, h9 b
- #define DMA_FN_OUT- _+ I- Z1 r9 e7 [: G
- #endif
$ h, ~1 a8 p. L' j' v: H4 s - ?6 d) F! D) a5 p; s: ~4 \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( F' ]6 A" Z5 s Z# H% b - #define STATIC_SHIFT 3
9 o: ^4 x8 l F0 Y9 L - #define TCINTEN_SHIFT 20* D2 ?, T+ z3 h5 O k8 c% `* ~
- #define ITCINTEN_SHIFT 21
$ t8 {% I( C5 Y9 w# f) O5 N - #define TCCHEN_SHIFT 22
* o4 o3 d J6 l( j$ a, S - #define ITCCHEN_SHIFT 23
9 ]* m' H& W4 r. q
( K1 Z6 M2 J+ I/ |. p& E7 f- static volatile int irqraised1 = 0;
, W' F+ c* G( R) @& J5 V+ i - static volatile int irqraised2 = 0;
q( O3 K: v* D, `$ j& d+ j
6 ~1 u" i2 s0 Q s% ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. k: i. }6 ~8 |8 z8 a: ~ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' F/ O2 l" n% ], b
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. Y- H! E5 E7 G/ v' M. X
6 V7 X0 U/ N0 u* j- dma_addr_t dmaphyssrc1 = 0;* Z- T+ E8 e$ `5 U& W" p
- dma_addr_t dmaphyssrc2 = 0;
" F* Z9 d2 ~7 ~4 }" d' b - dma_addr_t dmaphysdest1 = 0;# u# c1 |: y% _- q: M7 n1 Q
- dma_addr_t dmaphysdest2 = 0; n* {3 [& e& P; Q, G
; D" f) _" G' C- char *dmabufsrc1 = NULL;
9 d) y, V. F" x" a1 s - char *dmabufsrc2 = NULL;3 J X* o8 a) m( v
- char *dmabufdest1 = NULL;- b2 j, z/ X* e8 F" |. O) B, s
- char *dmabufdest2 = NULL;
; h/ G! \+ a+ n
6 t: L* I8 D/ n2 n, A, q* z4 }- static int acnt = 512;4 T! c3 r) O7 N
- static int bcnt = 8;
( [& J( e. w" D+ j4 G( Y - static int ccnt = 8;6 F1 r1 G* ]; m- y5 Z
- 5 u% i9 D. h7 r! X
- module_param(acnt, int, S_IRUGO);
* U* _6 R2 d$ }% j - module_param(bcnt, int, S_IRUGO);1 E& c# x# k) h+ r8 c& g; o
- module_param(ccnt, int, S_IRUGO);
复制代码 2 h$ g, C7 B6 U! q
1 [6 N! g" y7 D: T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ t3 s" ?; R7 C1 P) g# x2 j2 |# C8 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 l" y5 P( n$ g! Z; O3 ` 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 {) g% t& v0 S5 q
8 n, N, L- f4 s/ A- Z5 O F& B5 U# H0 p# h
|
|