|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 {; w8 B- Y/ Z" ~
- [code]EDMA sample test application
+ ?& M2 q9 j" e - /*/ h+ Z7 ~) ~2 o$ e4 v% j& s6 R+ u9 _' c
- * edma_test.c
# N5 o' s: `! K* a5 p6 J - *0 |$ }9 E, e- p! ^
- * brief EDMA3 Test Application
1 b& b( m/ O1 n$ Z* B! I - *
6 b9 T& ` A# S+ d; q - * This file contains EDMA3 Test code.* [) f" J d# Z9 J( f
- *9 ^! u- A" L) U. ?$ ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE d9 U% X4 v( E0 U
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 }: [ s9 \; h* F7 l G - * TO CHANGE.$ M* |2 O. S' L7 S; Z
- */ O1 H6 Y4 I6 ~( v& H
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: j7 z( R1 J, t7 C4 }1 m! ^' X - *
0 _3 B0 u# Z! P- M" b Y- A w - * This program is free software; you can redistribute it and/or8 N% k7 p% y5 G/ y
- * modify it under the terms of the GNU General Public License as
& d6 h& R4 {; O5 b; G - * published by the Free Software Foundation version 2.& `( E4 w5 x, j1 A6 R# G% c! v
- *' p8 {, Q3 [! q# }5 ^" ~
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 _, l, j, ^9 @7 i
- * kind, whether express or implied; without even the implied warranty
$ W7 j' F) |6 e/ [6 F( x% @) O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ m2 Z& j8 ~: u- }- I - * GNU General Public License for more details.
3 s5 z- U' d) h - */& X2 b6 E# f z( \9 w
6 S) O: o. a h. A0 O- #include <linux/module.h>
5 I9 }3 s0 f0 Y3 r5 P/ e - #include <linux/init.h>6 S9 q5 \3 b/ u, m [$ O
- #include <linux/errno.h>( F+ A( w2 X, y# j4 Z
- #include <linux/types.h>
4 V* ~& w4 D, d% f - #include <linux/interrupt.h>
7 @0 `+ k1 i% {, [, z - #include <asm/io.h># `: C$ L1 d) F; N4 b' m: y
- #include <linux/moduleparam.h>
0 \$ J5 ?& F `+ B: ?8 v6 V3 a - #include <linux/sysctl.h>) |8 Q/ I( v/ ~6 G/ k& u+ N {+ d
- #include <linux/mm.h>
8 u8 j5 \' V/ u, g - #include <linux/dma-mapping.h>
q- ^: t$ r7 E i* c2 t% d- b. B- O
4 G' v- ]+ {/ L% z. B- #include <mach/memory.h>6 J% f- a6 n- e( g9 \. k8 I
- #include <mach/hardware.h>
8 X' u- x& Q" f- v0 p" B - #include <mach/irqs.h>! y! d( t. l$ e+ k: g+ u
- #include <asm/hardware/edma.h>3 {2 B- K7 _* ]$ J b3 s' [! R
- 8 G, L5 ]8 X4 c# x) l
- #undef EDMA3_DEBUG
3 }: r, ?$ X2 f- u4 [( |5 o& s2 l - /*#define EDMA3_DEBUG*/
$ q' @! f' E: r6 e
" G& H3 B& A+ Y- #ifdef EDMA3_DEBUG! N" V. x% g& p. A9 w* G: ~# }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ H: }- v4 z, M' l2 q% J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), w2 ?- l4 o4 I. h7 c# D
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ u5 |( ~- Z E8 Z! E* D - #else0 J2 F7 R# e/ D+ F
- #define DMA_PRINTK( x... )
& o$ q6 F& ~8 }: L0 }- i& z - #define DMA_FN_IN
% N. s; t& D8 V - #define DMA_FN_OUT
: e' T% e& k0 p5 c U( q/ a$ { - #endif
0 ]2 X( ?( i( M# B! G* `
" c; b+ y3 [' P" E. o6 }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) N, Z0 o7 e+ W5 v' Z/ l- l - #define STATIC_SHIFT 3
! C) \2 C; t* d6 G - #define TCINTEN_SHIFT 20
' A( U& J: G4 G, j) e/ Z - #define ITCINTEN_SHIFT 21
8 n6 J c/ U1 A - #define TCCHEN_SHIFT 224 E, ]1 L2 t. H% L4 H8 t
- #define ITCCHEN_SHIFT 23: }% c9 s4 g4 s* W+ o; G; \$ e
- $ W6 z9 [8 G% r, K$ u9 x
- static volatile int irqraised1 = 0;
: y- R/ @5 c' J0 i" a8 t4 U0 g - static volatile int irqraised2 = 0;
2 K) t1 E+ P$ y) ]* k - : R* w1 c% K- k& n$ `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( u) i$ r- H5 ^! E# |2 i! o( X' p - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! f! g$ G. I+ z9 b! _, a - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 ?& V- G6 v y+ D
1 t: w4 b- q) ?3 T- dma_addr_t dmaphyssrc1 = 0;
, z/ g5 t2 F9 x5 ^6 P g - dma_addr_t dmaphyssrc2 = 0;# _ O# p2 i0 x$ k. B: {
- dma_addr_t dmaphysdest1 = 0;" a" ^" m+ m1 q# q4 }' F- Y
- dma_addr_t dmaphysdest2 = 0;
* W! @1 Y% d, k* L0 z( a - # M6 i% b' w0 D$ ?5 k0 x4 [: k8 ^
- char *dmabufsrc1 = NULL;
" A- H) a2 t4 m+ b - char *dmabufsrc2 = NULL;1 @3 P) R( M" k& q5 r
- char *dmabufdest1 = NULL;
4 H0 q F) d. o- z8 A2 C - char *dmabufdest2 = NULL;
2 O( y3 H; o7 h7 Y" G/ g& N - 7 U2 U/ r% f2 I' Z* B$ O
- static int acnt = 512;
* q, ?% _7 f7 h5 r' L4 c - static int bcnt = 8;
& e, W6 Z3 S9 B& F4 o9 ^- T - static int ccnt = 8;
6 j3 E5 n& I* Q) f, p( l
3 l4 n9 @) p" s: }) `" g- module_param(acnt, int, S_IRUGO);, R8 ]6 k0 U! O
- module_param(bcnt, int, S_IRUGO);3 S, a5 M, T6 i; w/ C/ H. T
- module_param(ccnt, int, S_IRUGO);
复制代码
' U5 \$ j9 u, ]& n
- w. W3 O, D, G; T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ l; ^" |; A4 e) ?% A1 yarm-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 I. V e Z( J2 L0 X3 k 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 y- t D) _. Y8 H( m
$ e8 O* I& z L ]! F2 h, ^
& }' z4 Y f# a! J |
|