|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) B } O# a3 A- [code]EDMA sample test application
y9 o* W$ [9 T2 g% T - /*
) _5 w* l% f( j/ O) S6 S ` - * edma_test.c" b, C. A9 B& f: }! G. T
- *
* ~$ A5 c; \& t+ p) ?: U - * brief EDMA3 Test Application
& W% F6 L+ k' N' ~1 H7 X8 i, ? - *+ t+ S& q8 K S
- * This file contains EDMA3 Test code.
: v* m8 N1 B* f; C) I: F, j2 d - *0 n- w& ^! N) O0 W# |0 V
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, T7 L* G; \2 {4 K
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 E: D( k$ q# j6 A+ ~ - * TO CHANGE.
2 q" V: N2 Q4 J6 M7 ?- G4 E [ - *. o' S( X; |6 f1 l" ]
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, T4 |0 k" f, H, ^; O - *
. h& Y% t! r! W6 _3 B: C% Q0 S; F - * This program is free software; you can redistribute it and/or$ Q. V1 E1 [# d
- * modify it under the terms of the GNU General Public License as
# \+ k! R; I9 @; K" e3 p - * published by the Free Software Foundation version 2.
: J0 u2 w% @ y2 e9 _) M' u/ ]+ C - *
+ N- p, P7 h% Q o/ d. d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 f& Z% o/ b" e - * kind, whether express or implied; without even the implied warranty
# S1 ~% F% v. F' W) X; N8 }% T' \3 {, | - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" e9 f) M* b7 ^ Y% o2 Z
- * GNU General Public License for more details.
& Y1 {" ?6 w0 G( S* C - */& k+ s* |! B5 ~/ N. q& ]. K
) p0 X6 F, p/ _6 B w- #include <linux/module.h>
* w3 D6 b2 \* V/ `: n! m% `0 w - #include <linux/init.h>7 ]7 |; B& t: L4 Z
- #include <linux/errno.h>2 Z8 n C/ x3 M* t3 p$ a" X! m
- #include <linux/types.h>" m* Z' ^% J6 y6 B9 H; _
- #include <linux/interrupt.h>
/ p* m3 g" |) B& h" x; L0 @ - #include <asm/io.h>
) K: D6 J4 c6 s5 V+ w - #include <linux/moduleparam.h>! ]+ o5 \% t0 x- x) _
- #include <linux/sysctl.h>
0 }2 N, c o/ D" ?' O+ e - #include <linux/mm.h># E. x. Q8 V9 ]/ }+ Q/ W+ T7 `
- #include <linux/dma-mapping.h>
( n# M9 E* t, S8 C( s) F- H
. Q( D( |; R9 L; w- q; p- #include <mach/memory.h>
e2 F+ \1 w9 J - #include <mach/hardware.h>
/ O1 ~' T$ Q7 C4 y7 Q. g - #include <mach/irqs.h>: p- b* u! k3 ], F$ L S
- #include <asm/hardware/edma.h>
8 y3 S& \" Y7 ^5 L
: _$ E' y+ A) l. p4 J3 X- #undef EDMA3_DEBUG
0 m! ^! y# E* \ - /*#define EDMA3_DEBUG*/' M7 \- U+ v n0 B7 B
- - M. g1 K# v; I4 n! U/ ?
- #ifdef EDMA3_DEBUG
" g) \7 p! p5 H$ ?: s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 t* @7 @2 n! s/ u$ q; J1 l/ G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 @+ m% a+ f5 j* L* Q* `+ s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! y2 ~3 W- Q- b. T" H8 t
- #else
, U2 p1 a: i' }. U1 Y3 B5 X - #define DMA_PRINTK( x... )
8 C/ _: p7 i4 i - #define DMA_FN_IN- l9 f' f7 P, G* ?* G, R0 Y/ s
- #define DMA_FN_OUT
, C6 U; D' |! F1 Z - #endif
; ], @- N- h8 \5 a6 x$ ~$ D - ' x0 l" a: C, W) p3 O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! v% B( Z6 v$ F4 E
- #define STATIC_SHIFT 3: n7 }/ o* z1 {5 W# N* p
- #define TCINTEN_SHIFT 20
& `7 S+ B! {- t2 p X - #define ITCINTEN_SHIFT 21
7 ~$ R( P# _) M$ C2 t: T3 T - #define TCCHEN_SHIFT 22
* s1 \ X D p6 P8 k; @( t - #define ITCCHEN_SHIFT 23
, B" W% [1 o$ P2 T
5 r6 @& }$ b0 g8 N' V% T- static volatile int irqraised1 = 0;
: v/ L' c. M4 m( w$ V& g - static volatile int irqraised2 = 0;
7 ?+ y: T! @* G" i; K" {- s - ( J2 ?" S, h9 l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' T& }: l9 m6 |% i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, c2 a- j. G6 H' t+ Q8 D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; a: M) @* w- } ] _
8 @# ], w S' j* L0 g0 b, [- dma_addr_t dmaphyssrc1 = 0;
" N9 C; f. z g - dma_addr_t dmaphyssrc2 = 0;
# z) Y" m+ q2 L - dma_addr_t dmaphysdest1 = 0;
& m; x. B( H" F A+ ~5 e, I6 Z2 @ - dma_addr_t dmaphysdest2 = 0;& T/ e, N0 g2 [$ _' |
- r0 {; N3 W0 P# ~5 U
- char *dmabufsrc1 = NULL;* M( D' ] ?1 t9 V/ [! C( A8 m8 H
- char *dmabufsrc2 = NULL;
- W2 I( Y/ d) G - char *dmabufdest1 = NULL;3 b, ]+ {) M9 o; j/ Z; E
- char *dmabufdest2 = NULL;
% M4 F6 j! b& Y. I/ h B' ?% t, V - 3 c# Z- h4 M( i5 S; {4 s' J' F
- static int acnt = 512;
+ N. P2 ?9 @: l3 c5 }( R - static int bcnt = 8;4 W* G% L! ?9 d p0 L/ |
- static int ccnt = 8;
7 L' ]2 V+ L( O @% j( n4 h4 }
. V, }9 W% H+ ^- module_param(acnt, int, S_IRUGO);3 V+ t1 x% ?1 z/ {
- module_param(bcnt, int, S_IRUGO);
( _' e4 g( B1 g6 h - module_param(ccnt, int, S_IRUGO);
复制代码 * \/ Q+ N, j3 Z: ?
Y I, K5 z) o' g. f/ K7 _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 r# Y" ~3 \: @: J0 x* e2 Q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 p g# b, B' F3 W+ A( s
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. ?" R& a8 Q+ X$ [/ v/ B& M, M; i7 N% i R! F* K! z! g
( D. n3 J; n4 A1 U
|
|