|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' H' ^ @+ {2 {: ~' P- [code]EDMA sample test application
9 k: h' y# }% s - /*
8 Y6 _1 {' t# O; P - * edma_test.c2 @% h+ R; V5 r. ^) Z+ _
- *
Y/ ~4 P; ^2 E* g, Q1 M - * brief EDMA3 Test Application
2 X0 ]+ w; W. T* K" D - *
8 ]# i9 b. u9 b$ b - * This file contains EDMA3 Test code.0 D( l+ n) H$ o- l$ q: M$ w; V
- *1 E) E; L3 E' l
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 ?/ z) M4 |4 e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' e) \! ^) l/ G0 ? X
- * TO CHANGE.% }( s- S1 ?' S) I8 V% l q; y
- *
+ N" {/ h4 g) w- K! V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, ^, D5 Y; X3 a/ e
- *
8 R+ G2 i. s: @' } - * This program is free software; you can redistribute it and/or
) A b0 c( h# W$ D1 ~0 p - * modify it under the terms of the GNU General Public License as$ R1 K2 _) Q6 b8 s7 ^5 e0 R: m2 b
- * published by the Free Software Foundation version 2.
2 [1 x% u0 D- w+ F - *
) l. |" e: j5 Y4 F1 |+ K - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# r$ p: Y+ |0 F. m! U2 x' Y2 s3 D - * kind, whether express or implied; without even the implied warranty0 i% x3 R- R8 x8 e" H. Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 H0 e% N2 Q) V2 @ - * GNU General Public License for more details.6 J+ Q# q* c; S6 h$ H9 Y' L/ D
- */7 Z: H* _6 e# ~. V+ q
- : S' n( \0 C% \' P' k ~
- #include <linux/module.h>: k. w5 w1 W: S* I& O+ W$ G
- #include <linux/init.h>2 X; W+ {. a I* ~, v# S
- #include <linux/errno.h>
* h7 ^7 T4 k1 ~2 g$ n3 o - #include <linux/types.h>2 h- v! _" f9 X; ^9 U
- #include <linux/interrupt.h>% g$ M, t) r+ {* h# _$ c2 J! F
- #include <asm/io.h>
& S, ? f3 I2 D; _0 ? - #include <linux/moduleparam.h>
& d- x/ K* |3 d. z5 @ - #include <linux/sysctl.h>
; D4 m! k% F; D! l1 o0 c1 M - #include <linux/mm.h>" K4 y; I2 t1 s. F% @
- #include <linux/dma-mapping.h>4 u9 ?0 N+ R) e9 I
- 2 n6 P# Q# x! }7 S, w3 f
- #include <mach/memory.h>3 E: u& j7 L% |3 p
- #include <mach/hardware.h>8 f, L7 f% _/ J- m+ q# n' |. d- g
- #include <mach/irqs.h>/ y: ?% P( l3 X) t. r3 q" ]
- #include <asm/hardware/edma.h>5 K% ]6 \8 \. O2 @# B
9 t0 ^3 E7 p j% h$ E2 n- _- #undef EDMA3_DEBUG
* T& L2 R; r& y# C - /*#define EDMA3_DEBUG*/
# H) h! J8 [5 w" X# ] J2 F - * j7 I3 ]" |% j' o! r4 N5 S
- #ifdef EDMA3_DEBUG+ `. C* [& F$ Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" j, w, `/ h6 e" ]6 l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 V U F1 w& ^6 N0 q3 C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! k0 s$ u: e# K$ h$ g - #else1 S. [( J6 ]; [) p% t
- #define DMA_PRINTK( x... )1 \9 _9 G. W8 I) e7 r- {5 M+ M
- #define DMA_FN_IN
. D3 B2 o7 n& s. U5 { - #define DMA_FN_OUT
1 N: V- K/ P5 a2 h& e# Y& e6 N0 }( c - #endif6 v, P( B" [) a- c9 m3 k" r
- 9 H$ L% N9 U1 g1 T
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 ^- ?* \$ ~$ T, y - #define STATIC_SHIFT 3. I8 `/ l" @1 E
- #define TCINTEN_SHIFT 204 W/ @9 H9 \) v4 S* G
- #define ITCINTEN_SHIFT 21
( K" T7 [) T- m- S( i - #define TCCHEN_SHIFT 22( \! |, {$ o$ z# u2 X# D& Y8 J
- #define ITCCHEN_SHIFT 23
8 M. i B. ]) _$ j. V
U/ S4 w3 Z z* Q- static volatile int irqraised1 = 0;* d2 }3 e0 o" D7 s! Y
- static volatile int irqraised2 = 0;) Z' F& H3 f# Y" t. L2 y
- 3 m& A5 r; N7 y. V& d) B ?3 [
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" `2 m9 |& |6 ~0 W/ t- l0 k! A" h" M( \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* ]) T3 S: K+ G4 f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ C6 g0 M- Y5 c2 U( ^
- 1 C% n, t* }& @- T1 ^3 ]% g+ m
- dma_addr_t dmaphyssrc1 = 0;; Q) O3 U) K. m* A& F
- dma_addr_t dmaphyssrc2 = 0;
% N. _/ `- V1 O, H- B - dma_addr_t dmaphysdest1 = 0;/ b% S8 [# z" w4 Y! q7 p, h
- dma_addr_t dmaphysdest2 = 0;6 D( `* b5 n7 }& q+ K: N( {+ {
- 3 C- O* |; G! g4 U) U
- char *dmabufsrc1 = NULL;8 ` o* ~& p. y6 Y5 X( x3 ^
- char *dmabufsrc2 = NULL;
- P( c8 J5 V' a7 Y" T - char *dmabufdest1 = NULL;
# ]( Q! i- B- A" F - char *dmabufdest2 = NULL;
( s" V; B8 @$ n$ P& Z3 O - 8 L x. J D( `# A ^
- static int acnt = 512;
8 f: M, e! d9 G- e$ l - static int bcnt = 8;$ w; a6 D3 v4 j% w' _1 X7 H1 N
- static int ccnt = 8;- r8 D3 l$ y. [" H$ b4 W
- ' E K$ a* [- e4 N
- module_param(acnt, int, S_IRUGO);2 r$ c2 Q$ @9 P' E$ G- G* U5 e
- module_param(bcnt, int, S_IRUGO);
% N6 ?6 S, A9 o/ k2 A! q - module_param(ccnt, int, S_IRUGO);
复制代码
3 p* v6 s9 u& M( c) u. V
2 D/ X' Y! F$ }# h9 { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% R7 u" C; ]4 {* ]
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; r7 X5 R+ b; _. g4 R4 y2 R( Y1 n
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; p8 O& m# b* ?$ J9 Z% }& @
8 k1 Y) R z* C2 a5 G W! s
9 E6 w4 q! ~9 F, l9 A4 Y0 o) M) C
|
|