|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + I3 M x8 D! t- Q$ q' Z7 W) b. o
- [code]EDMA sample test application
/ a1 P6 G( u& @2 W h5 o - /*
+ k" Z9 @$ z1 C$ p: x - * edma_test.c
+ H; b. i" l. t - *
) f' i3 ]! B" m, y+ |" i4 b - * brief EDMA3 Test Application
3 Y( E& g$ I, v, B+ s+ v1 t' ]& v - *
. t2 Y) {6 Q9 Z4 r) F - * This file contains EDMA3 Test code.; t$ b9 ^; |( x# u* ]
- *6 k; |1 M* ~. Y& L/ `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, E" s" o7 `3 ^& _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 t% B, b. E0 E- L2 c
- * TO CHANGE.4 x- d" `7 J# c' x, k! r
- *! A4 x9 s" x# X4 _! P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 p! K4 a0 [3 g; E - * H' I: E; K6 P. |6 j. _$ T' g
- * This program is free software; you can redistribute it and/or
, B& Z9 N/ ?6 M { - * modify it under the terms of the GNU General Public License as3 z3 P- s F: s* R( m
- * published by the Free Software Foundation version 2." J+ x3 p& h4 T2 Q d0 a/ i
- *
' ?; j. m5 Y3 l - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. @! F1 A1 ] n3 E$ p/ O
- * kind, whether express or implied; without even the implied warranty X' x4 U1 ` l1 A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& c/ ?7 T3 X1 z1 K) u/ W! R; Z* @% m, s: F, [ - * GNU General Public License for more details.
* D' K; L8 `7 L& y - */
) `8 j; {+ A$ _' |8 Z& ~3 \2 I" c
/ Q; x4 u& G) I+ ~7 w: n# p- #include <linux/module.h>
3 U% y3 q: H4 m4 `3 d% E; B' R3 F - #include <linux/init.h>( e2 ?, R0 v4 P& Z2 P
- #include <linux/errno.h>
( M5 v' U( f$ l5 {/ `8 R - #include <linux/types.h>, S2 E: y8 m. [2 n
- #include <linux/interrupt.h>
2 }/ b. T- s2 c( F4 E7 x - #include <asm/io.h>7 W- t; S& I9 B; {+ k: v( M5 u
- #include <linux/moduleparam.h>! |. j _. n7 l1 _& S% K
- #include <linux/sysctl.h>
1 r l/ V. |" \" I5 W! x: [ - #include <linux/mm.h>
8 K9 p! S0 }1 M% O' i& g, H - #include <linux/dma-mapping.h>
d* q1 q0 P' Q( B) [ - / Y* R! M$ j. ^5 Y9 e) I
- #include <mach/memory.h>
/ J# y a$ Z1 b: L - #include <mach/hardware.h>
( p$ Z6 z: X. f* Y - #include <mach/irqs.h>
/ R8 H& g0 q. Y/ e2 G - #include <asm/hardware/edma.h>
# o* A+ S4 q, f I% a* F - ) K1 e/ |; l& X& K" A- r
- #undef EDMA3_DEBUG
$ T ~+ K1 W$ d, C+ t5 Q2 ] - /*#define EDMA3_DEBUG*/
; \* t q1 H* `
& A! o4 B! w8 i: R- #ifdef EDMA3_DEBUG3 Y% w4 r T% d9 C Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), [8 @8 [0 D1 C: q# t9 U) N5 x
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
?; I9 q2 o- P0 u2 h" m e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. P$ z* Q! Q: l6 V$ W - #else2 N7 b4 w! r9 U! D7 e a
- #define DMA_PRINTK( x... ); Q0 U6 V0 }9 L$ F, ]* k4 u( V
- #define DMA_FN_IN
; s3 r! v/ Y$ R" b: O2 X* q8 R - #define DMA_FN_OUT
1 H/ x& y+ h4 ]; w) K - #endif
* m2 j. S8 n) G9 P; {8 K K* y( G - % m4 ?0 \) j" m& H/ q7 a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ y& W+ ^; b o4 |* s* j
- #define STATIC_SHIFT 3& K$ y- H5 J" m' i" D! x n. J+ L
- #define TCINTEN_SHIFT 20- L1 M: H7 o" I: n, B, S; H
- #define ITCINTEN_SHIFT 21
- o. m7 l( s* t! d: [3 U# e - #define TCCHEN_SHIFT 22
9 M/ V, X3 d/ S% ]2 L - #define ITCCHEN_SHIFT 23
: O7 {/ e% g% j: R5 m$ J8 N0 \
# B: _% m) r" b% q v( W) R- static volatile int irqraised1 = 0;4 K4 }+ J* b* e
- static volatile int irqraised2 = 0;
# _/ L7 O2 G7 O/ Q& x) j
( ?5 r* _, Z: F2 }& ]0 j) l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 f: q; c( w" W. _. O1 ]# y6 `9 g' e - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* x! J) B* r I7 _* H& f. O/ N
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( _ W5 j3 H) @/ v, V Z% v
. o+ Q6 \/ U$ [) Z X- dma_addr_t dmaphyssrc1 = 0;
4 L% a! m2 s+ t; F# v1 ^ - dma_addr_t dmaphyssrc2 = 0;1 K9 m) K+ e) i5 ^1 K; D
- dma_addr_t dmaphysdest1 = 0;# H8 ]) ~2 |/ O. p) s3 r
- dma_addr_t dmaphysdest2 = 0;$ |) u {$ I. x- M6 m. { w
- ' O1 w. I3 Y0 T( t6 p
- char *dmabufsrc1 = NULL;
1 f8 N. z; C2 E8 a D1 J) Q - char *dmabufsrc2 = NULL;1 U2 B+ d z! \$ N5 a: ?+ i, H
- char *dmabufdest1 = NULL;
; V( F& V. j. z4 o& t - char *dmabufdest2 = NULL;
$ b7 N5 O3 D9 q; N; \, d, h
$ _, R6 D, C" Q2 L% C2 q- static int acnt = 512;: M* G+ y+ M f
- static int bcnt = 8;
9 q/ k$ c: ]" H* M8 R/ G - static int ccnt = 8;- M7 j4 y* H) h+ o* f9 u
3 s; d) N4 ~8 a+ n. q+ w- module_param(acnt, int, S_IRUGO);* C: W5 A/ J' n
- module_param(bcnt, int, S_IRUGO);# v. F& D3 l( b' H
- module_param(ccnt, int, S_IRUGO);
复制代码 ; ]# s ?( l# i4 l+ i/ I
5 |$ x, }% n9 f5 k0 x0 ]6 J: X' Z& \3 s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" w# g9 w K, g, E
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ N( P* n: N; Z9 I5 E 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ q2 D; l+ ?# a- j' v* J. J
/ u2 A" o% E: w
+ O8 q% Y' E. ?$ L' x7 }4 i* {, A |
|