|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 s) `1 V- s, [ z- [code]EDMA sample test application
8 o+ g( j$ \5 z1 b - /*- I. x: b" I/ E2 L
- * edma_test.c
- \, h$ h" q6 I* X2 h - *
* h: _% n4 y: @9 K - * brief EDMA3 Test Application
* u9 s+ Y% Z- y4 T9 a - *
2 M5 R- R4 O* C( s2 `; O - * This file contains EDMA3 Test code.4 \' E2 ~# A# ^9 Z- D/ ~2 B. U
- *$ b! g7 k) J% g4 s* z7 v* C6 ^) ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 `% e. O2 s8 ?9 D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ ~6 \+ S/ v) R @9 q6 Y6 f$ C - * TO CHANGE.' j9 ]' T$ J2 V7 h6 A' t
- *
) h* z" \0 u1 y% _. u - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& b5 C. d/ k9 w3 D2 u8 A
- *
; E8 a7 {* p- ~+ p3 [: J - * This program is free software; you can redistribute it and/or, P+ f) Y }7 f9 y- A
- * modify it under the terms of the GNU General Public License as2 b; V2 T3 L: C5 R
- * published by the Free Software Foundation version 2. ~' @+ |! H3 v, v. n& E
- *3 j' a4 B/ a* g/ R7 j. q0 u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' Z7 X |" o) t: V# X% @ - * kind, whether express or implied; without even the implied warranty
9 V$ G. w, y5 \! ^ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 M9 z' c6 u/ w1 T2 r) {4 Y1 F
- * GNU General Public License for more details.
" J8 n& ]0 x$ T: V$ E - */
! ] H7 l. _/ C7 U0 y
/ k' I% h( W# A" T* ~- #include <linux/module.h>* Z. w5 G/ I6 O
- #include <linux/init.h>
9 R% k( j1 Y+ P; U8 R - #include <linux/errno.h>
" F4 H9 H8 R9 s+ p3 V9 j - #include <linux/types.h>* _0 ?1 v! Z K" E9 ~* A
- #include <linux/interrupt.h>/ y% l0 z+ w! K3 f) S/ |
- #include <asm/io.h>) c+ G8 E- s" Y! n3 z, B; p
- #include <linux/moduleparam.h>; R( q! B; w6 k/ U" F
- #include <linux/sysctl.h>
5 V/ P. a' W; H, F - #include <linux/mm.h>$ b8 t" S5 ^( A* q
- #include <linux/dma-mapping.h>
6 }5 Q# U0 J* ^) ] - 1 P2 w. e5 s5 b1 T5 n- _: J
- #include <mach/memory.h>9 |8 f% H; T. |- J6 k
- #include <mach/hardware.h>
: A8 U. e0 p& i - #include <mach/irqs.h>1 C* O* X2 L. U, P0 N/ r5 E( c0 l3 T
- #include <asm/hardware/edma.h>) K, W3 b/ p' k2 a2 W
! \$ h7 y A* z" g* n# k- #undef EDMA3_DEBUG
( V5 q1 p) x/ m/ G: X3 x1 r# w# | - /*#define EDMA3_DEBUG*/
* o5 Q7 v- ?1 N& u" k2 q2 y - 2 z( S9 t( I) F* G7 I
- #ifdef EDMA3_DEBUG
( P) V. S8 O) Q7 u - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! h) u9 I8 T) A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 s, S! {8 P7 L* \4 r: { z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* J( L5 |7 h7 Z, A - #else
$ C) g/ T! N# \: n2 X - #define DMA_PRINTK( x... )! y$ y' a; T& |
- #define DMA_FN_IN
( c1 P2 J5 T- w- {0 C - #define DMA_FN_OUT L" G: t, i; j+ G* W
- #endif
6 s o6 l4 q# C
l( \# e0 G* s/ L% q' n. B q1 z- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ o: ^3 J; u2 ~8 O
- #define STATIC_SHIFT 3' G7 T+ ~; K; A& m \
- #define TCINTEN_SHIFT 20
o! }% i+ S; g* Q3 I9 m- | - #define ITCINTEN_SHIFT 21 N8 B: l, l* ~1 R
- #define TCCHEN_SHIFT 22
" B5 t c5 s; b) U, I/ D - #define ITCCHEN_SHIFT 230 m; x. n( P9 ~/ y
: X' p, A, a! m3 U5 V0 b6 W- static volatile int irqraised1 = 0; z# b6 _ {# t* u5 N, s" ]8 S
- static volatile int irqraised2 = 0;
7 e7 Q$ r7 m& a& G* `8 T+ H8 d+ m - : C% F8 ^1 O9 a! n0 c0 L
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: n! G' p% `! e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# S) @! S& R9 V; o3 u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ R; y4 A8 b# T% J, ~
* w: f$ E. }5 O0 U- dma_addr_t dmaphyssrc1 = 0; R9 i4 l+ q2 y+ y& M; h
- dma_addr_t dmaphyssrc2 = 0;6 d' c' I4 A }2 a! o
- dma_addr_t dmaphysdest1 = 0;( ` r$ O, b1 k9 T" V3 U
- dma_addr_t dmaphysdest2 = 0;! N7 p! K' `+ x6 A8 }3 G( e
, B) K+ ]7 R4 l1 ^1 k& @# |& b2 ^- char *dmabufsrc1 = NULL;
/ D2 O( E) \* P8 z, C9 @4 f" ~2 L - char *dmabufsrc2 = NULL;# J' @5 u5 r. |/ }: o
- char *dmabufdest1 = NULL;! L" y! Z, ~' N8 B0 h: U
- char *dmabufdest2 = NULL;9 B3 o# u, j$ q
* B. n6 A7 y9 B* _2 c: e+ l- static int acnt = 512;, y) M. c5 H( n g
- static int bcnt = 8;- P4 i6 {( Z; @1 T' r+ k \3 n; G
- static int ccnt = 8;4 L$ A( g- X3 F
- ; m/ |6 Q$ F$ [0 i1 u1 K r
- module_param(acnt, int, S_IRUGO);
Q/ \+ F) @* K9 P7 V - module_param(bcnt, int, S_IRUGO);. D/ D6 T' v, G0 q3 P2 K1 r
- module_param(ccnt, int, S_IRUGO);
复制代码
6 G+ D3 u7 W0 R+ E( p
9 j! X) [* J2 d9 H# R. D, C 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 \( b. ]# @4 y D( \$ Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( t' i# h6 A/ L: N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 [% K! A5 Q6 O
$ {3 m: ^) h! e
1 |4 n; z2 m/ x) q* i |
|