|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 R7 K) X, J1 Z) T1 X5 e6 N, T- [code]EDMA sample test application
$ B6 Y: I( z( f - /*
3 y$ E M4 N- f8 E1 Z - * edma_test.c
0 ^9 P' r. y$ Z. s - *! s j5 J t- g# ?
- * brief EDMA3 Test Application
( R" F- H; B7 [ - *' W, v; N, t3 k; n8 p1 V) _
- * This file contains EDMA3 Test code.
, h; T! g$ K0 e' Z - *9 R, {4 h6 C) @1 f" @" Q6 j
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 ^; \, M! _: d6 {! S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; z& y) {) ~1 N# x
- * TO CHANGE.) {2 X) l: [2 e B) z* U* I
- *
% m \+ Y: V3 Q+ ], U: B; e - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 V) e$ F$ T* A9 W - *" a7 t5 R0 m1 c* Q: i
- * This program is free software; you can redistribute it and/or% M, H8 O4 u! _6 U& E
- * modify it under the terms of the GNU General Public License as
: B9 `! }/ C4 E: A - * published by the Free Software Foundation version 2.
5 \$ n8 A7 ]% B) B0 r; {/ C4 G - *
7 r' F2 y: C* x" M - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. e; U& }3 B$ n7 G - * kind, whether express or implied; without even the implied warranty
* }& W: R! V9 U9 l7 l" l9 m! i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
P4 |3 e2 [- ]) X5 h1 H - * GNU General Public License for more details.; X4 p5 S" F7 m+ q! U
- */
- V+ L/ z( E- _4 [5 \
1 }* L4 \" ~9 V) q( Q4 g- #include <linux/module.h>
5 g0 q7 x. i. a7 \8 G' A5 }4 Y - #include <linux/init.h>& K1 R$ g3 U6 k) h, b
- #include <linux/errno.h>
3 V6 x* t3 d* j$ W7 \4 e. R/ A - #include <linux/types.h>
9 R; H- r; v5 S) B, _: [& Y, y3 j - #include <linux/interrupt.h>
3 o$ N4 {' H& e9 U( y - #include <asm/io.h>/ O1 e5 t5 F7 A" B$ S; X
- #include <linux/moduleparam.h>
4 N- f4 B4 X9 [9 l; S3 {' ] - #include <linux/sysctl.h>
& H+ \3 [) V% S5 G+ @ - #include <linux/mm.h>- `: Y( Z0 U0 [4 q9 T
- #include <linux/dma-mapping.h>
% } _& W- n! t+ d* E A8 b - 0 a k6 c1 Z9 b' E' p. Y. w6 g) P
- #include <mach/memory.h>
7 j' W" e8 W. |* @ - #include <mach/hardware.h>2 d$ g" z( G3 Z2 b
- #include <mach/irqs.h>
! _% k2 ]' ]: e - #include <asm/hardware/edma.h>4 W5 V7 s: o9 V4 r+ Z, v: K
- ! y6 [ p: h! Z0 t4 m6 |) R3 N3 _
- #undef EDMA3_DEBUG
) M- p/ p1 }6 I$ v8 A8 C: Y8 f - /*#define EDMA3_DEBUG*/
3 i& w2 e" R+ Y; J3 \( T2 B$ z - 6 F4 [& [( a; U1 `3 O
- #ifdef EDMA3_DEBUG
. o4 Z9 ^8 ~& `' W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- c T. z% s U$ x+ p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ O5 _8 Q8 n" G: b0 k
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# }; Q/ N, S: s# f3 l0 k3 z. m. } - #else
3 A+ z: c% R' ? - #define DMA_PRINTK( x... )+ t ?1 ~8 A5 h' M+ c" ^: Z
- #define DMA_FN_IN) h+ f! Q1 }) ~1 [! ^
- #define DMA_FN_OUT j' f% p' {3 I7 f% U7 `
- #endif6 n: ?9 U" f" T5 Y2 w
8 a* ~1 q& g. b/ {& ~4 l3 n0 L- #define MAX_DMA_TRANSFER_IN_BYTES (32768). Y2 ^7 x4 J- F* L" i9 Q$ ^
- #define STATIC_SHIFT 3' f0 c6 Q2 N. h! k3 B# Y
- #define TCINTEN_SHIFT 20; V' F( C7 I3 c9 F
- #define ITCINTEN_SHIFT 21
6 U% S4 V: N) w# c, l4 ` - #define TCCHEN_SHIFT 22
7 a+ ^, B! j5 B" i - #define ITCCHEN_SHIFT 23
9 c% K: l4 ^% L* i6 P - 8 j$ X# |" b( F( Q+ D
- static volatile int irqraised1 = 0;
# d3 S7 E6 R1 G& R - static volatile int irqraised2 = 0;
- F( G( j6 T& Y. K" ~) e' H - ' W7 m& i/ S( e1 @: W9 M- r% Q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. @! f0 s8 T. m1 d& G5 ?) K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" B& E/ _$ T. l d; d" @8 [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% |! V# E* e" t' { - G# C% B2 L4 ~/ ^& w4 P
- dma_addr_t dmaphyssrc1 = 0;* ?" s2 D) |: O U( J
- dma_addr_t dmaphyssrc2 = 0;
% F( `& }" ]' P - dma_addr_t dmaphysdest1 = 0;) x4 Y4 x* J% p0 `
- dma_addr_t dmaphysdest2 = 0;3 f, D0 w; K% R' ~. A( u
- * j+ A6 B" E5 g T' h0 ^
- char *dmabufsrc1 = NULL;; g7 e) b- f; |: b3 S" n
- char *dmabufsrc2 = NULL;. v$ U: q# Y ?
- char *dmabufdest1 = NULL;* g8 O, r% ]6 s7 B$ e, Z4 B; n2 d
- char *dmabufdest2 = NULL;* N1 {/ x& Y2 @' L% I5 e/ j
- K9 L: N( E+ j; n
- static int acnt = 512;
' `5 b& h+ l5 ~9 y5 O+ ~ - static int bcnt = 8;
9 s. ~1 o+ I6 N4 N; @ - static int ccnt = 8;/ F' n# j" ~4 F7 x
- 0 H. S. {1 t3 w1 u$ v- i! N& i
- module_param(acnt, int, S_IRUGO);
9 S( X. y" `" ^, p% }* f( T - module_param(bcnt, int, S_IRUGO);
1 c. | c7 l2 F( z* ^1 o: O% e - module_param(ccnt, int, S_IRUGO);
复制代码
+ j0 W* r+ O" r; G4 V" D$ T( t0 _8 s* q1 u7 ~7 ]) W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 s$ f1 I& D0 v+ ?8 c! y3 F p1 earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! c' y: K3 ?$ f1 {; `9 ]- o9 Z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 E4 Z1 C Z* _( P- s- a
. f+ j# R# \/ O( A5 i
5 i; [5 R/ ^4 I9 x) k |
|