|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ R1 U2 y5 Q- Z& \
- [code]EDMA sample test application
% t6 p; K3 `& }4 n3 z, | - /*
% C/ M( `) q" k, J/ U, | - * edma_test.c, J( P/ o! P4 z0 R
- ** F4 P$ P( L/ N0 q/ J1 U) J7 v
- * brief EDMA3 Test Application
7 n$ k, h) n3 s2 ?3 y* z6 [' b - *
2 w* p) Y8 a, H - * This file contains EDMA3 Test code.
. t% a, O. S: L5 p, T3 V+ O - *# q6 o9 k h$ G; h: J' V1 R2 C5 X
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! D" X1 |0 c0 l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. w4 M& h8 p ?0 ]
- * TO CHANGE.# \9 O) [* S% [1 w$ k
- *0 ]# ~ @, V* _5 e e
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& B* p1 \" j6 }- {, g j& r - *, f8 \% Q- P' G8 A1 g/ J/ R/ E
- * This program is free software; you can redistribute it and/or
9 K! n: _6 J& \# n; x; ? - * modify it under the terms of the GNU General Public License as
: K- ~5 s9 u+ S5 Q4 L9 a$ n - * published by the Free Software Foundation version 2.5 { |6 z, r6 T5 _3 G; E2 x- V
- *0 d, [6 J! n% E2 C$ Y( |; r
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 ?6 P2 F. p; c8 u0 J$ R8 ^5 J
- * kind, whether express or implied; without even the implied warranty
& h( e2 _9 y- n! g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 A3 j4 X. h, m( L: e - * GNU General Public License for more details.9 R, i+ z' H3 _5 ~) p) ^+ m
- */' z4 k: Y& z* J s! m2 [5 L
- ; n& V. f& J. x) J9 ~; }
- #include <linux/module.h>8 L5 S8 V9 t: a/ V! a: `( a p
- #include <linux/init.h>) k9 z& A. l9 |; z. w0 v0 v4 h2 l
- #include <linux/errno.h>2 y' M8 i" |1 c. ?6 d9 M
- #include <linux/types.h>8 ]( {3 f. u2 K' }3 z7 z
- #include <linux/interrupt.h>
* |9 t0 V5 l4 i) ]5 |8 g% Y+ k - #include <asm/io.h>4 @2 ]( K( n: D5 } {. U: i9 e: C1 i' t
- #include <linux/moduleparam.h>- Y" b7 ]# P7 a) r3 w& M a
- #include <linux/sysctl.h>
- e6 L8 C! a2 f0 h0 h* a& S - #include <linux/mm.h>. ~2 e9 ~$ \' y- ]* \& U' a
- #include <linux/dma-mapping.h>
* f0 A7 o! N3 a, U4 z! J+ \3 C
0 T' i& l/ ^5 j4 B* U4 V- #include <mach/memory.h>1 I& j8 |, }; a
- #include <mach/hardware.h>
+ e, k, U* u3 |1 H( a$ X1 g - #include <mach/irqs.h>. I5 f3 o3 g" z* U( @/ i0 J
- #include <asm/hardware/edma.h>
, c4 y4 _9 w! U0 P7 J% B - . W1 p/ q# }3 i* K6 H% d: A
- #undef EDMA3_DEBUG
F/ m% c i0 }' e* u1 |6 h( n - /*#define EDMA3_DEBUG*/1 T m1 }- S8 S/ j0 o' ]
% b) i% ?* P" T! i0 N; d$ V7 g: t- #ifdef EDMA3_DEBUG5 U. _: ]! B. l1 z7 g% D
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; x6 M& z# D: S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) b) P( g8 d8 q( v
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 ~0 I1 d. p( V0 V; j2 r& B: V" j
- #else3 j. Z- I1 e& @# i2 R
- #define DMA_PRINTK( x... )& d J4 V' c% q. V8 P2 O1 m
- #define DMA_FN_IN0 [) }7 x2 S1 x! ~# ]3 |, u. A1 c
- #define DMA_FN_OUT
2 s# @1 f+ x) u, O$ `! L, e3 Q - #endif
. y Z7 t4 M, d) F; l( M8 w: V Z
5 W3 b# S' ?: B" v! _" X- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ z/ s5 ^; f$ q2 L$ E% x
- #define STATIC_SHIFT 3' ]; O5 E* g. o- t9 M
- #define TCINTEN_SHIFT 202 U" c Y1 L7 @) ?8 a4 Q; W
- #define ITCINTEN_SHIFT 21
* r7 k4 H7 k [( i6 a - #define TCCHEN_SHIFT 22
4 D2 f5 b5 L: q$ Y* @ - #define ITCCHEN_SHIFT 237 x/ }: p8 L- U
: Y! U8 |" W# F* l0 @- static volatile int irqraised1 = 0;3 ~) A( Y% A, y* V3 o
- static volatile int irqraised2 = 0;6 T) F$ [, m# [" y/ k
O; T! K8 W2 v. s6 J- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( m" x# P' a8 D - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! K: G( h9 K8 m6 ^- K1 I! q' d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 o" q1 U. ?6 U' \/ R - 0 E* @+ ?5 c/ b1 V! Y
- dma_addr_t dmaphyssrc1 = 0;- T+ c2 j. L4 u2 M: m! K
- dma_addr_t dmaphyssrc2 = 0;
- w: W4 ~1 p) f2 S3 @- t- | - dma_addr_t dmaphysdest1 = 0;
6 l5 J' ], Y" p2 Q - dma_addr_t dmaphysdest2 = 0;
4 D. v/ p" q4 P |$ P+ a1 r. h# d) R - : k0 y7 j) z6 }" N C: G
- char *dmabufsrc1 = NULL;
- z; R- q0 p9 [ - char *dmabufsrc2 = NULL;
, D, A. L: h, v0 i' } - char *dmabufdest1 = NULL; t& s" v# i4 e8 W; l$ p- c+ A
- char *dmabufdest2 = NULL;
- R c8 K: L) H2 s. M, M% A
7 b4 Y9 _4 K# t- static int acnt = 512;) c; Q$ l5 a- C% i# [, L7 f% M0 k
- static int bcnt = 8;4 B& D4 r1 S h: ?' ~
- static int ccnt = 8;
# { K+ s+ S0 _ N. `. w0 D - 4 s) W# w8 L) A
- module_param(acnt, int, S_IRUGO);
! R6 W% w8 T# F | - module_param(bcnt, int, S_IRUGO);. X. O7 a n- l' S1 E) @
- module_param(ccnt, int, S_IRUGO);
复制代码 & @# p& n; m* e7 F, J
/ V% s3 t5 Y5 K
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( F D/ x5 d M0 Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# n9 b/ O$ h. P) l$ K( b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ } d" A9 B; V9 o
1 \* l5 s5 e% @5 W& o& L! ]/ u* g3 o. o$ z. R2 t! z
|
|