|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# M2 \$ Z# v- L( o- [code]EDMA sample test application) Z$ G5 @# E E2 I& A. C4 @- B9 u/ i! w
- /*
b3 U) c; x3 W3 k ~( _( F - * edma_test.c7 t$ A9 p I O) v$ ~1 G3 M7 P X
- *6 G* m0 G1 ?( C" z
- * brief EDMA3 Test Application- N+ P# b9 O3 v; D1 m: |
- *6 [. r( B, A1 L9 O: I
- * This file contains EDMA3 Test code., z8 l* K: _ A6 q3 j( f' ~
- ** r& r3 X& n' {1 @. ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 A! ]3 M2 S$ y" k8 S# s6 g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; t8 S3 R& r2 H2 ^3 R( d0 h
- * TO CHANGE.3 [' b/ o1 s! m. x$ E+ e& o
- *; F5 w7 X; M4 I. s$ Q' ]9 U0 v4 \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- I' D5 m# ?0 ?1 z* r9 M
- *
" }% ^2 B' z7 e( c" s" T+ N9 y - * This program is free software; you can redistribute it and/or
8 ?' x3 S0 u, i7 y+ z - * modify it under the terms of the GNU General Public License as2 o2 w4 h6 C; H* H. x8 t3 V
- * published by the Free Software Foundation version 2.
% I/ z3 u% l% y - *
& L" q% J) |" D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& i0 D, Y# x0 k* N K; [0 n - * kind, whether express or implied; without even the implied warranty4 z8 s% W8 b3 n
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, }& _! G5 `: K" y- J" s - * GNU General Public License for more details.2 K" e* b5 O0 v u
- */
9 \0 b1 r3 M& c5 e/ q - 5 t1 J5 Y G2 m( q& U: ^
- #include <linux/module.h>; \/ i" B5 [: j
- #include <linux/init.h>: e( T0 }7 M% S( V# e# F
- #include <linux/errno.h>; j- I( y7 T+ a' B& }/ Z
- #include <linux/types.h>% S; G9 u: C7 N6 U& c. m
- #include <linux/interrupt.h>
6 I( a9 M, ?3 o8 B - #include <asm/io.h>' k7 q# N4 ~2 q) x& B
- #include <linux/moduleparam.h>* N L8 x$ b/ e b3 R8 i6 w W; {
- #include <linux/sysctl.h>
' f5 d( B4 ]) q. Q5 E - #include <linux/mm.h>
8 j/ w2 g0 L% m/ T2 ~ - #include <linux/dma-mapping.h>
) [/ O; L+ E/ g# b9 r
7 w L, F# ~$ k* |* a/ ^- #include <mach/memory.h>
$ x& {! ? i: m- [2 c5 Y7 ~ - #include <mach/hardware.h>
: a+ o( Y9 b# S- I( T0 ^' R - #include <mach/irqs.h>6 }2 s+ p- f6 x b
- #include <asm/hardware/edma.h>
8 {6 e; p, w8 e! j" P5 J9 v4 Q6 u+ S3 j - 8 C7 t% s7 T |# i5 x; W) F7 ]
- #undef EDMA3_DEBUG
9 ?7 ]8 a" t. H1 q+ m( }" p - /*#define EDMA3_DEBUG*/
" ^; J" `& u2 U1 [ - 7 Q* r7 Z+ i3 t0 g
- #ifdef EDMA3_DEBUG/ E$ U, j6 h, k0 ?
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
u$ L( ]% ?' z! \4 W7 @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: n, q5 T+ h' q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 g, f* b7 d0 G! R. H+ I) r/ \4 P
- #else
$ S2 E: M: G& g6 F4 g6 Y+ z% \) v - #define DMA_PRINTK( x... )
# j) \ w B" t, o& X, l: f - #define DMA_FN_IN! R$ J2 s, ?5 d9 j7 r7 I6 z$ ?
- #define DMA_FN_OUT6 E: q# f L4 I" ~: s: ~
- #endif; [( Y+ B- K" \4 v H" X" `
- - _7 l( m. m( K# V' C
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( k2 Q. h# d9 B) [9 d% G8 Y7 I
- #define STATIC_SHIFT 3, I) @) n' s R8 d4 X4 b
- #define TCINTEN_SHIFT 206 m) L0 X( j f7 f( T! [) }+ R
- #define ITCINTEN_SHIFT 21
8 S/ o' b' i4 H1 m: r0 B k - #define TCCHEN_SHIFT 22
7 t) v! u" P' H - #define ITCCHEN_SHIFT 234 u( w, J n& c9 X) i
0 t2 ^$ F* C J. k+ Q x5 M- [5 C- static volatile int irqraised1 = 0;# y: B! s5 c! p' Y% h+ ~
- static volatile int irqraised2 = 0;4 V K2 R( Y% a/ _- R$ u, b
- % @: h" d; y) R+ B
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' v! T) A1 a, k9 p/ P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& E. f. @8 M2 V; s& l% a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% i$ w- ~' M8 j- a: p
- 3 n6 e- ?' t: S: a; \$ a/ A& J
- dma_addr_t dmaphyssrc1 = 0;; o' o/ I& ]( E' y% h4 G+ h3 Q" E
- dma_addr_t dmaphyssrc2 = 0;/ B r% y; E* @8 [( X! E3 C& ~: }
- dma_addr_t dmaphysdest1 = 0;
0 w, n7 I5 n7 h' B) W - dma_addr_t dmaphysdest2 = 0;
/ b5 p p5 e5 P
9 c1 M: O- n+ H- {1 @- char *dmabufsrc1 = NULL;9 @, D& m1 Y' a
- char *dmabufsrc2 = NULL;
+ w4 n/ B9 c1 ] - char *dmabufdest1 = NULL;
+ @" l* |/ Z0 {3 O8 {1 | - char *dmabufdest2 = NULL;
/ s0 k* j; T W1 X0 s5 L - `7 W" q% C( V& S$ P9 t, S5 V. u
- static int acnt = 512;
( C1 C3 S+ w5 T - static int bcnt = 8;3 i. |; q% T( ?$ l# F
- static int ccnt = 8;: X7 f1 K& O, [- W5 w. g% h
- 9 |( k$ q* Q, j" q; Z
- module_param(acnt, int, S_IRUGO);5 P# E- ~9 a9 B9 u) k& H' f2 Y2 A
- module_param(bcnt, int, S_IRUGO);. G+ u: p% K- u% t0 w
- module_param(ccnt, int, S_IRUGO);
复制代码
7 m _7 Z$ `7 k2 K$ Q
4 q# H! A5 V* }" g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( I, G) x7 z& b/ C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 `8 K' X! X9 B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 k7 R0 K6 l2 f4 _1 G
7 y7 N. S B1 {9 K) V
t3 o+ M( C6 }) P! L% o |
|