|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# M$ n# p2 K* o( T( W6 e' t- [code]EDMA sample test application
& O/ Z7 Q8 w7 M9 g3 O - /*
7 w n* v6 K1 V P" A# ~ - * edma_test.c
1 z: M! V$ H; W5 o6 j7 f1 _ - *
( u% H5 M9 R# n* H v' c6 W - * brief EDMA3 Test Application
9 n$ j8 G! e" n - *7 `& p6 s2 w; B8 q, r2 L2 H
- * This file contains EDMA3 Test code.6 U4 f* k& _+ y' I: l( j
- *) ^7 ]% y+ ~2 F6 _
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" m1 [2 q4 l- Z E! ]5 t. v2 A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 P; m8 x0 ~! H0 n) G4 M- }
- * TO CHANGE.
/ J. {2 E3 J9 U8 C4 u$ A - *$ Q3 j, G$ R# c) t# Z" W& |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; }6 i: L+ D/ E7 \- m& w: @
- *& T# X3 R- h0 P) f; M* ]0 L
- * This program is free software; you can redistribute it and/or7 p; d9 [3 v0 t6 I5 Y, n. f
- * modify it under the terms of the GNU General Public License as
4 R3 L2 f* t1 C9 y% S- G - * published by the Free Software Foundation version 2.; D0 C( }" N* O$ l; v; i
- *
: @& x6 o4 f$ H" X: Y5 I8 }% f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, \) |' t, K1 Z7 ~6 ?( \ - * kind, whether express or implied; without even the implied warranty
6 A: @1 o* [2 ]3 q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 q; I; J' u3 H& R+ r) m - * GNU General Public License for more details.# U) }3 Z# K- e, `* V X
- */7 i0 g @/ A1 S" [
- 9 i# E4 n' M6 i4 ~/ l
- #include <linux/module.h>, B: n8 c+ N/ J3 [% s/ |# {
- #include <linux/init.h>
- Q5 _$ S5 L) C, K& S8 F! m - #include <linux/errno.h>; Q- q2 c1 y1 \. I7 j
- #include <linux/types.h>( O U! P$ S" B' d
- #include <linux/interrupt.h>+ @% O* Z7 |0 q) W% c0 n: b: S
- #include <asm/io.h>
- ~ M+ g( M; Q8 R( ~& g - #include <linux/moduleparam.h>+ k7 T* F7 O% w4 Z
- #include <linux/sysctl.h>3 S4 K) H2 {8 e' v S/ n8 M
- #include <linux/mm.h>! p( ~0 m$ V' ?; q0 u
- #include <linux/dma-mapping.h>; V p9 G/ |: M1 E' H: y
- ) X/ Q0 X; P- L# ?$ j. o
- #include <mach/memory.h>
/ a z D7 \8 i0 N9 J& w# ]* d - #include <mach/hardware.h>3 n: o. a8 z# S: w
- #include <mach/irqs.h>- B5 L' v! s0 {$ X8 s
- #include <asm/hardware/edma.h>, W# u5 x3 a2 E- m' C, L# y
- ) c/ J# \7 ?4 u
- #undef EDMA3_DEBUG( O: i! q5 R8 ~" N; o* @8 w
- /*#define EDMA3_DEBUG*/4 {8 C5 w m1 I& x
) i+ g1 {# A: J- #ifdef EDMA3_DEBUG4 V, B: o# }$ a. W( @( A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" r- ~- c+ _2 i" r6 {0 y6 b' `
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* s. U, m. B2 g2 l' {6 c
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! Q: N- [; X9 M. e# V0 ~7 ` - #else7 K. ~" l: E" X/ F2 x) {, l' l1 @
- #define DMA_PRINTK( x... )
+ m, t. h% w" K - #define DMA_FN_IN
* V n) m3 g! w. N4 a; |& K - #define DMA_FN_OUT
/ P4 b! j+ |0 ], p - #endif
+ @+ c6 h0 h- L( {1 D- b
; z2 c4 c" h0 d- #define MAX_DMA_TRANSFER_IN_BYTES (32768), J& V7 ~$ T; ^ {. t) ^ G8 c
- #define STATIC_SHIFT 36 T t1 I z" _+ W: v3 }$ u
- #define TCINTEN_SHIFT 20
+ w0 z2 E" ?, }6 C - #define ITCINTEN_SHIFT 21 J4 a( S0 i: b- A9 ?
- #define TCCHEN_SHIFT 22
# y; e0 P" I5 O; c' U' U/ c5 d - #define ITCCHEN_SHIFT 235 b) D, ]1 W2 F ]$ f
- ) g: e( x3 }5 h" e2 R5 l5 v
- static volatile int irqraised1 = 0;
4 @/ e3 K" r n( J' Z2 Z3 m. e. Z# u - static volatile int irqraised2 = 0;
' k3 V4 ]5 P6 w% ~
, s4 R4 `1 ^2 u# u! l ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) j# Z* D2 u e( { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 y; b9 I( \% G9 ~5 ~; _, I - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 Q' h9 |7 x0 F( C* p
# F% D* x5 m4 T- dma_addr_t dmaphyssrc1 = 0;
) Y$ k' t, n7 F" a. u5 F - dma_addr_t dmaphyssrc2 = 0;
. j5 E6 t9 a; \4 V! S) E* } - dma_addr_t dmaphysdest1 = 0;3 E% b! u! r% M8 z; c0 Y
- dma_addr_t dmaphysdest2 = 0;
# Q/ _+ }, |2 W- ^9 d7 Y0 F
- C# p; S# H1 B( {- char *dmabufsrc1 = NULL;% F/ o$ h' E2 B& K* y
- char *dmabufsrc2 = NULL;3 E9 d0 \; p p [4 ?
- char *dmabufdest1 = NULL;& D. \# ^* N' ~: _6 g2 J7 ?& \+ }
- char *dmabufdest2 = NULL;
+ |8 K& v5 L9 ^1 r; r
' r/ E" e/ D* a7 z- static int acnt = 512;
5 o$ j0 `" J# M% l( [" n - static int bcnt = 8;
/ p' j, E! W' x - static int ccnt = 8;
: t( K& y( X- }7 Z& H
0 p. v1 F% k8 F$ `7 S- module_param(acnt, int, S_IRUGO);
9 f O6 K: B$ x0 ^ - module_param(bcnt, int, S_IRUGO);% ]' b6 \ d6 }, d- S7 j6 O
- module_param(ccnt, int, S_IRUGO);
复制代码
% q$ o8 N8 a- y& [6 q
* }2 A3 q: O) y* k( J8 W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& W- K; U7 S! X$ Y5 N+ j; parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ C! c% s {; @* } 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* X0 ]" c% D; W, G; {4 ]# Y% U4 v. I. l
7 ?# r( U* |% T w H' K; N
# Y& J- O5 A0 r; ^$ Z |
|