|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 c9 @" n" G/ L! M( r3 {% @0 |6 ?- [code]EDMA sample test application
5 H8 B5 o/ |* y/ n2 V5 ^& `, |* O5 w' ?7 U - /*, l' |8 x% q1 X: {7 ^7 b
- * edma_test.c% |6 M/ c+ n; _: B
- *8 x7 m3 y7 Q& j8 U7 F2 W4 N
- * brief EDMA3 Test Application k: c4 g3 t, v) B
- *& \5 {" }6 H. ], o- p
- * This file contains EDMA3 Test code.' s2 C3 t3 N; l9 c* l- ?0 A5 `! g
- */ |2 F, L2 A/ k$ P. P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 A. b. E/ D2 ]2 `& G
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' U. H( s2 N& ]* S. l! A
- * TO CHANGE.7 Z, h( b% R- D5 l/ p1 @
- *
9 v5 }; g" l: c) i o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 V; h0 _, R9 {5 Y# N9 w2 O - *# S4 p( X8 I* a+ T1 x/ H
- * This program is free software; you can redistribute it and/or" q$ a; {) A1 B$ K+ \
- * modify it under the terms of the GNU General Public License as! E0 L% f4 j% h( ]$ i" a
- * published by the Free Software Foundation version 2.# I$ Q5 j; P7 A& ` B
- *
: n% s" v" t( l B) }. j9 L0 ? - * This program is distributed "as is" WITHOUT ANY WARRANTY of any l8 i9 V: ]' h$ Q" I4 x7 Q1 Y
- * kind, whether express or implied; without even the implied warranty
% }3 h6 d# {- F0 w+ Q" _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 c! h4 [. N+ ?& O - * GNU General Public License for more details.
+ f% k B0 [, N$ o9 ^0 U - */. T* ^0 i" F6 g, a
- 1 U7 x) B. G5 X" d& ?
- #include <linux/module.h>
/ Y' {4 S3 J9 i4 D4 T2 R - #include <linux/init.h>
% C. M' l P! {/ j - #include <linux/errno.h>
6 f8 K8 F2 K# ^7 S; M, L$ y- ? - #include <linux/types.h>, x- r* l) l7 [4 @# l
- #include <linux/interrupt.h>
6 o4 O' t8 H q) q9 h3 J- T - #include <asm/io.h>
2 }* h( f' M( c! [% \/ U - #include <linux/moduleparam.h>" z4 m i! x0 ], p0 t q
- #include <linux/sysctl.h>( N L) Q3 N8 g/ C$ Z; S
- #include <linux/mm.h>
" E( m/ |) d [+ T - #include <linux/dma-mapping.h>2 L# b+ P0 r/ U) ]7 w3 R; _1 z
7 O8 H2 E7 q7 T7 V- #include <mach/memory.h>
! ]7 b" ?3 V; w) O$ \ - #include <mach/hardware.h>4 I2 q! x' z8 U
- #include <mach/irqs.h>
! x8 q: U5 E& J4 W" c# }% D - #include <asm/hardware/edma.h>
1 n. ]/ u* g# q" d$ S( Z& A2 D - 5 q1 b! E! Q# ]! S" a) k2 D
- #undef EDMA3_DEBUG
^$ m* _2 r; s/ P+ ~2 ? - /*#define EDMA3_DEBUG*/
p, ?* L% n. E6 |. Z. A) A - : u1 }7 h4 A' s& e( K# v7 s
- #ifdef EDMA3_DEBUG' U9 A1 u2 l3 T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 N k) q) l# v$ \, {+ O' j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 c8 F) A0 ~0 U* W5 t$ k5 G - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 R% ^7 q/ k0 B2 g: v5 S/ s
- #else
, f! C2 u" _, b, l* e7 c$ F. n" j - #define DMA_PRINTK( x... )
$ K, X: R) y$ h7 O. P. } - #define DMA_FN_IN
1 E* w& }6 I* g4 {7 C - #define DMA_FN_OUT% L6 k, l( Q8 S
- #endif
* E# |$ s# v4 Q. t% ` - 9 D; Q: e, l# S+ M( ^) T2 w4 g
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ {% a$ `' M0 J) G' u# U8 v
- #define STATIC_SHIFT 3
7 S5 f2 f4 P% E& r - #define TCINTEN_SHIFT 20
3 m1 n8 t* M# ]3 x: H - #define ITCINTEN_SHIFT 21
& h$ P. X& Z' l* \4 a* }4 d B) G - #define TCCHEN_SHIFT 224 |' l8 T6 s% G7 T8 V/ J |
- #define ITCCHEN_SHIFT 23
" S; @. W2 a5 ]* K8 f - T+ P( p+ y: d. G7 p. |' r" [4 j
- static volatile int irqraised1 = 0;
1 ~% T% u; O+ L! V7 N - static volatile int irqraised2 = 0;
% R! x3 @, }& R1 x5 A) v - * E& g$ G6 R7 m, s- v
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' f4 c) X# E5 x- o$ {
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: S& i) z: b% v: f
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 R( l! J0 D- x. i" G! h1 r& g) I
$ ~2 X, I+ K+ n m. y* |' f- dma_addr_t dmaphyssrc1 = 0;
3 V$ K- c" i+ t& y - dma_addr_t dmaphyssrc2 = 0;& ~+ M- q5 f! E2 ^% r6 p
- dma_addr_t dmaphysdest1 = 0;9 J4 q G' F6 i$ m1 {7 ?' O
- dma_addr_t dmaphysdest2 = 0;
. v% C5 o9 P) W- o* Z( O0 l3 u
9 w6 h4 a9 a8 E+ W+ D3 Q6 g4 \6 l- char *dmabufsrc1 = NULL;* I) r0 _+ Y+ K" O3 d9 {
- char *dmabufsrc2 = NULL;. N) U- [# j! G0 {
- char *dmabufdest1 = NULL;: H& _3 r, I- {) N% | z- k
- char *dmabufdest2 = NULL;
$ D% N* E6 w) L' d" d! i - & Y/ L2 z# {/ n1 K$ U7 c/ C
- static int acnt = 512;
$ A# n# o0 b* q1 o - static int bcnt = 8;2 m5 ?+ ?" b7 R/ n
- static int ccnt = 8;' J. |/ d9 S% _- u2 l2 R# \1 }4 k
- # L; f5 h" h* T2 B. @ [; Z* n
- module_param(acnt, int, S_IRUGO);
. t9 O; M- T2 w+ D( ]( w) j! d - module_param(bcnt, int, S_IRUGO);, b$ L C8 ?" w u
- module_param(ccnt, int, S_IRUGO);
复制代码 / l- W/ Z }, D3 z+ |
_+ J# N. w- N& Y! K. q9 T. u5 p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: V4 b8 o+ X. V/ oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 x: E4 u7 y* u5 _5 L( |4 i# v
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 ?% {/ s0 |3 d5 Z, |" p7 d
! [" V) }$ d: D# Y% U7 n
3 M* w" F; q2 i& w3 L/ L9 M |
|