|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 a+ R9 _6 @& s3 t+ p* [/ {, c5 x
- [code]EDMA sample test application
# o5 z$ c8 j4 H- H+ S0 i, J - /** K8 y2 ^. k4 M% T. s1 P0 e
- * edma_test.c
: P* M# O( v0 c" l- u - *
" q9 N; a. k, V - * brief EDMA3 Test Application+ j [6 Q! F6 J1 w8 s( r
- *
* S) ]! e* ^9 l0 G9 ]/ v - * This file contains EDMA3 Test code.
3 i, B5 N# m4 e( v) a - *+ q& z1 l D' t3 F' R( Q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 P' m6 ]/ x8 o1 D
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- E3 Q/ u0 p6 C# u# a- A/ D3 |) m - * TO CHANGE.) n! z7 q( O1 W& |
- *% e, [- R# \: H/ }
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. G2 C( m9 l3 j% J. k
- *
- t$ G6 }9 ?& J0 c - * This program is free software; you can redistribute it and/or
7 z3 T: H. A" x& M - * modify it under the terms of the GNU General Public License as
7 m9 |8 u( ]% T7 z# z* K- V - * published by the Free Software Foundation version 2. ?7 t! E2 _$ p% u% ~0 W
- *
* A6 M: m0 {& t, o% ^, M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! R: Z7 p7 o# E+ ^& Y! ~
- * kind, whether express or implied; without even the implied warranty
8 q' y0 R. `# \8 `( Y2 [$ c8 l2 } - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- S$ o# Y- H9 Y$ {# {% I
- * GNU General Public License for more details.! @, z1 m9 A- e! ~1 y- [
- */8 `0 J9 j; G: D" j: W9 r3 y7 E9 Z, x
7 {+ |8 V/ @: s5 c% ?, s- #include <linux/module.h>
$ k& F {) q- D0 _6 r0 Y - #include <linux/init.h>$ f$ ?1 c+ |8 W4 w; l
- #include <linux/errno.h>
+ X X% E/ q5 @& p - #include <linux/types.h> v* p `) x, C
- #include <linux/interrupt.h>0 \6 L2 g2 z3 c8 A1 ~5 i) Q
- #include <asm/io.h>
/ H; ~, Y) x9 m$ f, }( b4 [& G - #include <linux/moduleparam.h>
' u( b* p2 W4 T/ f: L8 T6 Q - #include <linux/sysctl.h>
8 t$ m5 i- z8 T$ P% N - #include <linux/mm.h>
~* E4 f, v9 z5 M S - #include <linux/dma-mapping.h>$ E. M7 B5 `( h! [) R# I/ F2 q: ~
& x7 c5 x7 ~8 V; Y3 I- #include <mach/memory.h>* r$ |4 U; R& y( M( r; p
- #include <mach/hardware.h>
* U; B! m( H! ` - #include <mach/irqs.h># y- t4 a( N( M, V8 _9 ]7 j* b
- #include <asm/hardware/edma.h># ]( m- H8 e' Q$ u) X& S/ X: ?
- & X4 w% n5 L) }/ k/ [, ~+ w* ^$ i
- #undef EDMA3_DEBUG4 n, u) @8 B3 x4 O0 Y& m8 W, B+ R( |5 r6 L
- /*#define EDMA3_DEBUG*/
, ]3 N1 G7 K8 h" x
: {* j/ L$ z3 x( l/ B+ M2 |) ]- #ifdef EDMA3_DEBUG! g6 D6 A4 m+ P7 S
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ O3 a( V4 F" O- e8 l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- j+ s; }$ N- p: q" M, g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! a; k2 w! ^+ q
- #else
2 P8 R4 U7 B% ?# s - #define DMA_PRINTK( x... )
' w$ |: H) P2 B9 g - #define DMA_FN_IN
. h f* }: O) n1 K' U2 r1 S( _ - #define DMA_FN_OUT3 U; y0 Y5 e+ O6 z" z/ _
- #endif
, S8 Z$ W+ q# x! h - , o5 o" f8 C6 M) C1 H6 k
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 |2 D( |; Z! V9 B" V& q - #define STATIC_SHIFT 3
( @2 G6 V( T/ z1 Q2 O$ s$ u \) F - #define TCINTEN_SHIFT 20
$ _" h+ p5 l, R# V# Z - #define ITCINTEN_SHIFT 21
! D# Q: u4 b" R7 ] - #define TCCHEN_SHIFT 22
[5 c! b) L; T! \2 Y: J, n - #define ITCCHEN_SHIFT 23' e6 e$ y; K8 F4 f
, ?* p8 I$ S9 J% f2 g8 F- B- static volatile int irqraised1 = 0;% J) y; X# o! @% J. x& u
- static volatile int irqraised2 = 0;4 F( P0 o2 V$ s) N0 F) @1 |) R2 l E
, y7 q) d" G- |5 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ j; k$ G* X7 y5 M0 ]) J/ f
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& B) m# H6 H- b! j H - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! l7 ^, i# s) M1 B - 9 J3 f1 W: u' w( s& T$ @+ m6 B
- dma_addr_t dmaphyssrc1 = 0;
+ ? d, I. C6 K6 w4 |$ ^' n- | - dma_addr_t dmaphyssrc2 = 0;
% @) i5 J) V, c - dma_addr_t dmaphysdest1 = 0;
# y K6 w. n9 T- W! ?5 \. G - dma_addr_t dmaphysdest2 = 0;& e) K! T# |' ?, @4 d/ N2 R! n0 `
- $ O9 n0 H" f. n! ]9 j! \5 W
- char *dmabufsrc1 = NULL;0 j9 r, p- v. ?9 O7 {. l3 A# n
- char *dmabufsrc2 = NULL;
4 S+ T A3 i8 A4 B - char *dmabufdest1 = NULL; d- F/ n: v' B
- char *dmabufdest2 = NULL;: H. E3 ]# j0 U: X' P% J# k
- K% H1 n7 { o9 ~& C( n
- static int acnt = 512;
5 S; O' {& ^8 U7 T8 ]. q+ M# \; d - static int bcnt = 8;
! k- U' J+ i0 K* N( i' K: Y4 g7 n - static int ccnt = 8;
1 X B) F& J. E7 Z+ a# h - # T' C; d3 N) d6 S- a- G2 ~% O. ?
- module_param(acnt, int, S_IRUGO);
1 F( r S; H8 A+ f& i - module_param(bcnt, int, S_IRUGO);
g! s2 a# {- f R2 r- L4 ~" P. { - module_param(ccnt, int, S_IRUGO);
复制代码 - V g, e( U& C- P% K0 E
! a" E/ ]0 m; M2 C, t* @% \4 Y* Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 O C0 W9 O6 \5 sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 r( t5 U2 y" @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 ?% ?# N, s* k& ?! g1 e/ N' d9 N+ T/ M& }. R" _* l
4 q7 c' G4 H# \
|
|