|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 ^( i( b$ W& q0 }
- [code]EDMA sample test application
, Z7 m* r4 `7 c' I: X% Z - /*7 \+ b+ A$ y" g8 n! S& M
- * edma_test.c
+ e. B3 k1 }. C ? - *
1 _9 y0 z0 t; }. O" j7 ^ - * brief EDMA3 Test Application# H6 I8 }/ q! L4 W
- *
+ k) g" |9 p U: L/ }% S2 v c( t' b - * This file contains EDMA3 Test code.; s- W2 c" x; u# t
- *
& i* G$ o7 I9 u6 H8 y9 k - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' e" |1 p) D; n% P8 {6 f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 c! X. c" l( q( @: Z - * TO CHANGE.
7 z3 F P8 L, h/ i; d - *! o! R6 U: X U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% c3 @+ T( H2 `$ h# D# r6 w - *$ }0 o9 n7 ?: b# K, I* U( C
- * This program is free software; you can redistribute it and/or
# c6 {6 m& v; @; f - * modify it under the terms of the GNU General Public License as
7 X8 I" n6 B' i6 F0 O( @ - * published by the Free Software Foundation version 2.1 K- g) j4 _ D; Y# p2 Q% s
- *
* B* x+ U$ M4 \- o6 u' s9 T$ f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. ` ]& r0 w: S6 u( U* J - * kind, whether express or implied; without even the implied warranty8 P; Y" G4 s: \- a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" a' z. o: o" }% a, o
- * GNU General Public License for more details.
1 S& z" l1 Q3 U - */
4 q5 @6 R& k0 M3 A k1 E+ n - - y) ?- c w. Q" D0 j: V, L! n
- #include <linux/module.h>7 ]0 \9 ?; n& _6 |# S
- #include <linux/init.h>* E0 r5 R/ B. G5 W
- #include <linux/errno.h>
' l$ h# A0 x0 ^ - #include <linux/types.h>
7 w: R# c: D& A! R - #include <linux/interrupt.h>( ?% P) c! U" H7 Y( H) ]" k, V. N
- #include <asm/io.h>
) x$ R* v4 I% c2 F1 t - #include <linux/moduleparam.h>8 c: N; ~2 I3 G2 ?6 Y
- #include <linux/sysctl.h>
4 X) u! ]5 K* E0 N8 Y - #include <linux/mm.h>; {7 r9 U3 v; i, ^* x- V) h
- #include <linux/dma-mapping.h>" s/ y- e( `! I: ?. j4 J
! f. N) |5 C; o: Y$ |/ U1 P( Q- #include <mach/memory.h>. G' }5 `+ I, i
- #include <mach/hardware.h>
3 q3 ~/ N! }1 G7 K& j+ K( o - #include <mach/irqs.h>& S. X; ^$ _* G5 A; j
- #include <asm/hardware/edma.h>+ x$ s2 Z$ ]' E
- " n" D! y) p. ?% L: H( z
- #undef EDMA3_DEBUG
0 k8 A- L" g' f' T9 J0 [9 g2 I - /*#define EDMA3_DEBUG*/
/ o! E. Q1 F1 J - # U- b8 B% `) t# w
- #ifdef EDMA3_DEBUG
r: R) g4 P& F1 m) O - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% k7 r' B# a: G4 U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 Y3 L) T# O( f# ^ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 z8 o! ]5 A( ~$ ]* ^0 q - #else2 Z% M l4 m R. `' m: L4 K: {( W
- #define DMA_PRINTK( x... )" w. D' n1 c" u n! H
- #define DMA_FN_IN
& I; a. i; F" t7 K ~$ a3 N - #define DMA_FN_OUT
, b, \# N* R4 R1 } - #endif
7 O/ w, U6 b' V* @; p7 E0 C" W - 7 c! K/ `& d. n# B, V: Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: ]+ F1 O& ?: Y7 O* U - #define STATIC_SHIFT 3
) \2 M' C8 ]' {9 A; n0 {; C# W; o4 _ - #define TCINTEN_SHIFT 20
1 t6 U" J0 X1 H - #define ITCINTEN_SHIFT 21
! K7 G0 v. }( D7 t3 b( i - #define TCCHEN_SHIFT 223 B# ~2 [- S8 T! ^( n
- #define ITCCHEN_SHIFT 23
1 m; P7 h9 m; U) b! H4 p m4 f - ) w, Z: `& Q' f, P1 O9 e
- static volatile int irqraised1 = 0;
5 L: {& k6 P; B' U, z* j - static volatile int irqraised2 = 0;
9 _ _4 q" n* j) l7 F( D2 _
1 c1 q8 W$ `/ [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
L0 l) a- Z1 g - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% `1 k0 @" J; l3 D. L0 y7 M
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- t1 p$ Y+ V5 a- J @& P
' o, |. g* \, S8 w- dma_addr_t dmaphyssrc1 = 0;; ]0 t. u3 `* ^4 d
- dma_addr_t dmaphyssrc2 = 0;
) C& l' N5 d! J4 a/ q - dma_addr_t dmaphysdest1 = 0;1 e" o7 G" R/ d6 l8 k8 I) q
- dma_addr_t dmaphysdest2 = 0;' U! o$ I8 o9 u. P4 V
- # ^% l1 ~0 u u
- char *dmabufsrc1 = NULL;
) m' A/ Q8 V0 ^$ C# K - char *dmabufsrc2 = NULL;
) y; |2 W0 h* M( t- e3 a" D - char *dmabufdest1 = NULL;* [4 V' I9 E7 v$ K# B$ g
- char *dmabufdest2 = NULL;
' I l5 G. y8 g. m: \! H
$ X2 o* s3 \8 a/ x) M- static int acnt = 512;- w, |. `4 `* t% k. [
- static int bcnt = 8;
% ^# R% A2 q0 @! S& n, W0 R - static int ccnt = 8;) C% [3 Z( B7 N; H+ `% X4 f
- / X; D" k# S( d: Q4 Y. N' o
- module_param(acnt, int, S_IRUGO);
. p" @3 E- r; x. G7 S2 A. k - module_param(bcnt, int, S_IRUGO);
8 H2 e" |! S/ t i. i2 h7 z - module_param(ccnt, int, S_IRUGO);
复制代码 2 O9 D9 u2 x! y6 O( _$ I5 g& M0 b2 D
) X- Y0 ~4 U3 L" O3 ~ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: P; t9 \/ {# p. x
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; ~' F& U* H5 x) W5 j3 r& @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ [' P$ `2 ]& Q; \7 j
3 y+ J7 X0 L! H( y# t7 @" j0 x( O4 v- e2 M* r: ]7 v% q' ^6 W! ]( m9 B, z
|
|