|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( l( M: Y! x1 x- [code]EDMA sample test application" k3 F) b6 k7 o, d
- /*9 B6 t1 g$ X5 |9 N' x
- * edma_test.c
5 F- f# B2 Y% x3 y2 h0 K - *
& U6 L( ?' F4 ~' L5 O - * brief EDMA3 Test Application
2 k- k6 \7 L, }1 H% z - *% ?2 L4 S, z% M" M- T2 p
- * This file contains EDMA3 Test code.
3 E( G: ^: W# N& v$ W" k - *
* m/ B8 d; {. i$ v5 e0 J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. B) ]9 e! Z/ V% g) R( X# u5 h, ^
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 j7 K" W6 A/ M, Z, V4 e- ?. {# b; _
- * TO CHANGE." p) _9 q1 B- t6 Z
- *
: U) Y# }* J2 P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ r0 U; l) X' G w: O7 }4 y$ U
- *
( c6 g, o/ u7 Q4 l# G - * This program is free software; you can redistribute it and/or+ }5 n: [+ l# J' ~
- * modify it under the terms of the GNU General Public License as* P2 A0 u( v: F! j- M# |
- * published by the Free Software Foundation version 2. C d n# q( G3 ~7 s3 c
- */ C; K% G) K6 t U+ Y! ^$ B4 {, k
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 x ?# B9 ]0 ~* c - * kind, whether express or implied; without even the implied warranty6 z+ S+ B1 ~3 \6 ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. b' _( t# z" [# [
- * GNU General Public License for more details.- Q5 v$ r" X9 E" b, b2 z1 a) ^, [
- */
# ?2 \. Y9 _, W( i6 q0 ^ - 3 g0 j6 W; `# D X
- #include <linux/module.h>
* w% O, E9 J, f% v - #include <linux/init.h>" a0 p, o( H# f& n- v, _0 g
- #include <linux/errno.h>
* B V; G/ ^0 h) w( Y - #include <linux/types.h>" J1 }% p0 I, t! R1 P7 [- e
- #include <linux/interrupt.h>* ?; n% M+ T" V2 R Y2 Y
- #include <asm/io.h>( l/ c- h5 U" {
- #include <linux/moduleparam.h>
' G& m* g$ Y8 o: }5 ~/ p. G# p - #include <linux/sysctl.h>7 d7 @; o% a' T+ T! \' [
- #include <linux/mm.h>/ a2 m. }9 X5 U; D
- #include <linux/dma-mapping.h>
0 j2 o9 {1 O& w5 |4 P' _
2 @' K3 w: a6 J0 _" g9 X( B+ I* ^- #include <mach/memory.h>
# P% ]8 [: A0 y* {' D1 Q - #include <mach/hardware.h>
* F. A6 {* @1 |2 x7 ~$ g - #include <mach/irqs.h>
) _. h2 ? a' j$ G - #include <asm/hardware/edma.h>
6 h) v2 X; q6 @" Y+ g; G - , b$ r) V- n8 k9 S* i9 q% h- g/ k
- #undef EDMA3_DEBUG) ]* f ^' Z- a/ h) M
- /*#define EDMA3_DEBUG*/; P5 P" d" `2 `2 e. m; j" O/ n) v4 X
0 U& t. j* H. z6 X" y- #ifdef EDMA3_DEBUG7 l4 x2 s5 c% d& x- _
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 S; p! i$ z5 ?* G: { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 P% D7 Q: D, r- R/ I
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 F. Y! e8 K) |1 v1 X - #else2 t* r2 b& p, A4 N I7 n1 g/ g$ Z. Q
- #define DMA_PRINTK( x... )
b2 P( Y. p7 ]" T1 ^ - #define DMA_FN_IN
# W1 M, T5 V7 j f- I- e4 o' j Q - #define DMA_FN_OUT
/ ? L/ y' g% n3 y1 p! x: q - #endif
4 l: A2 G' h' f( s$ x" }9 e
+ J7 _' k1 t( R+ A& b- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 x( d* \) Y1 {2 e$ c - #define STATIC_SHIFT 3" p5 Y7 `- {. U0 V( X+ R* U. b
- #define TCINTEN_SHIFT 20
: x6 q6 _2 G8 _/ M3 [ - #define ITCINTEN_SHIFT 21) l" i0 ~5 `6 |! h0 a
- #define TCCHEN_SHIFT 228 {+ I6 c1 i1 K6 `! s
- #define ITCCHEN_SHIFT 23: S% O9 R- A( @- n/ D8 L
* O, K( l2 c/ n" H/ f- static volatile int irqraised1 = 0;
! T) Z) s% B+ N( \' E" Y - static volatile int irqraised2 = 0;, b# P! j( ^0 m4 X
- : T+ ?% Z' }6 R( `& f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 o3 g7 X: P2 ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) y# y* H Z. S p8 S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' `6 n5 r6 D8 j) H9 `/ T. a O/ P0 D
8 M6 {) D% Z( y) U2 \5 \- dma_addr_t dmaphyssrc1 = 0;
+ Z# P& ?; m+ c! q' I1 t* ^ - dma_addr_t dmaphyssrc2 = 0;6 ^- i0 y) P' t( ` I- k3 u: p: \
- dma_addr_t dmaphysdest1 = 0;
; w+ ] x9 I6 V1 S4 w0 D - dma_addr_t dmaphysdest2 = 0;% Q9 }% F8 |% ^+ V: b7 Y
- ; f. O1 p( ]9 K
- char *dmabufsrc1 = NULL;
& y, b' n- s& B - char *dmabufsrc2 = NULL;
3 V" @/ ]' Q" Z7 @5 O5 l2 x, g9 K C( } - char *dmabufdest1 = NULL;) b+ y. B' W9 M. Z% H9 ]5 ]# e
- char *dmabufdest2 = NULL;9 q# }7 R+ w. w+ X$ U' h m
- $ f' \4 v5 D- w
- static int acnt = 512;0 U" X' n8 z- m# V, B0 L! t
- static int bcnt = 8;; y7 P9 X; h* {) f" P1 N7 U
- static int ccnt = 8;0 f, }. ^) c6 f# g( c
( q1 }7 D1 L1 o( |- module_param(acnt, int, S_IRUGO);
* l' i% K: j$ _' ? - module_param(bcnt, int, S_IRUGO);
# [0 ]6 K9 \9 u# ]( J' J6 S - module_param(ccnt, int, S_IRUGO);
复制代码 ( j" |# F* }$ a, Y: K0 Z4 Q
4 u. V( t$ t( G3 \. e) ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ |+ Y% R& W2 i& k- _7 }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 A; b$ C3 Y! F* b" B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 H# h- P! P) h& h+ P9 a- a1 B% Q3 o; J+ ]$ Q3 w
s' A8 F; f! i E( ?( E
|
|