|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 J! I7 K+ X* |' K8 F; K% B- [code]EDMA sample test application0 G, x# z4 K) m7 \
- /*5 C% }; X) u4 ^- s- ^" C2 g/ t
- * edma_test.c* I( O4 p: q M& _
- *1 R! D: w& d2 d+ B! k7 u
- * brief EDMA3 Test Application
/ o5 x" A. N: ?/ W" n g) ^9 H/ j - *
: a8 l% c* K- k6 I$ O - * This file contains EDMA3 Test code.
3 {( w0 @, B4 j6 G - *) K6 U( T ^6 E3 Y0 Z) a$ [; y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' [. [6 d2 [' D' m- y) W, I6 K$ q9 _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' U- x, E( t, ^, D* z' O/ t" q
- * TO CHANGE.+ [( f b& G+ b* a h$ @
- *
" B; u/ |( D8 }& b+ q# x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# b3 ~. B! F6 F
- *" C) b1 n- W3 C8 J& ~& }
- * This program is free software; you can redistribute it and/or
. D ~* o5 O) o- p* |8 W - * modify it under the terms of the GNU General Public License as& w: x1 e% n7 P; u: g
- * published by the Free Software Foundation version 2.8 N# d$ r1 V( G. Q' E& h
- *
c! Z! ^6 u4 \0 f) d6 ^5 a - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ z/ \/ `. o: [% \9 ^
- * kind, whether express or implied; without even the implied warranty
; \; l* T5 g, W7 |" C; n( c - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 p5 l) w5 X* [0 e+ z, ]. d& H- Z; R/ f - * GNU General Public License for more details.
; L8 a4 U) y6 O/ ]' F - */3 P5 H, l3 G- C( z
- 8 C& o7 z* U! B
- #include <linux/module.h>
% h8 M0 R# c& G0 O, ]0 I) D( N - #include <linux/init.h>
, h ?4 U' p3 E - #include <linux/errno.h>
, u4 V9 {' R1 f) V- y' i - #include <linux/types.h>
6 w/ ~- Q1 |6 _: S% Y - #include <linux/interrupt.h>3 e9 n% ^/ C$ Q, |4 j6 u1 J! R
- #include <asm/io.h>
; o9 n: p; v2 t; P) s+ N& X - #include <linux/moduleparam.h>
. {) M; ?# B4 N& M9 d+ ^7 _7 u - #include <linux/sysctl.h>
* h0 n' u2 M$ q - #include <linux/mm.h>* y1 l7 H' o1 c
- #include <linux/dma-mapping.h># y# h/ p6 t/ g! g: `
# p; d: H) |: A! E3 C- #include <mach/memory.h># C. J/ U/ b: }5 Z" D" ^
- #include <mach/hardware.h>. a$ ^- |+ K. ?$ h
- #include <mach/irqs.h>
" e4 s! K" C2 F - #include <asm/hardware/edma.h>
5 G# ? Y, k; X% e3 F. }
4 r( C0 ~& V8 t& D! u* g- #undef EDMA3_DEBUG
: K) O1 O' e7 F; V. `6 m+ f$ a - /*#define EDMA3_DEBUG*/
1 K& K W* ]' d5 H( h
% W" Z1 C$ N `0 X: f/ v; ]& |- #ifdef EDMA3_DEBUG
# P7 v/ Q" C& A. G# s/ p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' w! i1 |2 A4 s: u0 H - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. `' F9 u' ]) f - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) b) n* z' V% V8 ?+ o - #else
! o8 K9 m" E) L( V7 ?6 z - #define DMA_PRINTK( x... )' P1 }. z- T% v) ]8 v# C
- #define DMA_FN_IN- K4 ~3 e# d# K& [' h5 \
- #define DMA_FN_OUT
& j8 O4 d$ W4 t - #endif+ q( t5 R+ w$ ^4 F" R! a
- ! H. f* m7 R3 h+ M
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) U. h' K& u; G" a) X( t3 \; l
- #define STATIC_SHIFT 33 C1 H! a2 i3 a( }! C- W }
- #define TCINTEN_SHIFT 205 a L1 i% [$ R6 D
- #define ITCINTEN_SHIFT 21, X$ J. d$ g- Y! B7 [0 R2 z
- #define TCCHEN_SHIFT 22
3 L* p) P/ t; D0 l - #define ITCCHEN_SHIFT 23
# g1 |2 Z) N/ n$ r) `" {# v+ P - ; p& P. G$ K0 V k
- static volatile int irqraised1 = 0;5 G% V) _/ [+ J' x3 G2 p" ~2 c! O7 Z+ N1 a
- static volatile int irqraised2 = 0;: F. n j& f$ y; [$ z/ F
- ! F4 _8 ]7 c! o+ s3 K
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 w) R# y4 Y( w3 r1 S C: l7 g - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# B1 G5 P: U7 ^: o3 r6 G
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& ? Y3 M6 @% ^6 N5 ?5 h
. e7 R/ [/ C5 y! C0 p# W- dma_addr_t dmaphyssrc1 = 0;
, w8 T+ }$ r/ ]% y% J - dma_addr_t dmaphyssrc2 = 0;* }' e6 U" X* b, J$ U4 P; C4 E
- dma_addr_t dmaphysdest1 = 0;! L& W7 ?3 L0 L4 D+ h
- dma_addr_t dmaphysdest2 = 0;
# |! p A2 X, } E3 ^5 _
+ y9 ]3 M; T% f4 W) q- char *dmabufsrc1 = NULL;5 @( l4 ]( u9 K( }" E* i
- char *dmabufsrc2 = NULL;" }- ^8 n X: Y8 X, o
- char *dmabufdest1 = NULL;( X1 A- o* F6 `; J( B
- char *dmabufdest2 = NULL;
1 H% w v5 U" u1 B* v R6 e! n& A - ' |6 L/ y5 h; o% @) X: c W4 ~
- static int acnt = 512;( x5 B, {. l" [5 g
- static int bcnt = 8;
( W2 g5 I6 Y! c; w0 m$ M' F - static int ccnt = 8;; L3 `% ^ e# u& M
1 a: r- _7 l. `5 ?+ i0 A- module_param(acnt, int, S_IRUGO);/ f t& u4 |! M
- module_param(bcnt, int, S_IRUGO);2 P: }- c; }7 p: r0 R
- module_param(ccnt, int, S_IRUGO);
复制代码
1 M5 i& m; H" M+ X& O& \% T& G( r. D; K/ D; U7 B& @5 Q2 g3 z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! R! u! }9 ?9 N5 Z, q5 b4 Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( M8 Q. a* h2 Y& t4 `/ d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 B3 u: B$ ?/ A
+ J% {4 `! R9 c
) r+ R* E" H6 O4 g |
|