|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( ]0 e0 w: M9 J3 Y- [code]EDMA sample test application
8 T/ I8 h! c0 A! k) \ - /*8 l: \/ \% F' x& _* T. [
- * edma_test.c
9 [% k* K ^) i) [ - *4 f T# N: P& x) d* I
- * brief EDMA3 Test Application
0 A6 o/ r$ d: g& D1 J# u: v - *6 x, X# h* @! s" y. S$ u+ Q
- * This file contains EDMA3 Test code.
5 k7 n Y+ R: Z9 e6 ]) }! ` - *6 g; r, u4 K5 n5 ?# X& }# a
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
v9 V' Q% Z) D- J4 u6 ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 H2 o9 O, |3 u- D7 B% a, g0 r
- * TO CHANGE.% n( o+ W$ R0 v
- *0 U; t5 Z' a6 M0 U, @/ G* C
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
_5 |# _, V4 w v* Y( v% l - *
_% l7 C3 F: \4 w( p: @ - * This program is free software; you can redistribute it and/or0 L0 R+ u5 M1 N( p' }
- * modify it under the terms of the GNU General Public License as! O' G9 ]& N$ J- s; P; J; r$ F
- * published by the Free Software Foundation version 2.
, ?" G9 i" C% c8 A. x - *
- N: l S# f1 z L& h" w0 K9 {: o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any, V+ |/ g$ _0 ?. f
- * kind, whether express or implied; without even the implied warranty% D2 I3 N* s# i0 x7 S5 P+ T
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; R/ `' N- `. T) A - * GNU General Public License for more details.
' t/ O+ `0 @( l- n, t' x; w - */
9 N$ h5 t: W. {3 Z- k" l0 @& L - % d% e, \: B; [3 U* H2 f
- #include <linux/module.h>
' \2 }" W' }' ^, y! D# A2 B - #include <linux/init.h>0 e; H5 H! [& F3 n8 }
- #include <linux/errno.h>; @+ j5 o+ K& q8 N& P
- #include <linux/types.h>
5 @( n2 e3 z- d5 p+ B$ B7 h2 q - #include <linux/interrupt.h>) `% a7 ?( R7 U5 D1 B5 k* L
- #include <asm/io.h>
6 o6 E; T- g- Z5 i; v: v; a - #include <linux/moduleparam.h>
) k- H- J8 H2 h, r5 R - #include <linux/sysctl.h>
4 b1 ^( u% q4 q - #include <linux/mm.h>% d6 S, b* |# V# N6 w
- #include <linux/dma-mapping.h>& |/ Z, {0 i6 x( l# f7 U
- 1 v, o6 @$ p' T9 @
- #include <mach/memory.h>* \' f$ ]) g# f
- #include <mach/hardware.h>
5 C" ^2 O$ M$ A* h+ G9 l - #include <mach/irqs.h>$ J% c2 Y4 n/ \6 ^5 M
- #include <asm/hardware/edma.h>
}/ d$ [# \4 I
( B7 t; @, [2 W* K- F# m/ X6 M6 ^& u- #undef EDMA3_DEBUG( \5 I! C C9 V& F* e: m! ]5 L) n
- /*#define EDMA3_DEBUG*/" Y; y- l0 G3 M
- $ ^( k7 Y8 ]( N. g8 d7 Z
- #ifdef EDMA3_DEBUG
3 d$ t1 }% M7 a9 l1 }2 o0 ~. @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 D/ q) Y& i, j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! ~/ W/ G t( {& d; |% O2 g7 @9 h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) r0 F7 s/ t. @7 [( U - #else
. r$ h# Q5 I0 J, x' |. {* P - #define DMA_PRINTK( x... )
/ Y' j- L, `: e - #define DMA_FN_IN9 K" `+ N9 b$ ?
- #define DMA_FN_OUT9 ^" g1 C- F+ {9 ^
- #endif! F* P$ [/ B: w% p- @
- * R1 P+ G0 v) w' y' \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ P3 ~8 T0 ` q/ A) [& B. d! [
- #define STATIC_SHIFT 3
3 e+ u6 f1 r9 m' M - #define TCINTEN_SHIFT 20
: G8 c2 ~. g' X0 t1 i) s - #define ITCINTEN_SHIFT 219 G8 i( ^9 b- ^( d
- #define TCCHEN_SHIFT 22( e2 ^( e7 b( C2 N" } g
- #define ITCCHEN_SHIFT 23$ `- h; i$ g7 S
- / I% q/ J9 G2 W: S- T4 Q
- static volatile int irqraised1 = 0;
4 ~ T- O+ b: q - static volatile int irqraised2 = 0;
) ?& j& _$ E& J# i9 d - 0 [. G# R% I- c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 ?9 N/ G' u! O2 Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; A9 N* R3 Z2 X/ e: ?& i5 B
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 P$ y, L8 ]" Q4 {. ]$ v
/ `( @0 q0 Y% {" h% p% y- dma_addr_t dmaphyssrc1 = 0;
& k' `- G9 `) A4 z - dma_addr_t dmaphyssrc2 = 0;1 d4 H% M, ?* w; G7 _" q. J2 \
- dma_addr_t dmaphysdest1 = 0;2 x' r; M7 y. r5 p
- dma_addr_t dmaphysdest2 = 0;7 v, v' ?5 t/ G( y) a) w" _+ \8 e
! m$ b5 t/ c6 V" C- char *dmabufsrc1 = NULL;* g: _/ A9 [2 N3 N
- char *dmabufsrc2 = NULL;3 _0 x" a% l; L8 u6 ?
- char *dmabufdest1 = NULL;) C7 Z. w V8 R: b& N; ]3 T4 h
- char *dmabufdest2 = NULL;9 H+ v' r6 p% b7 L/ N! z. |( T
3 \8 L7 Q$ z. @4 B1 y& M i4 a- static int acnt = 512;& L4 K) {) \" W3 I" }
- static int bcnt = 8;! E D6 x) w& Y& t! G
- static int ccnt = 8;/ {3 w/ v. S) c5 }/ i+ z ^
' {# |8 v1 E9 m) Z7 B$ t6 k- module_param(acnt, int, S_IRUGO);
% I2 t. X; ]4 ]. t$ w - module_param(bcnt, int, S_IRUGO);1 d; c! D ?. G) w( J8 w- ]3 e7 X
- module_param(ccnt, int, S_IRUGO);
复制代码
4 ]# M9 A. [0 b9 G! b5 I* _. ~7 q$ |& F2 t1 B0 O; }4 }$ F' c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. E* e9 o1 R- j, D+ darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 t4 z, j, V M0 y9 L& ?% K8 o) q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ P% J5 p) p$ N5 n
# ?3 Z7 z$ e1 S e1 E
, \+ V( `% f9 T, |+ S4 y
|
|