|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. e, d! k+ \/ ]( Z- [code]EDMA sample test application0 n- {0 P P' `0 }! C( z/ S; r
- /*& h+ U8 e& M$ O: G9 w% W& d
- * edma_test.c" j/ Z. X7 \7 u& c
- *
7 Q2 W ~* m( l" y) [& g - * brief EDMA3 Test Application
" x! @% o9 F7 E0 k4 w M* h - *
2 i# f! ^# y3 ?0 U9 X" C - * This file contains EDMA3 Test code.
0 g5 y( l! a6 \ - *
/ t2 P1 g0 A. T: t1 r8 p- g - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 u3 h9 l& h5 E4 n% x
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" V! D% f/ p( z
- * TO CHANGE.
/ w: F1 Q3 n6 {2 |1 G( Z) u - *0 N8 Z5 M5 {: G# A9 V( w2 U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( _3 i! t, R5 u- Q - *' j6 ^+ a' k8 q8 C( Q8 @
- * This program is free software; you can redistribute it and/or. ^5 J. E/ s/ Y. e* R0 H \
- * modify it under the terms of the GNU General Public License as
4 P3 n3 T; ^5 N' {3 h+ v* c - * published by the Free Software Foundation version 2.
/ n$ l, h. k0 C/ W( j - *
* Y2 ]1 W! o7 ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 h! O, E( y' {0 ?0 J6 T6 X3 [
- * kind, whether express or implied; without even the implied warranty
7 L% D9 {: X4 [* \; ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- D( i. O' n* @& j# G* j: R+ e2 v - * GNU General Public License for more details.7 b5 u0 Y7 I4 C8 S: M2 v, G$ z
- */
: `2 W$ m& `$ i! E - ( w( n- a& z R" n
- #include <linux/module.h>
3 z& j Z0 v9 | - #include <linux/init.h>( P F! t5 Y" B; ?" \1 @; s% n
- #include <linux/errno.h>" Q- `& H" g0 j/ O( E- D- G6 V0 R2 r
- #include <linux/types.h>/ K0 } L6 q. Y) X5 Y" u2 S
- #include <linux/interrupt.h>
- w0 Z% E+ ~# K& O - #include <asm/io.h>, M. z. `! C6 g1 z1 e
- #include <linux/moduleparam.h>
4 e, Q! i$ Q$ |0 p% ` n* Y - #include <linux/sysctl.h>3 h2 c. ]" p. V! ]' c2 J5 i
- #include <linux/mm.h>- ^6 o, d! ^5 f
- #include <linux/dma-mapping.h>6 l) S8 a( [9 z4 }
1 F7 J! O2 m& C5 @! ]2 V- #include <mach/memory.h>
, O% R& \! U) I9 m8 ^/ G, D - #include <mach/hardware.h>7 g @* T; O1 u1 n. E6 ]7 H+ F
- #include <mach/irqs.h>$ z7 Q# h) T8 Z! A0 D
- #include <asm/hardware/edma.h>
6 T1 k3 j! ?7 W7 B7 Z - ' L7 f6 ?5 D* k- E/ J& P$ Y X2 ]
- #undef EDMA3_DEBUG
6 e2 {; n$ R+ W+ i0 P# q - /*#define EDMA3_DEBUG*/
2 ^% S y% C3 f8 U, y9 x7 \
" T! L; V" J! n0 I+ _- #ifdef EDMA3_DEBUG1 U3 _. {; u" B* L' f
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 p: ]* |- ?9 r" ?/ E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); u! e" W, h* l% c! m! l: ~
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 y7 k1 W X6 B - #else
! m# _$ y/ F2 @; [ - #define DMA_PRINTK( x... )
3 {! Q/ O# p3 n" a1 u$ P( e4 E - #define DMA_FN_IN
1 G" z, T5 W5 a! |* h - #define DMA_FN_OUT$ m. }' Y" {! U& {1 ?0 C6 A
- #endif+ N3 ]+ H$ P6 X. O/ m) Y
8 |% G. C- B0 L- L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ I2 E E6 e, L+ C; |+ I
- #define STATIC_SHIFT 3
6 R9 ^$ k: d$ G3 H% K - #define TCINTEN_SHIFT 20: }3 |, c# u7 _7 k% y, B
- #define ITCINTEN_SHIFT 213 e5 q$ @) Z7 W. ]& C6 O9 G
- #define TCCHEN_SHIFT 22+ d z/ n; t' d3 f" H0 N3 q2 o
- #define ITCCHEN_SHIFT 23
+ T/ C Q6 z0 U% G c* r - + o, [% X8 E# y, A' n4 R+ x1 J
- static volatile int irqraised1 = 0;
$ K1 h& ]3 k8 t% J& S - static volatile int irqraised2 = 0;" p" n& _; C, `6 V# ]8 |, l
- / n4 V- ?1 _9 s' E0 u/ c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 {; B/ ^" i6 D# s$ G) w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 M$ X! E8 k9 b, f+ j
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, H0 E( H) G/ A$ l/ j$ ~8 S
$ `2 w! a6 V! E- n/ Y- dma_addr_t dmaphyssrc1 = 0;, x$ u- B2 k6 a7 x# V* s5 k# c n ?
- dma_addr_t dmaphyssrc2 = 0;- D$ m# r; W* b/ a; M3 I
- dma_addr_t dmaphysdest1 = 0;
1 v" @: M7 |1 [: k0 { - dma_addr_t dmaphysdest2 = 0; M {" O! [2 R. N7 O! q, e; u
- & j9 R+ K( o! @8 F. e, O O* a/ C
- char *dmabufsrc1 = NULL;
, K2 g- ~0 R+ T# R5 w/ ^1 m - char *dmabufsrc2 = NULL;
1 O( K1 H- T' L - char *dmabufdest1 = NULL;5 A, }7 d4 W* ~) A+ ~" U
- char *dmabufdest2 = NULL;
8 B( Q1 k# |5 _; @ - 3 l& D' \2 n6 B# @. j3 W
- static int acnt = 512;
- p: j+ t1 \6 m5 Q! H3 E - static int bcnt = 8;! e+ H% n: h- x) z7 M
- static int ccnt = 8;
/ j; k( |8 R' b- E/ w/ _7 T - 1 c# g8 V4 M% [3 x1 B
- module_param(acnt, int, S_IRUGO);, V* {0 _. }' Z
- module_param(bcnt, int, S_IRUGO);
w1 T% S6 ^; o c2 x# t$ x - module_param(ccnt, int, S_IRUGO);
复制代码
8 r* U) `( Z% |8 Q2 Y: y. [) E
( c' C+ R1 p! Y, V- n A 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 f0 ]) W4 E* U) V8 c* Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# V# D* m: `, @, ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 b6 |( x. x- ?- M+ o- e( K* U& ]2 I0 s0 u4 O' |* ?1 |& l
; Q+ i' }) o0 F8 n$ A, M |
|