|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 x# r0 N, O1 T: L6 b- [code]EDMA sample test application
1 o$ X k% X3 K4 R - /*
% W: u+ c: K$ u7 K2 ~ - * edma_test.c
6 _; g( ~1 c. p" y0 l - *
( S# @, y4 w+ K; K( i; N - * brief EDMA3 Test Application
7 [& }/ h& O5 D) R9 ~7 g - *
0 t# Z; a# z! D( P9 | - * This file contains EDMA3 Test code.9 _0 l' A0 L) K8 Q. P P- q
- *7 T9 h( u1 i! D
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 o$ v% q+ h9 Q5 ]- c+ z8 ? - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& M$ |, ^9 N+ z - * TO CHANGE.- `! D7 v) b# v4 q9 a
- *4 N c, I3 @7 D6 ?+ _" P& ?* b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ _% V9 p$ |# q l: ^ - *1 s' g ?1 B$ _! g2 k
- * This program is free software; you can redistribute it and/or
8 k1 I0 l4 t2 v/ o) _/ _2 Q" T - * modify it under the terms of the GNU General Public License as
$ M' h3 U- X' N5 e - * published by the Free Software Foundation version 2.- w5 O7 A F+ _
- *
+ { R# a8 J0 s7 y2 O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( a- A( j6 k# J' Y1 H0 K8 L
- * kind, whether express or implied; without even the implied warranty
, V4 @6 J# ?+ u: }* j% |( F( o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 F! E' O! c: q! i1 Y - * GNU General Public License for more details.
) l7 P- Q$ [. \2 Z' r9 V$ ^) _- { - */
4 B$ p9 V6 B7 I4 S
8 t5 ?4 w6 I* q, v" k- b- #include <linux/module.h>
, D2 C2 R1 E6 T - #include <linux/init.h>
0 S( S; f. M3 |7 k, ~. f6 d3 ] - #include <linux/errno.h>( Y, ], Z* t$ v! F9 J$ Z1 c5 m
- #include <linux/types.h>
- X3 u# _9 \( y% N( c Y" S - #include <linux/interrupt.h>4 t: Y4 O K3 C* k Q
- #include <asm/io.h>' J' C& K0 j) J0 d* j4 |
- #include <linux/moduleparam.h>
# q- q' d6 E* N - #include <linux/sysctl.h>
* O! r1 ^9 X9 [% f - #include <linux/mm.h>
3 \5 y& S1 `& O9 p - #include <linux/dma-mapping.h>2 J3 b) h$ U( o+ P
- V9 s6 Q3 s: A, C/ M- {" q- #include <mach/memory.h>2 ~* |7 g- `7 ^: P$ S: U9 `% E
- #include <mach/hardware.h>3 v4 F- d- @! @2 D/ s0 X
- #include <mach/irqs.h>
5 T( x/ r( y/ A' i6 E& R0 M9 V - #include <asm/hardware/edma.h>
' q$ m9 Q3 W6 b6 v# B/ C - # p; `$ M/ G' D. z$ P. c
- #undef EDMA3_DEBUG
5 V/ d5 ?0 B5 j4 o6 U% ? - /*#define EDMA3_DEBUG*/
7 ?$ i/ P& q; S% v- I
( E' F7 ?; q9 s3 Z) p6 f$ o- #ifdef EDMA3_DEBUG3 w/ z U; |2 j. u; j, b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, b$ a% }" }; ~0 S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). d' W9 G# \, W, F8 Q6 p3 R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 N1 v& {5 B- i2 G - #else: I3 J( M) O& T: L/ t- `
- #define DMA_PRINTK( x... )% U# c( c, a- |! ^( W* j2 F
- #define DMA_FN_IN
: D# i! U" p( V& x& q2 F: v0 L - #define DMA_FN_OUT: t: E+ E& H( c! ]# ~( ~$ o+ s8 d
- #endif
+ n0 _, D% I! v+ N - : H! Y- ]1 s7 }7 k6 U& E+ {9 i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' \+ {) y4 a. h, ~- G9 [ - #define STATIC_SHIFT 3& j' w' u& a8 @ C8 D
- #define TCINTEN_SHIFT 20
( v }# ]6 W3 u! `' M - #define ITCINTEN_SHIFT 21, F/ V' n; d! h+ e2 q: q) R
- #define TCCHEN_SHIFT 22
7 `! x$ T1 A0 u W - #define ITCCHEN_SHIFT 238 b1 v, @! q" x# \' P/ y; \
' T0 G! D& Z+ y1 H0 e/ F3 C- static volatile int irqraised1 = 0;
% B. k7 Q& T9 u( B+ k - static volatile int irqraised2 = 0;8 O0 c9 f- q+ ]) h' e s
- [/ D4 h$ C! B4 Q! a# X( u
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# ]- l7 F+ m# c, q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ r7 s3 q( @& H. Y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. q% ?. s: P4 t1 B: s
! S8 I& J. j, Y- dma_addr_t dmaphyssrc1 = 0;
% `! f/ K6 r+ f( J | - dma_addr_t dmaphyssrc2 = 0;$ O( T; Y k$ g1 E" Q
- dma_addr_t dmaphysdest1 = 0;
2 u5 C- A% b4 F( j1 F+ x - dma_addr_t dmaphysdest2 = 0;
8 q5 b8 J' p* ] - & B y+ z" {1 y3 o) X# S% }4 ]
- char *dmabufsrc1 = NULL;$ J2 s8 z6 [4 b) y" S7 @
- char *dmabufsrc2 = NULL;
+ Y" }3 U, H2 \ [1 m: j - char *dmabufdest1 = NULL;
~- s; _3 y- L" m) `. H1 n; p - char *dmabufdest2 = NULL;
1 f1 h3 y' _0 ^2 U" y+ J6 R - 6 u1 E4 V/ [% w, h. D1 v
- static int acnt = 512;: X+ C( C; Y% T- a
- static int bcnt = 8;
' o+ I' A6 x2 ~. e K% ?" y - static int ccnt = 8;
& w+ S7 E1 k; M5 ~: u
; U/ L( c8 z6 ^' `, I- module_param(acnt, int, S_IRUGO);
! P& N5 q2 D5 ^' e, v; I - module_param(bcnt, int, S_IRUGO);
* r. j2 p# W5 f- q/ A( ?' e - module_param(ccnt, int, S_IRUGO);
复制代码
% Z* Z* @$ h/ A7 b% u, h2 S5 O$ H/ p4 m' h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ ~4 s6 S3 J) c" o! Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& k3 O5 u7 A4 S% o( T0 _- S! k
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' u. w! c5 O& U* K: n2 Z' G
E; V: R& I- Z; p: D5 {" O
1 r5 |2 `& D k' Y |
|