|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; u" i' o8 E( R/ u5 W
- [code]EDMA sample test application
& s( X, `' C A8 z% ^6 X - /*
- @2 D4 Q1 s& _. l0 o% R9 M: J - * edma_test.c
6 D/ Y/ ~+ @( W - *
' S- U# |1 {0 c2 q5 T - * brief EDMA3 Test Application
$ M; G( P/ ~/ Q1 ~/ G, d1 @4 s( p5 S - *
" A' ^8 d2 ~4 P8 y5 t - * This file contains EDMA3 Test code.
6 q& n& |8 x5 V& Y) _ - *2 }# q2 ]. E& D. K/ M6 }+ b$ |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
M0 B$ A& w: m/ h( x# ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 w9 G' p' u7 c. A$ h - * TO CHANGE.- m2 r! X" v8 A. P4 {" q
- *
7 K) a. {" _! B" u- z% o/ A9 i W - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' t" v' w4 ~& n4 C
- *2 A/ `, N2 d' ~- _
- * This program is free software; you can redistribute it and/or% G9 X8 Q8 F# f+ A, g$ k& U
- * modify it under the terms of the GNU General Public License as' x, n6 J! V4 ?+ k/ t
- * published by the Free Software Foundation version 2.
$ t7 C, b9 H' Q, q: r* h - *
- S" w4 l( ^: Z0 D9 t( J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 `0 P6 l* o& e$ I7 H
- * kind, whether express or implied; without even the implied warranty4 \+ | @% ?' J9 b9 l# F0 y4 Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, u2 m$ z( F7 R* O: Q - * GNU General Public License for more details.
. k# r# \7 t7 H0 G! \( q - */
: T9 a5 r& j* l5 x2 W
0 N; e6 m& x$ {, Q7 X+ ~' y+ v- #include <linux/module.h>6 @9 u! X9 Z3 s
- #include <linux/init.h>
4 D% k. c4 m% v! v7 B6 m, K0 m - #include <linux/errno.h>
. l" B6 k+ j$ @8 S - #include <linux/types.h>7 X4 s" [/ Z$ m" I
- #include <linux/interrupt.h>
% w/ g" o- W/ e' k' `" N9 d6 ^ - #include <asm/io.h>0 q0 V1 a: ^" U- ?+ z. p
- #include <linux/moduleparam.h>$ x' q; C0 h- g: w; Q4 h+ C! n
- #include <linux/sysctl.h>
3 A3 R* L ^8 V6 r& L- m" W1 O - #include <linux/mm.h>: ~( ]$ \2 y$ k) Q1 b( ?! v
- #include <linux/dma-mapping.h>
" F1 k0 u, t7 H L/ J
$ G) b& w( H9 R( [- #include <mach/memory.h>
. P' }. a+ K3 o" k/ Y5 L- L2 n - #include <mach/hardware.h>
; M- N) o/ A4 G% W - #include <mach/irqs.h>
1 k1 z2 Q" x3 a3 b0 p; d/ p- G! F - #include <asm/hardware/edma.h>6 R' h& `* ^; j# m
- ( m& d6 Z# l! M$ L
- #undef EDMA3_DEBUG
$ f! v1 ]8 {9 G9 N6 Q - /*#define EDMA3_DEBUG*/
" t; h$ `" @7 \! _5 u+ n - % X- U' g/ x& x: M
- #ifdef EDMA3_DEBUG
8 e& ]! }( m) |9 u* ^9 w6 K+ p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 c+ t; y2 @+ o: j1 p7 Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 v3 a s+ U$ h- J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 P+ v4 H) d% _ \9 @
- #else
7 S% |8 H. f. m& t$ A; l3 H - #define DMA_PRINTK( x... )
, B% @( k0 Z# i - #define DMA_FN_IN) h4 X5 |# g+ \# ^- q, y7 W
- #define DMA_FN_OUT, _3 a* |3 Q. ?; Q* f
- #endif" h1 c; w% L* A, z' n
- & S& |( R- Z! n! d: j0 `- w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( Q! ^* P4 l% O/ \& {0 J - #define STATIC_SHIFT 3# S# } @7 D$ z+ A
- #define TCINTEN_SHIFT 20 s9 S8 R9 E: L
- #define ITCINTEN_SHIFT 21* |, q/ C. @! ] j
- #define TCCHEN_SHIFT 22! w. N1 e$ ^' }% e1 T" Y' A+ T
- #define ITCCHEN_SHIFT 23
6 i# C5 |2 l9 p2 m* R
8 F2 h( G3 O4 X5 Z- static volatile int irqraised1 = 0;
3 T' Y# o, C: B& v# \: x: x) I - static volatile int irqraised2 = 0;0 v4 E; J6 S4 G5 m
- # ~! k3 U) ^# }3 C& c1 E! K
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, A7 D' w9 b' u( H6 e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' e, b! Q/ b6 u6 y4 f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 s: H2 q8 P) p% T0 `
- ' G5 |" b3 \2 d
- dma_addr_t dmaphyssrc1 = 0;
w: n# p6 I+ N' c g: E4 j - dma_addr_t dmaphyssrc2 = 0;
# k. w, |' I; s/ r* Z - dma_addr_t dmaphysdest1 = 0;
) F9 O( k$ W0 @2 W - dma_addr_t dmaphysdest2 = 0;2 j: H9 P5 A. p3 ^3 u( t9 i8 R
3 x* d+ \- J1 ^6 }' o x- char *dmabufsrc1 = NULL;/ m6 n' X+ F1 R9 f* T
- char *dmabufsrc2 = NULL;" C7 K3 C' M2 c
- char *dmabufdest1 = NULL; c, e: H+ O; |: U. s* P1 E; {
- char *dmabufdest2 = NULL;4 O) ]* B# A* i# I1 Y" i, |! l- q* p
- 3 y# ^5 e* X" \( p
- static int acnt = 512;9 A9 L! g% u- p9 B4 J: ~! [
- static int bcnt = 8;
0 _( o6 y# e& t1 m3 g* o5 x - static int ccnt = 8;
4 G' N- g. }3 ~0 L0 j' D% w - * y& u( w( \% _6 O- k6 ^- ~
- module_param(acnt, int, S_IRUGO);
$ j* ?& d! p) O" ?& O! n9 } - module_param(bcnt, int, S_IRUGO);
- y0 ?2 ~4 K+ a! L9 c( b2 G+ I* \ - module_param(ccnt, int, S_IRUGO);
复制代码 6 Y% F! I# P. K4 s2 P) a) g3 K# w
5 J) \# d0 X! H X6 `. U. A/ |! ]) o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 Z# X! _4 G7 y( U4 | V
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% O9 E4 _, z7 K& L5 u1 H
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# d" S3 z9 B" J. G- N
' Y( m- G3 H! H# C- f' H/ d k1 Y# m- h, Z2 [8 ^6 O( D+ t5 }6 M6 h( y& d
|
|