|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 H! a0 x. z! t- U, p# N, M
- [code]EDMA sample test application
3 w8 Y6 C3 z, i$ Q' |9 ~+ f. J - /*
4 C, ^" y+ ^; i5 G. K - * edma_test.c' o6 \5 q9 H4 r
- *1 O3 E0 g3 M7 ^0 f j; _
- * brief EDMA3 Test Application: t/ b0 Q/ p1 \) u! d) Z
- *
4 S3 u3 _) _5 e) X6 p' j% ^( N% \ - * This file contains EDMA3 Test code.
! {9 f2 a) E" |4 R" Y4 e9 }2 G - *" `5 u+ j& @/ E; _- r+ X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. G4 S2 U" h$ c0 F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ }- i+ I$ H4 M5 C+ y: `
- * TO CHANGE.% q3 o; @1 w+ ^0 d5 Q/ k7 i
- *
$ K( O& m% f/ n# h. ^5 G/ ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 X* ?( P+ T2 r% ~% K# F9 _ - *6 R7 I0 P, J9 o- c. Y6 a
- * This program is free software; you can redistribute it and/or
2 S0 b) \1 x+ j6 N/ g - * modify it under the terms of the GNU General Public License as# C) k4 a9 n3 |% ]+ E
- * published by the Free Software Foundation version 2./ K' T0 Y/ x0 \; i3 N
- *5 \7 @7 J; K7 t2 Q! Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( ?% H/ C! V8 m" N8 p& d2 w - * kind, whether express or implied; without even the implied warranty
' F7 l2 s- N1 S- j8 t- c7 j* w8 m - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 B! i) [ E7 y( Z1 c1 Z. G) O - * GNU General Public License for more details.7 ]/ x( b2 K# q: U' }1 G9 V \/ \
- */1 r: y5 B) t p- z( v$ k* V+ F) W
( V$ O! N4 b$ h0 N3 X3 ^; K! E- #include <linux/module.h>
1 t3 V; R9 P# @. R6 _1 z9 L2 _8 s - #include <linux/init.h>5 I) g7 ?* A. I7 g+ J1 S
- #include <linux/errno.h>! r$ U O( _+ g D
- #include <linux/types.h>$ T! q8 v9 h& d) u' R5 ?* ^* G
- #include <linux/interrupt.h>4 u* j ^" ?6 \
- #include <asm/io.h>3 ~( E; |- W& Z7 h5 i |4 ]( G
- #include <linux/moduleparam.h>. O h9 M, t: ]& k! y8 M& _
- #include <linux/sysctl.h>
: A9 f G C8 _, Y7 A+ G2 q: t - #include <linux/mm.h>
6 U# v' w. Q0 F; }. _1 T' h - #include <linux/dma-mapping.h>1 S& E' G$ Y n2 i4 g8 z
2 W) C8 o3 e; C1 B# Q" m) T- #include <mach/memory.h>
) z- q7 K. }+ g4 z0 N/ m" E! p - #include <mach/hardware.h>% i' q$ D4 u/ ]4 c
- #include <mach/irqs.h>5 _( t& \% Y/ p& r9 @
- #include <asm/hardware/edma.h>
+ X, O+ j" E! l6 w - 6 q7 _5 D8 u8 y) B3 k& g8 l
- #undef EDMA3_DEBUG
) s" G3 L9 \& v3 d5 C5 k* o5 K - /*#define EDMA3_DEBUG*/
5 }8 |9 j' P7 M8 ^5 ^% B - & ]0 i* ~0 F; k$ \' @
- #ifdef EDMA3_DEBUG
1 ]5 a% ~, c1 u: L! i* O4 X( o- ]7 J/ A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 l& N- u ?7 j! J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- D/ `. x& z9 R; m1 e7 d% j+ @! } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 n% Q' E' ~" X4 ]- v
- #else) r+ a; J/ c# `9 L/ n1 R
- #define DMA_PRINTK( x... )
/ v, w& `7 X( J$ B/ `% v5 E - #define DMA_FN_IN
+ e3 r8 d+ J" E ], F0 d - #define DMA_FN_OUT5 J7 Q5 a% S7 L1 Y: V
- #endif, X6 Y; j t1 Q4 I9 _+ @- n
9 {& N2 X4 h8 @6 q u# J- ?: e" G- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* `/ O$ y( p2 l9 L4 B* U - #define STATIC_SHIFT 30 a2 I: H+ R7 r! u# ^6 S' E( k
- #define TCINTEN_SHIFT 20/ B$ U+ Q8 w. H& ?4 a
- #define ITCINTEN_SHIFT 219 K2 | b5 X1 }* _
- #define TCCHEN_SHIFT 22
* r/ t' b# e- [: b8 w# n$ p - #define ITCCHEN_SHIFT 23$ z: D7 k& j I8 \4 A
2 R$ b$ M; l% J: V/ `- static volatile int irqraised1 = 0;. Q) g5 t; l! o
- static volatile int irqraised2 = 0;
, U" I$ R: [/ h+ `
5 x; I. R4 j5 Q9 \+ g! `- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) }4 y9 U4 r0 {; I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ g( D9 {2 r6 _0 k. y# C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 N3 O1 X; K; S' m( n
- , ~6 y7 e4 n! n7 J5 b6 t) p
- dma_addr_t dmaphyssrc1 = 0;
3 G/ q$ v% j4 v+ Q - dma_addr_t dmaphyssrc2 = 0;
' J, r" m: B- _3 [0 Q- b - dma_addr_t dmaphysdest1 = 0;
4 O6 J- o) Z! j! B/ j/ a* I8 Z - dma_addr_t dmaphysdest2 = 0;0 r- u) b- S% d" F) I1 ?
3 v1 t6 E2 ]6 P/ T5 V- char *dmabufsrc1 = NULL;* ^9 s8 V$ ?0 w h5 q
- char *dmabufsrc2 = NULL;8 N$ M4 l# W' I0 S& e6 T( i/ Q3 F n
- char *dmabufdest1 = NULL;$ l' `% i9 A: r4 x3 V0 E
- char *dmabufdest2 = NULL;
! U# N; r+ o. V5 F$ B* D
, d4 B: ~7 G: w) Q6 F- static int acnt = 512;' a2 j8 V* S" ?4 Q
- static int bcnt = 8;% \0 H3 {4 ]6 j: k2 v" U
- static int ccnt = 8;
( }& U; D, ]* Z+ H `1 Q( T. g
( {, C! j9 o2 |# f- module_param(acnt, int, S_IRUGO);
6 O( r: {3 F% p' m3 a z - module_param(bcnt, int, S_IRUGO);: H) ^+ E8 S4 F
- module_param(ccnt, int, S_IRUGO);
复制代码
, G. {' A# E, D; V4 m9 g3 X* u. A+ z$ Z+ z1 {2 c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 U! s* F- P Farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 x% K% J( H! x# R
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 B! t d+ z) W, y
t( Z; `! E$ { l: T
9 K2 s+ h P9 L3 Y' W
|
|