|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ |% W3 `" G( n# D; g @+ }' d) ]- [code]EDMA sample test application
5 Y# G: ~+ f( _0 u/ H3 Z( b4 h% b' o+ r - /*
; l8 J4 j$ `) o0 _ - * edma_test.c. y G+ h. d& ]' _
- *
- ~. U3 ^( R- P. y0 E - * brief EDMA3 Test Application- e5 W6 u6 K4 Z: ]7 x
- *
4 q: m$ k% M6 ^ - * This file contains EDMA3 Test code.' ?. p; Q6 |+ U7 [; d2 b
- *
1 A) X5 |9 N+ {9 m4 H, f - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ ^ s2 Y0 a3 J4 e, @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) A5 t7 b" j! f9 n, p! g4 N- L. w$ q - * TO CHANGE.- ^ {! k) t3 Y) i. \" N
- *
3 D" j$ m/ }1 X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- ^9 w+ G: Y2 T - *
3 v6 Q3 [; _* y' ] - * This program is free software; you can redistribute it and/or
0 X7 ?. Y3 N, W) x. H3 v - * modify it under the terms of the GNU General Public License as$ q! @' v6 [/ e9 X. I; ?8 K
- * published by the Free Software Foundation version 2.
( ?2 C' H& e* a4 T( E! e* j - *# D7 r: U, F: Z7 T* p! g
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any! R4 {$ M$ s7 g. U O- ?9 E
- * kind, whether express or implied; without even the implied warranty
' N# y8 y s0 i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) G2 C2 i) s; T
- * GNU General Public License for more details.: l) B, i H0 O6 t9 H+ F
- */' C: n7 O* V- A: G% V, o v
4 _4 s% b: B) r' y( X( s2 Q1 a! ~1 a- #include <linux/module.h>
2 ]! L% N+ Y+ H" g$ [ - #include <linux/init.h>
0 C2 j/ f, }5 V - #include <linux/errno.h>( V) W% ~" f/ g+ x4 D1 R
- #include <linux/types.h>& t, X+ b# @9 s& Z1 S( O& c
- #include <linux/interrupt.h>
" B* ~. R' T& {/ a/ f - #include <asm/io.h>7 k2 j: K" O* r1 P( s- h U
- #include <linux/moduleparam.h>% U; _ q6 j* m- l+ g
- #include <linux/sysctl.h>2 ~; L) i1 Q o5 {; ~1 B
- #include <linux/mm.h>
7 P1 a3 S0 Z! l4 ~2 G+ u4 l - #include <linux/dma-mapping.h>
# q" ~* d, D, H0 m I$ L# J2 r% u' k
2 v: P) S/ C; z4 b# z- #include <mach/memory.h>
9 [$ u" X V) n4 B9 r, p - #include <mach/hardware.h>
( ]4 G& b9 j, A+ v) f - #include <mach/irqs.h>
9 O. Y" Y2 K+ M+ K4 o" Z - #include <asm/hardware/edma.h>
. W% Y, Q0 b5 `; f - / u% ]6 n" y+ C+ R4 N
- #undef EDMA3_DEBUG$ p4 D, `8 X0 t& T6 b6 S& ]
- /*#define EDMA3_DEBUG*/7 c5 h( B1 f, W7 C/ E
1 T/ a4 l# P+ U9 E2 ~- #ifdef EDMA3_DEBUG3 E0 `6 Z+ w: v' l# b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, h$ q8 M8 [: z" Y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ y: C* X9 B' Y+ _- y" t; A, o - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& J D( u" W/ m! R3 y
- #else
. t4 Y' ]5 z7 S7 t6 ~9 {0 U - #define DMA_PRINTK( x... )$ e5 [+ O6 [8 h# @2 I1 r# [
- #define DMA_FN_IN
& R5 L* m/ [ i* V8 h) z - #define DMA_FN_OUT
9 m* N. K- R; E) e - #endif
: a0 k" ]7 D! g - . v( P& f! U w2 P* s) O7 g
- #define MAX_DMA_TRANSFER_IN_BYTES (32768), e: ^( s! w9 U, ?" z
- #define STATIC_SHIFT 3& Z4 [& ^- m2 i$ L
- #define TCINTEN_SHIFT 20& \+ E' u3 g6 Q1 _1 x
- #define ITCINTEN_SHIFT 21
! e5 T t" k0 @3 M) a - #define TCCHEN_SHIFT 22$ U- u8 z+ @5 o2 y {/ g
- #define ITCCHEN_SHIFT 23: ?; x; w# t+ ~) V8 ]" f
- 6 a) _2 u+ k# `# U1 v0 ~0 X8 d' m5 z" K
- static volatile int irqraised1 = 0;
- ?2 z2 |5 ]4 |3 q - static volatile int irqraised2 = 0;- f, G; e2 d% T3 k) k) k
$ p4 D! M' K! [- t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 x4 J- u9 [* G$ R* ~# E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" C2 S# i1 \7 `3 |+ @+ H* T! a4 u - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- B$ M/ i, s8 w. u6 m" a3 P
9 T; ]8 O! ]/ ?8 @6 [- dma_addr_t dmaphyssrc1 = 0;
* ~* r6 Y# j, J- G! Q3 e5 W4 ? - dma_addr_t dmaphyssrc2 = 0;
# y! o; \* }% V0 a+ M) G. _: N: ` - dma_addr_t dmaphysdest1 = 0;
( J3 m5 i( E6 z" V - dma_addr_t dmaphysdest2 = 0;
; f% H& M/ }1 p1 N2 c - / C) W3 P7 S$ Z. _4 }
- char *dmabufsrc1 = NULL;0 u6 c" D+ u* G5 ^, a! Z; ]0 z
- char *dmabufsrc2 = NULL;
% u) D" H7 I: @4 I3 p - char *dmabufdest1 = NULL;
. U5 F; \( h8 x0 V: |+ T* i4 y8 Q6 V - char *dmabufdest2 = NULL;
/ L/ x* G6 ]+ b3 ]( P1 r
7 ^3 o- S5 e: e' u" F, F( I- static int acnt = 512;9 R4 F( F$ U9 S4 g; N
- static int bcnt = 8;# t4 Q) e1 y: N" y, u5 J: b
- static int ccnt = 8;: d2 \ \1 O' s* L9 d$ V5 l' d
$ b) r( w. m: c' m% ?: g8 V- module_param(acnt, int, S_IRUGO);8 H h) m5 u3 w/ o8 Y
- module_param(bcnt, int, S_IRUGO);& ~7 a: L& W1 S" F
- module_param(ccnt, int, S_IRUGO);
复制代码 ( n% m* g. p" |3 U- j: t; b: u$ l. k
7 `: e; L4 N; C0 U6 o) ^ Z% K# I 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" t5 R1 ?7 r4 _$ ^% q5 ~6 I8 p+ L
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* Y8 S q+ u% J" U" q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; z( w! q! h- {& Q6 r7 ^8 @4 J9 h/ W
5 h1 h6 Y1 B/ J$ E" D C0 g5 D% m" |. f" f( b
|
|