|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
b% A, Z& `) I' g" ~- [code]EDMA sample test application
- H9 V* s: O0 o, r: S' j - /*
% J1 t& D# W; ?7 Y - * edma_test.c
& r4 C- }8 [0 r- s - *
" k- M( x9 Q; j- Y6 h* W - * brief EDMA3 Test Application Z1 D3 x' f. s0 |
- *( x8 S$ {. d% y/ y3 s
- * This file contains EDMA3 Test code.) l0 ~5 K! j$ p
- *" {7 M/ E! T7 }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( o; V2 V6 r4 d( K% g z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ T5 a8 P9 T- {/ x
- * TO CHANGE.1 L% M& `; p: q% X( e
- *
8 V7 |; b7 n A - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& |+ f" X. X% k& V
- *. ~0 L7 D. P: F) b! _6 E& ?
- * This program is free software; you can redistribute it and/or
7 R9 V/ V q) P7 e" A% ] - * modify it under the terms of the GNU General Public License as9 [$ D6 ]# n7 @+ r2 }' V
- * published by the Free Software Foundation version 2.
+ Y6 y* O3 D5 L2 |4 s% ^ - * @* r5 A6 p3 |- t: i* L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 E7 b8 }* [9 U& G* _1 l8 C- k5 y - * kind, whether express or implied; without even the implied warranty% @5 m3 d9 ~5 ?
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. x! s# I: X1 X1 Y) g
- * GNU General Public License for more details.* r, [2 l2 [/ ~" W7 U, b1 q }3 ]
- */- V* S' M9 \) p/ q2 F
- # s, M1 `& q4 ]# w! m# [9 L
- #include <linux/module.h>( }5 V: t: N$ r3 ^2 D
- #include <linux/init.h>4 s1 A! N+ X* J* `9 K- X+ l
- #include <linux/errno.h>
7 U8 W- G0 y6 `% ?1 C - #include <linux/types.h>
6 B5 F( Y2 j: j2 n* ^/ t0 m - #include <linux/interrupt.h>
# n( \" s; y" }' d) z - #include <asm/io.h>
, n+ \/ q9 y" C$ c$ y* x# ] - #include <linux/moduleparam.h>
- r# A# V G3 U& Y% I1 D3 { - #include <linux/sysctl.h>
( N! w* V1 {, B! w0 F - #include <linux/mm.h>6 Y# g: N- F3 t
- #include <linux/dma-mapping.h>
7 ^5 |1 J& u/ f% W- N - ( r D& m$ T, J2 o. K7 H; H
- #include <mach/memory.h>
; {5 ^; U; }* d& j7 x( a; L - #include <mach/hardware.h>
$ T4 H( R9 x$ `3 j* r }( i+ r, ] u - #include <mach/irqs.h>
3 m5 t. w/ B+ c& p# W - #include <asm/hardware/edma.h>7 ?4 E z3 ~. e- h3 V
h* P; Y s- w1 \3 U6 T! ?# g3 g- #undef EDMA3_DEBUG) A& A Z4 Q8 {( _6 {2 _
- /*#define EDMA3_DEBUG*/; e5 d. d @. U3 i1 V+ M
' U# T$ C* ~/ O& U6 u# m- #ifdef EDMA3_DEBUG
2 g, Y/ {% e9 |! ]( X! M - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) b) i4 G6 v- a5 X" J, m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 D% E+ S8 v' s* J6 z& n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), b% K, @9 G7 P) O
- #else/ w) p) v0 K2 y2 C9 ?* S# a# o5 I
- #define DMA_PRINTK( x... )
9 g. ^6 a- u8 \6 S# W - #define DMA_FN_IN
5 R9 i( ?9 [. H6 s - #define DMA_FN_OUT
: a4 K! p. r9 H( D/ v2 F+ h8 X - #endif: C0 I) Z7 j# D& s+ u
- % t7 [: r# d7 W9 l) R$ r z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 l; R: k& P6 \0 B+ T - #define STATIC_SHIFT 3
4 m( B$ O; B z: q - #define TCINTEN_SHIFT 20
7 j+ z8 W) f: |) L$ `0 d6 }% z - #define ITCINTEN_SHIFT 21
5 ]& ] y$ h; I% x. |) {; Q - #define TCCHEN_SHIFT 22
8 t1 K( v: V7 R# Z4 Y2 { - #define ITCCHEN_SHIFT 23# I- M0 }! Q- U8 |3 Q t4 l2 J! A
- / K3 c7 @. M9 b5 v. B2 f
- static volatile int irqraised1 = 0;
0 e) a$ d& l. F- s - static volatile int irqraised2 = 0;
; }1 r8 v. b, e* ?% s/ F - 9 M% j+ x& f* ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- w |" L2 h) v. T# a - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); \* R3 q" \4 c
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 x% U. t* T; y' T8 s& ~' v
- ( p( G% H: C4 f0 e- [2 R+ A
- dma_addr_t dmaphyssrc1 = 0;
, O" v! p8 ~, O5 n2 D - dma_addr_t dmaphyssrc2 = 0;1 ]% F/ [" g# l8 q7 Y. F8 T+ o
- dma_addr_t dmaphysdest1 = 0;
! d# p3 f2 l8 Q g9 }0 u - dma_addr_t dmaphysdest2 = 0;
. p! i0 }0 O, K9 f1 l( r/ q
% C) C0 r% c# B; m" ~- char *dmabufsrc1 = NULL;1 G& ^9 `$ q$ {7 t" E
- char *dmabufsrc2 = NULL;6 W# X8 P' V$ b9 s
- char *dmabufdest1 = NULL;: e! i4 \: i# t+ ~& D' L
- char *dmabufdest2 = NULL;- f8 k* }' @. w* T5 j
- , c+ j0 g+ H {; F5 ?
- static int acnt = 512;
, N4 m" v) r3 ?% y - static int bcnt = 8;5 t% H) Q7 o$ [6 e3 S! f, Q [
- static int ccnt = 8;
2 Q" l5 A. X( w2 }* G - ! u& R3 R1 \. x1 f
- module_param(acnt, int, S_IRUGO);
. c1 t4 a; K# k- C$ P( J, q' }! ?, f - module_param(bcnt, int, S_IRUGO);% Q; X! L9 x N1 u: N
- module_param(ccnt, int, S_IRUGO);
复制代码
! _6 ^# g* E: D
5 S7 p7 H( f, I0 o2 f- _/ }6 V) t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, ^8 c3 u; M. \) U; aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ y- G' ~8 `6 m, y) [) Q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. ?9 r& I8 ] m" p; p' `6 B+ m6 v
w' R I3 r! D6 W( |- z
8 S0 R8 m: ^# ? |
|