|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : b# Q- K8 Y3 Y
- [code]EDMA sample test application
6 G/ _9 O# U) b8 I; x - /*
1 N8 s; `6 z1 p" q' k, [! O! X - * edma_test.c
( W! g+ x/ `) s/ L' O6 p4 ~( L - *
+ Y& l& Q3 x4 e* @" s8 @# N - * brief EDMA3 Test Application
" d) x% i/ u7 M# y3 U5 _- X - *
# X _" X& j3 o4 }. i8 g - * This file contains EDMA3 Test code.
) M1 s3 t4 e) f$ O+ e! _4 D - *
. o2 x& u2 b4 f8 Y; b+ x; ]* a ?$ x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! O6 b2 T% U, T2 @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ Z- W- G7 S7 U- i; P* A
- * TO CHANGE.8 T6 w' m) X9 |" G9 @
- *
" d' z- h% \1 r0 }5 _: B( p/ o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( j: C, Q- U* z% G" p& k5 }4 a; |
- *
1 G, F, l# U4 v. c. v+ C4 ]8 ] - * This program is free software; you can redistribute it and/or: \# z2 p- p# ~: X% s8 R
- * modify it under the terms of the GNU General Public License as
/ {- A& @; I) K+ d) f - * published by the Free Software Foundation version 2.. f6 _3 f- z. B. S2 K* D( y Z" J
- *
; J" q: d, N d" H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: V% b( q6 l0 y0 K) i! k( _ - * kind, whether express or implied; without even the implied warranty% Y$ s0 P( b8 P A# q' R8 {
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 e; E3 X3 M+ u7 P; V7 X0 {+ |
- * GNU General Public License for more details.& B/ P9 M- I5 h+ i
- */
+ R. E2 ~1 Z9 H. A
8 G7 l1 G2 W% Y2 h& F- #include <linux/module.h># O& ?9 f9 S+ o; F
- #include <linux/init.h>- C9 O4 e) j9 G% e
- #include <linux/errno.h>. o2 E3 U/ @% G- @+ h0 B
- #include <linux/types.h>. O; [3 F- \/ P+ k! W
- #include <linux/interrupt.h>
6 s. u* s$ ?$ O; K- y+ K$ u ] - #include <asm/io.h>
- `0 z) [# ]6 O; D - #include <linux/moduleparam.h>' R, n+ U; D' E9 B. [) d
- #include <linux/sysctl.h>3 s8 f/ S2 P& u% b( S/ E
- #include <linux/mm.h>! U6 W5 v! x9 C9 [4 P* O' L: m+ D) b
- #include <linux/dma-mapping.h>1 \6 p: y# a- D- ~" h: I- S
# c6 }. q6 ~8 z- N* t. H1 Q1 |- #include <mach/memory.h>
' C. `! X8 S @4 |; [- [) s - #include <mach/hardware.h>
; Y' w1 l- x/ v7 X - #include <mach/irqs.h>2 M+ Y W& Z) X/ C5 r% }; p
- #include <asm/hardware/edma.h>8 c% R- Y4 C2 s% u2 }( Z
- # J( i+ W: ~! u$ E# r5 A# Y
- #undef EDMA3_DEBUG. O4 q( l6 ?# c5 q6 G7 }
- /*#define EDMA3_DEBUG*/& W& Y4 w5 u+ L# t. M
" p% C* t5 m9 n* z! i2 ]7 c1 [8 \- #ifdef EDMA3_DEBUG9 A D; |2 [4 c/ m5 W. }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): D* Z; y9 k& x& n% S7 A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# L6 D9 `$ r% Y+ _/ e8 a6 d; S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" ]# F T" E; h7 U - #else7 O' r+ L; s E- K
- #define DMA_PRINTK( x... )
% E+ ?$ A3 Z1 s; q" I% k - #define DMA_FN_IN
. s5 C' T/ c' k9 D( I - #define DMA_FN_OUT
# I: e/ V. C2 C+ ]* Q+ t4 b - #endif
1 I5 t4 c) R/ C5 Q8 R! Z/ T3 W* j - 9 m9 d' N6 r( u4 s
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ P6 T% o1 l& j& U o [
- #define STATIC_SHIFT 37 ^/ r$ A+ ?% U p5 B( }7 j
- #define TCINTEN_SHIFT 20& h$ \- S) L5 A. @9 G* r
- #define ITCINTEN_SHIFT 21
0 ]; ~9 `# E, b8 L - #define TCCHEN_SHIFT 223 u: c$ |+ B; T, ^& N
- #define ITCCHEN_SHIFT 23
3 b( V, b- E( Q+ c+ e i* m7 W
* m- j+ V" @+ [: r: o. A- static volatile int irqraised1 = 0;$ n+ k0 r; X* b( K& ^; X3 V
- static volatile int irqraised2 = 0;9 W9 k4 X, {. z: @: j3 P
* `' x* D! e* ~: b/ J$ H/ v- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 N7 f7 Z3 v$ a) Y( x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 s4 S/ X, n' {) ~0 F8 ?8 o
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 k: m% x5 H- P$ V' P* s# p - 9 k. W* K, o2 N8 B' U
- dma_addr_t dmaphyssrc1 = 0;
, Q4 r* x7 Y9 H% L: Z- K - dma_addr_t dmaphyssrc2 = 0;1 S" F* b6 t# s% ~
- dma_addr_t dmaphysdest1 = 0;
' J1 e( q1 H @; l+ {. c2 C1 ]) { - dma_addr_t dmaphysdest2 = 0;* B9 {- ]1 Y5 {0 m0 w$ W
- 9 f) O" }( o. L) G
- char *dmabufsrc1 = NULL;
; ] w$ z1 e' ]' T: M - char *dmabufsrc2 = NULL;9 q1 l) s" J9 Z8 k8 J0 B
- char *dmabufdest1 = NULL;' _9 r3 y& U" P1 K% Z' O! N. J' L
- char *dmabufdest2 = NULL;
+ E7 d, Y8 n/ D- |% z - ' i% E" a/ o2 G; W9 d
- static int acnt = 512;% P. }5 w. L5 |0 H' R9 M. a
- static int bcnt = 8;
6 u, O) [. S: h/ t; @ - static int ccnt = 8;% b2 d: c$ h6 [& e
- ! e! Z4 l$ U5 l+ w% R0 G
- module_param(acnt, int, S_IRUGO);# r1 _% l! k Y& F& L, o. A
- module_param(bcnt, int, S_IRUGO);
/ C+ }9 B: @, e% J: f# ^, S2 d3 { - module_param(ccnt, int, S_IRUGO);
复制代码 3 |# C) P1 Q0 O3 W" L
' z4 ~( ]+ y& {' m& w8 U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ R- `" c; V. x# h1 I& B1 q6 i( Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, I+ T' h3 q ]2 ^ n; D, z% }& ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 Z+ F/ l0 E: L0 \
+ Z1 |& _) b* B# c, W7 p) J( B
) n4 k6 y+ m( r; Y6 d0 l; F! b
|
|