|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 L/ {' L: b+ y: F; F! n+ O) J
- [code]EDMA sample test application- x0 f1 q2 E+ [" h: \( m% F" R S
- /*! B% a* @+ ]" j9 v! X
- * edma_test.c
3 k& v' l2 Y. s/ r8 d. {0 z - *( O& S1 h% ^) R
- * brief EDMA3 Test Application6 h# t0 Z) A$ T$ K7 W
- *
$ o0 r7 _8 t* G5 u5 w - * This file contains EDMA3 Test code.
3 }+ c1 [5 C1 ~ - *& }! d" e) @8 [8 Q1 U
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 p, y+ c1 F$ a1 `! T9 F; O0 z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; J: r, [5 f: p( S
- * TO CHANGE.
& r8 }3 o$ r6 v, T( j+ Y) X - *
2 @8 i# u6 l& f" w) k. d( G - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" G1 w4 g$ t! u( O9 e: C2 l
- ** E9 D/ S, e E# h
- * This program is free software; you can redistribute it and/or6 Q, w' ^2 z! S/ C* R
- * modify it under the terms of the GNU General Public License as
- ~ k/ G- x, I2 j+ G - * published by the Free Software Foundation version 2.$ ]; @9 }3 S% q9 C5 c- e
- *
: L7 I) u) B A+ h, f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 b! _3 L# g" X: B) A8 d
- * kind, whether express or implied; without even the implied warranty, ^: K5 f- C* @: J* y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! o! \% `/ r3 r# q5 U" e) | - * GNU General Public License for more details.
; s# h- g' b( e1 Y, s" ] - */( z* |2 z8 b T' [. A, n0 S
1 ]1 U8 y: V0 N" Q3 t- #include <linux/module.h>& u' ]6 v9 B( y B
- #include <linux/init.h>0 k7 a- K5 t6 x9 x" d- g" c
- #include <linux/errno.h>
4 E0 C/ \. c8 K6 q# _. G - #include <linux/types.h>4 @* T; @) Q4 |7 A1 g& a) Q+ o+ X
- #include <linux/interrupt.h>
k6 ~* Z6 D/ ]" N1 c7 A1 d4 m3 z# U9 m; } - #include <asm/io.h>
% L( A/ v+ D4 O - #include <linux/moduleparam.h>8 z4 J6 o P: U* [" J8 S- Y# h
- #include <linux/sysctl.h>8 x# A, K1 U$ _7 P% `; D' p
- #include <linux/mm.h>$ k$ e: ~* f( b7 t5 G, G7 C3 u
- #include <linux/dma-mapping.h>
, `/ b/ p5 p* M% m
6 J; P1 q1 y/ F3 }- #include <mach/memory.h>
: b# H* b+ ? m% {5 S - #include <mach/hardware.h>
2 a; |% U0 e6 S: Q; Y* @ - #include <mach/irqs.h>
( S' q. q/ p! `: j - #include <asm/hardware/edma.h>
6 V Y" Q& O6 M& P+ i. N
" Q) n$ u6 I, t# P4 @1 ~7 A- #undef EDMA3_DEBUG
$ ^/ B, I! B( U' Z+ [ - /*#define EDMA3_DEBUG*/
" u% r+ K' z& N& w/ w
% q3 {1 B. n* @- #ifdef EDMA3_DEBUG
6 J- ?7 `# P# f( N2 l. X3 \ |2 c - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& ]- h Q( n) g$ Q0 q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% @7 v( m/ W4 q0 ?/ H( b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ D5 c2 E3 Q- b$ m" t+ u% |: x
- #else+ y! a( h9 B- l, ?3 f8 T' X; W" f1 f
- #define DMA_PRINTK( x... )
# J7 x' q$ `' u; X- X7 f - #define DMA_FN_IN# q8 I. r3 J& Y! M( K2 @
- #define DMA_FN_OUT
5 {! {9 \0 ?0 d" c# d - #endif3 A: Z7 U8 h4 E3 E" A
- ; o) I" Z' f* B b1 z9 m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ u6 I% z0 c9 Y* H& U- s! I
- #define STATIC_SHIFT 3# E9 p6 A+ h0 v% @ Y
- #define TCINTEN_SHIFT 205 j1 k7 }- r) R d' e( ^# X5 U
- #define ITCINTEN_SHIFT 21 c- }4 V2 Q/ ^; J! q
- #define TCCHEN_SHIFT 22
$ Y9 ?3 u1 I3 C0 q8 p - #define ITCCHEN_SHIFT 23
4 N: Z8 K) ^- v
: O# h1 r. L6 I" m5 f2 ?5 h- static volatile int irqraised1 = 0;/ R. @2 ?( D5 M& |! L- W$ s8 U5 I
- static volatile int irqraised2 = 0;
* I7 O5 q0 v' m
% v% _ b( M& Y, Q9 [' F7 g4 B- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 j+ [5 u4 {% ]/ b3 J* Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ h1 f0 s" g, p0 H# z$ J. V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* [% x% E; Q8 }, S - 4 }/ Q6 n! Y: z8 {
- dma_addr_t dmaphyssrc1 = 0;+ s' Z! Y, a6 @8 i
- dma_addr_t dmaphyssrc2 = 0;5 d9 {3 ^" Y2 v; }: o1 l8 h1 T1 z
- dma_addr_t dmaphysdest1 = 0;
! m5 l, }7 K m( b - dma_addr_t dmaphysdest2 = 0;
* h5 c" Z, Y9 U0 O8 r. h - 6 Y" f3 a( n2 J- O* |
- char *dmabufsrc1 = NULL;
! a3 B( c/ }' Q; a - char *dmabufsrc2 = NULL;
; A @. l* l. l7 o% S- K - char *dmabufdest1 = NULL;2 ?: f; U9 h$ a7 ~+ ^4 @+ d0 y
- char *dmabufdest2 = NULL;
* P) k6 ~0 H: ~2 C2 Z - * R0 Y" d. C" a2 \4 E
- static int acnt = 512;6 \' j& W' ?0 M. ]
- static int bcnt = 8;. a! k+ n6 w5 i6 I1 l: T
- static int ccnt = 8;
* I2 V& p4 }% K9 a% @/ M
. L- ~- T; x8 x9 P3 E2 ]7 A1 l( `- module_param(acnt, int, S_IRUGO);6 n# F* ]9 R, j7 }4 j6 s/ G
- module_param(bcnt, int, S_IRUGO);% Z4 i5 O/ R: k1 H
- module_param(ccnt, int, S_IRUGO);
复制代码 % y' W' e) Q9 O, l3 ?
4 s4 I& A e% E. B1 { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 A8 u' m- u5 l+ t2 Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* W) ~* i+ ] \: f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; }8 R# |3 u. }
- E) H( e4 G+ q4 W; ? p& ?4 w. G6 H, _; M6 g
|
|