|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 l" N# k. |0 }: j
- [code]EDMA sample test application
2 X2 c' I3 F# f; Z6 j - /*
/ u0 G/ R q# m1 |# Q' Z - * edma_test.c
+ c. ]8 w2 u! j' ]% R - *. J1 z/ v; O( c8 |9 X$ x
- * brief EDMA3 Test Application3 O. E' l: k7 J: J/ \" w5 X9 a
- *, c4 K: C& S L" C3 U: O7 B
- * This file contains EDMA3 Test code., n! _( U( N5 U* h- y
- *& b% N: B# M u0 Q4 C v; Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 r+ }6 z5 ~) m% S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ C% F& O- w& v# P1 Z o" i5 J
- * TO CHANGE.' H6 Q/ _5 h$ Z5 P1 @( }; d
- *2 F- w1 E |6 N- w9 i, Y8 l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! E$ t2 j3 ]5 F3 p5 z - *
. X* l, l5 N; m5 h - * This program is free software; you can redistribute it and/or0 v: \# w/ }3 T0 F/ e3 Q
- * modify it under the terms of the GNU General Public License as/ I& j8 C# \3 D1 a. l
- * published by the Free Software Foundation version 2., U& r) K/ w+ P7 R/ k' y/ e+ y9 L
- *
8 Z& U" c6 G: E- A - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. ~ ^: w1 ^/ J8 k1 `3 L( `( r4 ]
- * kind, whether express or implied; without even the implied warranty( d5 \: u8 @" f/ c2 D8 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ a6 Z5 L1 A' w8 t" K" ~7 c; k - * GNU General Public License for more details.# Q. R ]4 r; Q! }6 Z
- */. @% {8 N. h$ S+ H( M- x
" R0 @' ]! s2 |5 M& ~4 B- #include <linux/module.h>
8 L- `2 n m% @1 F3 R, L4 E - #include <linux/init.h>! t2 B# v5 p' \2 m; }
- #include <linux/errno.h>
" _% L8 l- O5 W# n9 { - #include <linux/types.h>
2 \% `6 j7 i8 k - #include <linux/interrupt.h>( L0 l6 I- q: M V6 p, b
- #include <asm/io.h>$ y; `+ i: a; v4 v- \8 R* i
- #include <linux/moduleparam.h>
+ S* H c! ]0 Q# R8 ?; W$ O) K - #include <linux/sysctl.h>1 D) q( f! k% |
- #include <linux/mm.h>
+ A" b6 N' K d' @* D - #include <linux/dma-mapping.h>/ p2 `% c8 d5 c A2 q+ g7 ], S3 U
1 S* x1 U" |4 y+ x8 d. m- #include <mach/memory.h>2 Y3 N3 c+ F: Q3 ^! r
- #include <mach/hardware.h>2 i9 H" d- x: S5 A7 j
- #include <mach/irqs.h>
$ s' ]' s; K y; d) @: j - #include <asm/hardware/edma.h>
- E9 I& E) m& w- z - E# X+ H( ~; t, r
- #undef EDMA3_DEBUG
$ i3 u1 V' T7 O5 P9 M - /*#define EDMA3_DEBUG*/
5 U9 N' Q& k7 w, U1 M4 Z
6 d% o) ^. W: G& Z7 r- #ifdef EDMA3_DEBUG7 x( D' o b# i5 V5 {
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- Q6 g9 I, A/ s4 v0 `& \9 o8 s
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, s: J2 H! u- F3 f" ]. }# K! | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 d! [7 j( s6 m" [. L& e8 Y
- #else) j* A. W* {( E$ V. Z4 f8 x. l
- #define DMA_PRINTK( x... )
: h: Y$ D) m. x& \$ o! s - #define DMA_FN_IN& j* ]; E7 F* k9 R5 Y
- #define DMA_FN_OUT
. A |) ~9 c) r - #endif0 v& c/ w) {. ?6 ?/ P
- " i$ @/ k$ r2 l! @7 @( C+ S* J
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( r! M! K8 [7 ]! \" S9 ? - #define STATIC_SHIFT 3! _0 E$ U3 i9 Y4 {5 h, P- j* S
- #define TCINTEN_SHIFT 20
9 @/ J/ P0 ?+ O1 r0 s/ I: u" q1 _; f - #define ITCINTEN_SHIFT 21% L8 U( M; C# ?" r* q
- #define TCCHEN_SHIFT 22
' `/ @6 O( {- F, ?. A - #define ITCCHEN_SHIFT 23
4 t, k3 f# V8 q' K. ]6 D - 9 ~4 k2 w0 D6 [" P ], ]" F
- static volatile int irqraised1 = 0;
7 d5 p/ |2 w+ \' k# k0 l - static volatile int irqraised2 = 0;
7 y# @; i) b* ?6 T* r - 5 h3 x% D1 \, E6 |0 x3 k2 \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 n1 G0 Z: p5 a. [* U6 M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 h" ~8 A$ \% P5 R - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 T) h: l' Q1 T. ]* ]2 Y
- # o% y+ d. K$ M# ]: D% _6 K
- dma_addr_t dmaphyssrc1 = 0;6 z/ b5 u8 c r; w" r v
- dma_addr_t dmaphyssrc2 = 0;
+ V4 f, ~* @: d3 g @- t& l0 a, v3 K- P - dma_addr_t dmaphysdest1 = 0;
; i# J# L" \8 \+ w - dma_addr_t dmaphysdest2 = 0;
7 i" O* f! \" t, C1 F0 K& K
! r& Y1 A# Z7 V- char *dmabufsrc1 = NULL;
3 c; n0 u5 b9 J6 I+ V$ E - char *dmabufsrc2 = NULL;. h4 V' H3 C2 c+ [3 r# s
- char *dmabufdest1 = NULL;2 Q$ q" [! `6 k& S
- char *dmabufdest2 = NULL;- Y+ Q5 T- [* _+ u1 v7 ?
- ) ?# n9 R: @' S! C8 `. q2 O
- static int acnt = 512;' |4 r B" {9 W
- static int bcnt = 8;# }( N, \& R) s8 E6 T6 Q3 l
- static int ccnt = 8;3 P) q. `' w0 ?/ r* l
" E1 N+ K7 i% f- P) a- module_param(acnt, int, S_IRUGO);
( Q$ s7 O" `: U" ~" A/ a* q - module_param(bcnt, int, S_IRUGO);/ M# V* Q7 y8 c
- module_param(ccnt, int, S_IRUGO);
复制代码 7 \: A0 q9 y+ d5 E7 ?$ G! `! z
7 `0 I# Q8 C q! g8 _! y) R7 v
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& _9 R1 H, |, e8 {% ?( Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" j+ H; p; ~) s* v1 f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' Q3 j* d& a* ]
" u% i d' B( i2 h/ Q
' d, D( d* Y# i; g6 |$ J9 K* t! e' h |
|