|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. t; L1 l( T( Z6 L* X1 R3 ~- [code]EDMA sample test application
- K4 X# z, M. w - /*/ X3 \6 H/ }5 D
- * edma_test.c
% c1 F0 d# ^+ d6 z& o% G- r - *
6 w9 W b, j: D8 T - * brief EDMA3 Test Application* _* j: G" r9 w! h$ b; `8 v
- *
/ i* C$ V5 Y) t' j - * This file contains EDMA3 Test code.& w7 B/ T2 }: |$ k+ O
- *
0 d8 S0 q1 d( B- J+ y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 J4 k. U& V3 r, o - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! p2 m S) K5 V- M' f1 }6 r - * TO CHANGE.# l* N, B2 o( o& z) j7 w9 A- l
- *3 V/ t, P$ `) I# g
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* W5 n/ L4 F4 j, T
- *
! Y9 ?. o e+ j - * This program is free software; you can redistribute it and/or9 b/ V4 h! j& T3 u% ]+ R, ^/ P% S, X
- * modify it under the terms of the GNU General Public License as
9 q- {! k8 z& R: H/ k6 w! a! V, b, V - * published by the Free Software Foundation version 2.( n8 T3 c1 q& e2 c" r
- *
- J% p2 m; O7 } T - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: b* L) `2 q6 e8 R7 M - * kind, whether express or implied; without even the implied warranty
3 x o; o6 M" P# b5 f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 D# A2 p( i; I6 w8 X6 P9 w - * GNU General Public License for more details.
# d9 B4 B2 v5 s# ^1 Z - */- V% V' d. e$ L3 t
- $ c. F: l" t; o$ ?! ~$ ^
- #include <linux/module.h>& z8 v8 f) E$ k- {
- #include <linux/init.h>, D6 @( E9 F. Q/ W0 |9 C: C# j8 p
- #include <linux/errno.h>
# ~5 K, v0 b2 C - #include <linux/types.h>
d" n. Z" ]1 Z9 M) k2 E - #include <linux/interrupt.h>4 x$ r. @) x) S2 e: I5 V4 C% b
- #include <asm/io.h>
5 o! v' M1 D I4 J/ A ?" Z - #include <linux/moduleparam.h>
6 {; Y) K9 |; y0 d) j2 I# c& L - #include <linux/sysctl.h>+ m/ z- B3 k# h* ?0 N
- #include <linux/mm.h>" l: {$ l9 |8 z4 {
- #include <linux/dma-mapping.h>
! f; [9 t" T3 s6 ^! d! k; x2 m- ?2 R - " P$ i7 a9 P8 ~9 @
- #include <mach/memory.h>
8 |9 u0 c% n+ p, R8 {2 k - #include <mach/hardware.h>
& s3 N3 y/ X5 k4 L8 k! T - #include <mach/irqs.h>5 |( Y% C1 _1 m1 w, f3 N4 A
- #include <asm/hardware/edma.h>
" J" K4 B( w1 \. g9 \" D9 r
, e# z! S0 D+ F* S- #undef EDMA3_DEBUG
7 o5 U! p9 |+ R2 a; ]! O5 @5 F7 } - /*#define EDMA3_DEBUG*/; v" e% s6 y% \! b5 a8 @0 A
0 h& o" X& M) ^1 s P% e2 r! A6 P: J- #ifdef EDMA3_DEBUG
0 U) Y" }; @8 i2 P; F - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* v5 [% g9 N w* Y5 \1 s, Q& E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" Y* d; ~7 r8 Q; ~* ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 j" |" g K& X9 z& q _# k
- #else
0 j, |) A3 _6 E; k. `1 }3 ] - #define DMA_PRINTK( x... )3 F% E; J1 f1 |1 V8 d5 q) `" f
- #define DMA_FN_IN
9 I( f% N6 Q m2 r0 z$ O3 Y; a - #define DMA_FN_OUT
: |5 k! X& V: \8 W - #endif
# ~$ D0 x. u$ G6 b$ `6 X0 C) {$ D2 q
' n( b6 j. p2 P/ N1 M9 R+ W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! n( I r$ J/ q7 H - #define STATIC_SHIFT 3( E0 P' n% n2 p& J0 g
- #define TCINTEN_SHIFT 20
' \4 R' Q' e0 `" Y" b4 v! q1 U% Z3 m: S - #define ITCINTEN_SHIFT 21
2 T8 \7 B: w5 Y - #define TCCHEN_SHIFT 222 X. j; I, G U6 v
- #define ITCCHEN_SHIFT 23
+ W, Y0 i b2 ]3 _% K7 X5 l' G) I. t
P# l$ A8 `+ S R- static volatile int irqraised1 = 0;$ \: n. _; Z- }; z& r
- static volatile int irqraised2 = 0;' ^1 s$ Y" K+ ?
- ( [' ~+ e4 t1 B1 m* l/ \3 m9 Q8 w
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 r8 B) D4 S' k& W4 m5 [. l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' m) E& b& t. K- @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 |$ ?, h' X/ T' g, s* ]9 @, e$ n - ) \+ b5 ^$ w( L+ M9 R, y
- dma_addr_t dmaphyssrc1 = 0;$ P& s* z" w# K9 i3 S4 n
- dma_addr_t dmaphyssrc2 = 0;$ C( m% R. X Y* f9 C- r
- dma_addr_t dmaphysdest1 = 0;
7 J! Z1 J; M3 B3 q& v - dma_addr_t dmaphysdest2 = 0;
$ v2 D6 T# z( R6 U* L1 O( Q& P/ `! H
4 q( r; b8 Z6 D$ s% c) v( ^- char *dmabufsrc1 = NULL;
( M# M/ {0 R/ _! F# d - char *dmabufsrc2 = NULL;9 c: ^9 d; \* ^7 q6 C4 K: B! f
- char *dmabufdest1 = NULL;
+ s) H9 G8 n- V# k' @2 X - char *dmabufdest2 = NULL;
% `$ u% P$ M1 H" E& q, |1 h, ? - , J! P! ?" j, |; l5 z# g
- static int acnt = 512;
0 O; M3 ?; d, l - static int bcnt = 8;* u; J, c' t5 F( I
- static int ccnt = 8;) y' U. a+ ~1 W; e! Y9 Z
- $ I. O7 W' ]3 F1 m Z- ^
- module_param(acnt, int, S_IRUGO);( }% | H7 V6 ^# J& |# h% L5 r
- module_param(bcnt, int, S_IRUGO);
) R0 X( I. u* L* b. \; k - module_param(ccnt, int, S_IRUGO);
复制代码
2 D" d4 n; X, e1 i7 j% ?1 @: o4 y$ Q; ^6 S) ~' }. |0 D1 O- n- Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 x& N8 M/ t P5 w3 K7 l
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: }! r4 b/ w( m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 u4 B+ U- L9 F, Y7 I* n$ a' @
6 Y1 [& `, Z& t) s* G% P6 A! Z4 w; }" d% U: }* |, Z( x
|
|