|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# { z3 I3 n$ A: |- [code]EDMA sample test application
7 `+ g% m3 E# D8 N' {6 h+ X; u* j - /* b/ r% }3 l" s
- * edma_test.c/ A- B& l t- G" ~( ]
- */ q- U0 n8 t. p- N3 h& ^" B( x
- * brief EDMA3 Test Application; r" l: @1 q b! \) M
- *
! v: [& M- u1 E+ r* D0 f3 L8 V - * This file contains EDMA3 Test code.1 {. f5 z% w p& Q: p. s
- *
: ]: Y6 D% W$ Z2 x X& [, h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ [$ F; e7 Y: \+ y- m( L! `, g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 g/ {) f# S6 W! l& ?% I- G - * TO CHANGE.
2 ^" R F, S+ {8 z2 K( l3 u - *; e2 n, w' _$ v6 _0 J0 w. w2 y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 w5 \) g K; u7 w - *
0 o( A% Q; K: l4 m - * This program is free software; you can redistribute it and/or) L/ W ?! B; b. D
- * modify it under the terms of the GNU General Public License as7 d0 Y1 m' M; P; \$ o
- * published by the Free Software Foundation version 2./ }* O' z1 u" K/ u$ A3 C
- *- h% Y3 C9 D6 T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ @5 C( z4 B" P7 c: L - * kind, whether express or implied; without even the implied warranty
" |* c* X% A& s8 Z) Y% _% N! D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" C8 E: Y! b7 o( E2 N) O% j
- * GNU General Public License for more details.: A6 n; [. K( R) d9 W3 X
- */
' B+ W4 c: b! I. t( L, a - - X: _7 d" `9 L. I, X* A: v6 B; P$ Y
- #include <linux/module.h>
1 O, Y2 m, s! a* A2 t; E# A3 H - #include <linux/init.h>" v8 g$ h5 U& i# u L1 O u
- #include <linux/errno.h>/ g( d8 |/ `6 R7 k! L% |
- #include <linux/types.h>3 X' Z9 f1 t7 o- G* x
- #include <linux/interrupt.h>
" L( t% k6 u1 I4 A c - #include <asm/io.h>
/ S4 Y1 e3 M7 I* C9 |' X" _1 ` - #include <linux/moduleparam.h>
' Y5 e6 S9 W% y- W) E7 V2 j9 W - #include <linux/sysctl.h>( A4 t5 L# \; \
- #include <linux/mm.h>; x' r5 a5 W x) P6 Y2 v
- #include <linux/dma-mapping.h>% k8 k( c/ W4 u
6 y1 Y4 O& z% R z" |: E. s% _. n- #include <mach/memory.h>
+ `; J/ H0 M/ Z: g1 }8 B! s! V) E - #include <mach/hardware.h>
4 Y/ ?9 R' v$ [7 m0 h3 F- y# y t - #include <mach/irqs.h>2 f0 z2 {2 p+ T" b8 [
- #include <asm/hardware/edma.h> C' E) C6 }$ ?2 e% n
- z8 q' ~/ d; V: ]: l
- #undef EDMA3_DEBUG" d# k0 s! d- A0 k
- /*#define EDMA3_DEBUG*/
+ } I7 w$ k$ T- j) A5 M! C" H* {# Q
3 U' x" M& N7 C3 \( t8 q& a- #ifdef EDMA3_DEBUG
9 [! G J* M" ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( T. b5 s+ I' t5 ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): n; G8 x3 E# S; b+ P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ a& [& k# I. T; m" y3 B - #else! B# O$ j6 Y w5 |' G* [+ I
- #define DMA_PRINTK( x... )" y/ ]2 O) }5 j. a$ O& u7 q5 G
- #define DMA_FN_IN" P# c2 n% @6 a' z
- #define DMA_FN_OUT
! @" q( V1 o- i- E6 @9 `, @0 l - #endif: Z8 ^9 i) A J" l9 ^5 |
- ( K! T- S4 e% h: Y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ Y6 f# b$ ?- ^; z% ^. O - #define STATIC_SHIFT 3
4 y! W+ a- R6 ~# t" _+ R# Y - #define TCINTEN_SHIFT 20: L& E& D; w! \# a6 w3 V6 e* f4 G
- #define ITCINTEN_SHIFT 213 k7 t/ B* p- y! q4 G/ R& ^, j
- #define TCCHEN_SHIFT 22, y. t$ A3 b( p' K
- #define ITCCHEN_SHIFT 23: E3 I/ g" W W8 D! }
" {# L8 @& e5 ^6 k* b$ I0 f. R- static volatile int irqraised1 = 0;$ T, Z- ^5 _( y. U' u( v
- static volatile int irqraised2 = 0;2 V. v, z B( y% l4 E; c W
& T" w' y. S) G! d+ W- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 l& ? }) Y' @# v! o - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ k9 D" \% c% Z' w3 s* S) T; @; `0 [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' a3 w3 b/ D2 k$ i' Y( y/ N - 1 R# Q5 g/ X( I3 N' s1 s+ _ k
- dma_addr_t dmaphyssrc1 = 0;7 A$ @0 a- q* r6 s2 x
- dma_addr_t dmaphyssrc2 = 0;* B- t' Z2 \- n0 s2 A9 F
- dma_addr_t dmaphysdest1 = 0;
, I$ m2 Q) E+ ~2 E' g - dma_addr_t dmaphysdest2 = 0;
/ T& h- L8 D o: {+ p+ Z - & h- ]) u1 j+ x* Q4 J
- char *dmabufsrc1 = NULL;
" |8 q I* n& p% p# m5 g& h - char *dmabufsrc2 = NULL;. P0 Q7 l9 z4 n. y
- char *dmabufdest1 = NULL;: g4 I3 h( ^9 U; c- T& n, ]
- char *dmabufdest2 = NULL;
! \! m$ ^4 z1 w3 R/ e
, N+ G& W- Q/ i7 i# H" Z* K- static int acnt = 512;
/ ~6 C3 w |5 I7 `' a7 Z; P - static int bcnt = 8;' J0 Q/ ?- m, ]* G: G
- static int ccnt = 8;
! C7 Q* t; I5 U: _2 f1 ?+ U
1 `$ @7 m* _7 a+ B+ @- module_param(acnt, int, S_IRUGO);
5 F/ u4 l' i' H s, W; _ - module_param(bcnt, int, S_IRUGO);1 S. [' [6 J! }. d
- module_param(ccnt, int, S_IRUGO);
复制代码
4 s; ]% J/ w+ g1 F3 ~: m6 d* M
1 t# y: u0 [5 \' W4 o) S6 j0 l2 g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ Y7 _- b. _+ farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" i+ _9 ]! E& z R3 n: ~4 N 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# i: K. V9 r) L' E3 O) Q C' s
& W; F; t( r6 C# A( J1 h1 y
" { B2 [/ g3 |8 V" x5 R |
|