|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: x/ X) R( v* V' ?$ Q' o+ c- [code]EDMA sample test application, ?4 c& u) \: [% S( b
- /*+ A) Y! E0 L3 T# o7 E4 I( j) ?& y
- * edma_test.c
# L, V! E* o! N( u3 Y5 y" t - *. B, k, F w0 G7 w- M: c
- * brief EDMA3 Test Application3 Q" k+ m6 A' e& M/ H6 }. O% U6 H% v! i
- *
1 _5 \ }) m! X( v" {/ V - * This file contains EDMA3 Test code." Y8 N) M7 r( ~6 v' c$ `7 d
- *
, T' j; J2 M& q! Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ F, O% Y6 I7 I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 v9 {; q! ^6 g" n6 j) O
- * TO CHANGE.+ e) W- ?, D& ~
- *
9 ~: B/ b( C) q+ w* r - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! r a4 m8 A; ?6 G. Q
- *
8 W! v* c& }( M - * This program is free software; you can redistribute it and/or0 p& m3 k, z) }- o: X5 l" a8 \
- * modify it under the terms of the GNU General Public License as
$ N+ Q [/ A1 ~! O# a - * published by the Free Software Foundation version 2.9 D. [, h/ n% t; c3 `" p+ Q/ Y
- *
. Q4 L0 A8 K: G9 V' O% f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) ]9 N7 \4 i% b- P9 ?& A5 n k* R& U
- * kind, whether express or implied; without even the implied warranty* p" F) R% E" O6 k$ V8 m* L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; W. _' g3 v: G* u2 j q6 ` - * GNU General Public License for more details.( P/ v* _( h5 C8 y
- */
4 h) E' ?/ T4 { g+ c0 l - x/ @/ y& Q5 C- P
- #include <linux/module.h>
. w. {8 w6 A3 G' p7 Q& m& c. D - #include <linux/init.h>6 C2 l5 k2 V. M7 h2 _/ x1 H$ B1 d& U
- #include <linux/errno.h>5 ~6 y+ ]0 B4 ]% {1 K4 x; P& ]
- #include <linux/types.h>
8 W; [; n* ~' }# r. g) T- j. f0 u - #include <linux/interrupt.h>$ g$ G- i. ?4 k ^
- #include <asm/io.h>
0 V9 l) S- O9 k - #include <linux/moduleparam.h>6 p5 D, q9 N+ r
- #include <linux/sysctl.h>7 L5 M3 N: ^5 ^4 X4 e E+ n2 `) [ ^% C
- #include <linux/mm.h>" \7 j# c4 \4 N) R! F6 \
- #include <linux/dma-mapping.h>
4 R, w, ]& H: B. H
- _+ D) P7 H! p- #include <mach/memory.h>
. x2 K* ^" `0 { D% j - #include <mach/hardware.h>5 k5 X$ H# J3 F6 x" V! u) H# C
- #include <mach/irqs.h>7 z8 k8 z8 I4 C* D# i/ z/ m$ t
- #include <asm/hardware/edma.h>
c. q1 H T3 V7 C8 h P
- p: y1 B7 x" v0 d% B, ~9 ^; ]$ s, G- #undef EDMA3_DEBUG
' v1 a1 Z* [* l - /*#define EDMA3_DEBUG*/
# ?0 y/ H3 X% h- Q - c. V. p! D6 t0 g" ^7 H
- #ifdef EDMA3_DEBUG$ ~+ J+ h: Z9 A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 h1 q; p# J. C0 e7 a' a4 @' ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): |& w A5 D- M" l
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ ^! }- {3 h/ Q2 b- D: @: H - #else
( u& u9 n& ^4 w5 X - #define DMA_PRINTK( x... )7 D$ E3 I; J5 V0 H) U
- #define DMA_FN_IN1 ^: W. f8 E& H/ D/ v9 \. `
- #define DMA_FN_OUT
5 b* M. I$ x+ L8 H6 n2 d - #endif
6 K% I- v: g9 P( \5 }
1 q8 E. @5 o3 B7 h5 t5 S- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' q; n1 h& \$ Z" w5 s0 f* ~9 x - #define STATIC_SHIFT 3
) `$ M' D) N. S( m# i6 r( \' G" X$ h - #define TCINTEN_SHIFT 20
, T7 y* x* n8 j, A - #define ITCINTEN_SHIFT 21
0 X. i0 X1 A- ~, _ N - #define TCCHEN_SHIFT 22
3 n) y8 o) B, N9 T) h$ s' J - #define ITCCHEN_SHIFT 23( G# h' Q6 d$ M
- . m e% R& K) U* j" S
- static volatile int irqraised1 = 0;
7 S& h% s f, Z. p" D/ U - static volatile int irqraised2 = 0;+ K! M. k, ~5 H
- # K) a4 K- B' o |$ |( e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' y$ i4 ?4 a `4 I1 X - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: g$ W! j0 O7 L, h2 H - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 K" y% E" }) s# E8 [
. S; Y0 i9 t1 t3 _9 k; _3 @- dma_addr_t dmaphyssrc1 = 0;5 b, R7 l. A7 [% d
- dma_addr_t dmaphyssrc2 = 0;
/ J6 Z6 o4 z; S - dma_addr_t dmaphysdest1 = 0;0 T4 l+ c1 _4 l: R2 Q
- dma_addr_t dmaphysdest2 = 0;, h" v! }7 B$ Y' U3 T! j+ U
- + h& i4 E( |- w( }" ~
- char *dmabufsrc1 = NULL;+ ]5 h# _ r8 \% l
- char *dmabufsrc2 = NULL;: L3 y9 F0 q4 D/ u
- char *dmabufdest1 = NULL;! @6 T, O+ K2 X. L. \, T
- char *dmabufdest2 = NULL;
+ K3 E! R, K& B# F% Z) z
" Z: Z2 q# k( s% B, U O& w- static int acnt = 512;
7 c! f/ Y3 y# ?8 {; A - static int bcnt = 8;" R4 v5 @0 O- X* H) o, p! w$ e
- static int ccnt = 8;
- _: `( B1 ^2 P: O( n' | - . l) d" m! E! A* e: J" @( I
- module_param(acnt, int, S_IRUGO);" s" ?3 C! D; c2 \& k& e9 Z
- module_param(bcnt, int, S_IRUGO);
1 b8 y6 y+ L2 I - module_param(ccnt, int, S_IRUGO);
复制代码
1 ~8 W+ h# m9 t: p9 O9 k( W3 R; O5 n
$ h- Q, e) K g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 A5 ^" V( }; [* W' y4 n+ Q" k. ]3 ^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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& W( @5 B* s6 d: W' \ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- h9 m! a- d3 M6 Y
) g- i( Q4 C+ I% b% U
3 t* Q! P- ?5 j8 ^5 N1 g! p
|
|