|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 E( A; R, ?: h+ a- [code]EDMA sample test application
$ T% R, v+ H# Q- L* V - /*; m8 F( X( j0 P, t" q' X1 x
- * edma_test.c
$ t$ u( L4 X( r& t6 }, E - *2 q: g0 y1 p0 B* x
- * brief EDMA3 Test Application% n8 ^! D+ a, i
- *" ~: r- e+ p. C! W
- * This file contains EDMA3 Test code.
3 N0 i( r; n, E1 }, f( { - *6 S. ]* t, u, z6 b' y+ m) D
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) B6 o1 h$ ^3 U* y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 \, A) \* H% k* `, M/ Z. F
- * TO CHANGE." \7 I3 E2 p) i. [
- *
& u E: A- B, @: Q" c- o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 U& i0 b: P( _& `; c/ P% L - *2 i) ^6 Z; |% _! d7 }8 q; S* J
- * This program is free software; you can redistribute it and/or
5 ?3 ^' o) F6 @0 f# h; E2 O& s - * modify it under the terms of the GNU General Public License as h6 l5 {2 m* m. v( w' q1 m* J0 N
- * published by the Free Software Foundation version 2.
5 Y. ~6 K8 F0 t8 w; B. w' x - *
4 j0 {8 M' U0 ?8 U! R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 C4 D4 L" x. q" t P" S - * kind, whether express or implied; without even the implied warranty
' |+ N. Z$ [* _) Q4 r0 o& x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: l; z `4 c2 k$ y3 Q! b
- * GNU General Public License for more details.
: o; }: p4 T# W - */
f$ F" L3 a. J- M( r6 L
8 h! o: Q3 m4 Q4 I, u3 T- #include <linux/module.h>+ C. \( e; ^: \7 v9 ~
- #include <linux/init.h>
, A+ R2 S+ j+ m0 s - #include <linux/errno.h>
8 _+ d9 i' E" a' n* n. V1 a; s - #include <linux/types.h>
: y$ W& F2 U% N9 v - #include <linux/interrupt.h>
3 J2 \7 i2 ]- B' @: J2 g+ T - #include <asm/io.h>* i3 H8 o7 n7 L
- #include <linux/moduleparam.h>; f2 j* n! }, s6 I
- #include <linux/sysctl.h>& A/ n$ Y0 x% h' L: I
- #include <linux/mm.h>
$ h+ P$ x. {8 r. \) d' z7 \ - #include <linux/dma-mapping.h>
! {8 B9 }4 H Z7 c
4 @" S9 G3 M8 H- #include <mach/memory.h>
$ O, h+ `$ } g$ ~# S" I- [4 o - #include <mach/hardware.h>2 x4 ?2 w" W7 y% l" s8 C5 F
- #include <mach/irqs.h>
& u; y! U* a7 W7 q- a; X- g* z - #include <asm/hardware/edma.h>* Q6 A# V5 e8 C+ ]
- 7 U5 m3 ?: B N; v& T
- #undef EDMA3_DEBUG
% Q8 e# Z! B `0 k0 R - /*#define EDMA3_DEBUG*/% b+ g5 f( M f4 C3 O
; I& L/ V8 X" `- #ifdef EDMA3_DEBUG8 R( v3 V+ G: {5 V# o9 T8 ]6 z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 F! H, F: D# u - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- N% s( v& V1 a& f! a w& W - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 z) h$ N6 B5 s% z1 s3 w: h1 z
- #else0 x8 A- f3 a1 g, `7 W
- #define DMA_PRINTK( x... ): {$ S7 b1 |7 T
- #define DMA_FN_IN
5 [7 i2 J. g! [+ ~ - #define DMA_FN_OUT& L% D/ A" P. h, a: q" s% L1 u
- #endif3 L6 I9 y# b* J3 @* b |. j2 K6 Q7 D
# z4 K7 V6 w, [' a* y7 p O# S- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- l; Z: u0 |0 X5 H8 q - #define STATIC_SHIFT 34 C) s l7 F# o3 Y
- #define TCINTEN_SHIFT 20
0 l9 S1 F& g/ e: H8 L - #define ITCINTEN_SHIFT 21
, d+ r g6 i1 W3 m9 d3 T2 v - #define TCCHEN_SHIFT 22
, C, i& Y; r0 G/ y1 } - #define ITCCHEN_SHIFT 23
& w* _& m+ i+ D/ m( i, I D
8 H8 M$ {5 s, c X; Q* y7 t' x- static volatile int irqraised1 = 0;
R) Z9 ?% ]* Q) }7 r* M* X# H, ^# H T - static volatile int irqraised2 = 0;
: h' s1 u- B9 e* @' c; K7 M3 ~ - 6 k8 S8 n( E7 Y1 R. z+ E+ i6 P" U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) c: Z7 X1 H8 v5 ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. ?# y6 u( \: }0 @: D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) r& D; V9 {0 l0 C) ^$ X
# X- s& x9 R8 g Q. T' A- dma_addr_t dmaphyssrc1 = 0;
$ i9 k8 L B* {, `3 J - dma_addr_t dmaphyssrc2 = 0;
* D$ _8 [- _- y4 h - dma_addr_t dmaphysdest1 = 0;- o* O- z8 D/ l7 ~3 j/ G! \
- dma_addr_t dmaphysdest2 = 0;7 ]" M( R& p# e, o+ s
( z5 g+ z) H. w, u% u- char *dmabufsrc1 = NULL;) T0 e' Y; H! J
- char *dmabufsrc2 = NULL;% ~6 b% i5 C5 M- z' I: C
- char *dmabufdest1 = NULL;, l% D8 `2 J: j; w' P7 K
- char *dmabufdest2 = NULL;) I4 g6 M% c* D% u3 j4 p9 U* O
- 0 T# z/ r- O. {3 }0 S
- static int acnt = 512;
) v z+ K* {4 `. Y, Z- @ - static int bcnt = 8;
4 Q( p G' m5 w8 E: i" _4 r - static int ccnt = 8;
7 C9 t1 u% ^! e T' _/ s6 l J6 P - " n+ f* I6 n' F
- module_param(acnt, int, S_IRUGO);/ {2 j+ \/ {8 M* e' e/ E3 ^
- module_param(bcnt, int, S_IRUGO);5 H0 A. y" s( N$ V" I
- module_param(ccnt, int, S_IRUGO);
复制代码
$ M. t- N( I/ j, n' n! ]6 z- E& M
3 z2 F7 {% p5 c7 i6 c0 l* k6 _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' w- X, X: i- |8 G; h- W& _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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 s, G" e# M3 [" X7 u7 {5 n s
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 D! V) L% e6 a6 d; w5 I1 T
' L3 X+ I3 v4 M* J* Q) F
! b5 d9 u- ~/ _! G: s3 [5 Y8 u r |
|