|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " m3 I) M8 n+ ~0 T- G
- [code]EDMA sample test application) U) g$ X9 ?' B; I
- /*5 N* h1 d; u& t S( ?! I9 M0 k
- * edma_test.c
8 k" I1 Q8 p# V. S- k: d - *: [# s6 T; M" |7 V* \0 x( B/ x0 k) K
- * brief EDMA3 Test Application
) b, Y& X5 b+ Q' r; ?0 f - *- A8 n# P3 R& V% Q
- * This file contains EDMA3 Test code.
5 ?1 {4 G4 }2 p. m* A7 u- m) v2 q - *1 @' X) |* p- {3 m6 ~" i/ C
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 E G D( Q; w' g) T7 w
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ D' q6 B# N! m
- * TO CHANGE.
# c( v5 e8 H, } - *) D7 N; p0 r! g6 ^9 [0 ^
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# X+ u/ L! o" c; }# |3 L - *
$ I7 S5 R9 Q7 u- f2 l4 p - * This program is free software; you can redistribute it and/or
5 B0 K8 j# d! l+ s( q - * modify it under the terms of the GNU General Public License as
5 ?6 b! A. s% O9 W! c( P - * published by the Free Software Foundation version 2.3 z+ I+ O% j% @9 w
- *
* t9 J- j6 Q% J& S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 P! v6 ~3 B: e$ Z/ J+ z - * kind, whether express or implied; without even the implied warranty
) }( E+ b+ ?- R2 u9 m# Q& d* r- \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 p0 n- y$ G9 S5 K/ M; v1 @; ?
- * GNU General Public License for more details.( X/ F1 W6 m% n; D0 V) `
- */0 y4 U* b% C& ~; f1 v# P ?# b
- ; D8 h! r- c5 c% S7 E' n6 f
- #include <linux/module.h>: v% Q' _- w: n" X3 i8 R* R# F0 Z
- #include <linux/init.h>
' z+ ]' h2 p% O, I+ W# i2 N - #include <linux/errno.h>
$ \8 K: a, W J) X. { - #include <linux/types.h># Q1 t: g) q C1 v
- #include <linux/interrupt.h>0 L) K, H* q# t, k/ j
- #include <asm/io.h>
0 ~; G0 T" J( \. o1 w) ?$ u# C' e - #include <linux/moduleparam.h>" T3 g; b$ E! E9 ~
- #include <linux/sysctl.h>( |9 z/ s% k# F" D9 l7 s$ ^
- #include <linux/mm.h> x+ A1 d/ j; }
- #include <linux/dma-mapping.h>2 U1 v/ e4 I! t8 e
1 J' \; y, w! J; O' F& O" w- #include <mach/memory.h>
?. S- k2 M0 A8 W. M: z! {* I - #include <mach/hardware.h>. O+ E' h' n6 D( U9 o4 o. B
- #include <mach/irqs.h>
5 l; g y$ ]* s6 v! t6 Z - #include <asm/hardware/edma.h>2 A5 [& W% A+ \& ^
8 E2 t# u9 k8 d( s7 t- #undef EDMA3_DEBUG' e4 |2 r1 I8 W- X0 B
- /*#define EDMA3_DEBUG*/8 ?( ]1 X2 W# c+ E \9 i& ^" C
- # f ?8 i6 {& O& H! H5 u8 c
- #ifdef EDMA3_DEBUG
1 Q5 d" b0 M. H3 F1 t - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 i4 n: { i( Y8 A1 }: t - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 r- l$ Z) H. N. _ P/ m) c: T - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! A" S2 q$ y F- C) h - #else9 R- A" y3 v* E/ T$ |7 q
- #define DMA_PRINTK( x... )' T' y* T% }7 w, n ]/ _1 B/ c
- #define DMA_FN_IN) x% p) B5 i! e2 ]6 ?3 R
- #define DMA_FN_OUT
% _9 X* ~! b0 t% y1 ^, o& i - #endif
- C7 b! @$ h9 o3 C' e; y, F
6 ~+ J* x% O- q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 A$ z# u# D4 V$ {. C' B/ Y- u/ M3 F - #define STATIC_SHIFT 3- V8 | r# Z$ R0 ~6 t# k
- #define TCINTEN_SHIFT 20
$ f( n- c- i) M- a - #define ITCINTEN_SHIFT 21% X+ h8 x% }9 @
- #define TCCHEN_SHIFT 22& [& z/ Y# W3 e
- #define ITCCHEN_SHIFT 23
6 s! H8 ^. h% S6 {$ k& x, ]& \" P - 4 }% l) Q4 f# g
- static volatile int irqraised1 = 0;
) i% w, j8 M8 c! p, j - static volatile int irqraised2 = 0;- \( K' A* h* a5 F
- . X7 U8 g# c) e5 C, l$ {$ e* c8 d/ [
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# |& u/ M& D9 O( i1 I8 o* a - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 W- g U' ~+ u
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 A; q3 {) H2 O% X& b
( @/ P/ N9 d3 K7 ^/ M- dma_addr_t dmaphyssrc1 = 0;, @* F2 |; P# b8 m" p
- dma_addr_t dmaphyssrc2 = 0;3 w3 \7 w. T" V0 \
- dma_addr_t dmaphysdest1 = 0;
3 U: r. T* S& s: D2 \5 b - dma_addr_t dmaphysdest2 = 0;
- v" d7 P2 r% h0 g3 v/ h4 n- v
" _1 z& k" F/ P0 f- char *dmabufsrc1 = NULL;0 C* a% x' @! X' u+ ]% c1 n
- char *dmabufsrc2 = NULL;
2 X1 O5 a' X) X# J) [& t l - char *dmabufdest1 = NULL;& l4 c$ A% C( E5 _% u& |
- char *dmabufdest2 = NULL;% F3 p2 }$ T7 J2 X C
- . Q4 V8 T& q$ V/ A5 ~
- static int acnt = 512;
: ^3 D/ V! f- L9 q1 G( G - static int bcnt = 8; w# v5 W* e2 e, t: X
- static int ccnt = 8;
( }9 ^" Q. @9 x5 _' ~: K
+ k" i& X' Q# Z- module_param(acnt, int, S_IRUGO);
; ?$ m/ g l& g9 _& H1 \ - module_param(bcnt, int, S_IRUGO);; {4 H( i5 `( ~" R8 j9 n5 Q, W
- module_param(ccnt, int, S_IRUGO);
复制代码
5 u9 X. V: t) O j0 a
; _1 D. {. N! f1 i7 A7 ~+ } 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ s* t" o- k/ |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ Z/ o$ K9 Q6 Q: L, {$ _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" J% e7 A$ S2 d1 D! d& u/ n1 N3 U+ V% k
* a" d2 z' l7 t4 W- H7 J |
|