|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 {) X2 l, _7 O7 z% l; K: p3 ^ W) R
- [code]EDMA sample test application, G3 F2 E& l. M3 O( j; w; S6 `
- /*
$ q- p$ X4 X3 E& s% u3 ~ j - * edma_test.c
0 W; O6 \% O) g - *
& S" S* N* h2 i: O1 ?6 u - * brief EDMA3 Test Application
g3 [ K7 e; |% r - *
! X) L6 ~5 C' A: p" Y k9 @. [ - * This file contains EDMA3 Test code.5 J$ D* P6 q' _: f+ B
- * a6 ]# |% i9 U" m: o
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 A* j4 n6 B6 D) j6 i
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" a" S2 H3 }' q" Y! g - * TO CHANGE.
9 }) V' M$ _' r: V - *- W+ J% R- F) E; s6 S
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ A( C. I7 }* x& j1 V - *- g/ k, [( f0 ^+ e, [
- * This program is free software; you can redistribute it and/or9 s! J: ` g( G8 k
- * modify it under the terms of the GNU General Public License as
* i* u4 V7 h- c2 t( N - * published by the Free Software Foundation version 2.
1 }6 E1 A- a4 Q$ S - *
. n+ C* H$ q4 j7 f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 Z* E2 u- o5 R H5 n3 _: c+ a I - * kind, whether express or implied; without even the implied warranty% ]/ P$ e+ W. D% i- N7 I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; B* l/ m' {/ m9 T8 c% ]
- * GNU General Public License for more details.( ]) x9 I, M/ f/ m8 \" J% ]$ b
- */
: J4 E/ j5 T& E, O7 v; n: P# x; v0 i7 H - 1 W8 u' k6 a4 f0 F" |+ E0 ^: B
- #include <linux/module.h>, |, H5 T: w& L+ o" i
- #include <linux/init.h>
% ~, K7 X( B3 i7 f - #include <linux/errno.h>
$ M' A, b* f5 A4 N - #include <linux/types.h>
8 e7 s8 W( R, f) [ @ - #include <linux/interrupt.h>$ q; F6 X' f% m( V& ~
- #include <asm/io.h>0 L! k, T1 g, a9 {9 a' W N$ g
- #include <linux/moduleparam.h>; G6 u( X0 @' |8 |+ N' r
- #include <linux/sysctl.h>0 f0 q" Y! Q+ A& V6 K0 O9 g
- #include <linux/mm.h>8 J7 R5 B) ^5 K. }
- #include <linux/dma-mapping.h>1 B; y3 k- B3 N& t) a5 v& O
& T7 s+ l5 t: k. M( s- #include <mach/memory.h>
[! X9 V$ S) X6 R0 { - #include <mach/hardware.h>5 b' I/ Y9 a6 X: ?5 I+ D
- #include <mach/irqs.h>
0 L3 `, y; s5 v9 `4 p0 J/ d - #include <asm/hardware/edma.h>& e- a4 F( f& _/ o) F
- 8 ~4 [8 Q/ }7 o: D8 Z7 Q0 q
- #undef EDMA3_DEBUG
. x8 [1 G# f; M# e3 p - /*#define EDMA3_DEBUG*/; W8 M6 ^ c" `" Y( ~. r0 L
: e, B3 H: @/ v# ?" v4 y9 g- #ifdef EDMA3_DEBUG1 M% L$ l7 y5 V/ i6 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 u! R' q, D' ?8 J: W2 J; F: t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 `! d- b9 d; f' f. l
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 T; n2 x0 K& y
- #else
7 s6 c2 y( I& w4 t/ l - #define DMA_PRINTK( x... )6 @: }, [, K2 W2 i d
- #define DMA_FN_IN' O. I. ~- Y: K% j+ B
- #define DMA_FN_OUT, @7 A7 u, a; X. J- Y
- #endif: U- L6 K7 }+ u9 R' O% M
- ~" a H3 j1 T# U3 c' {- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 S$ _5 f- A* }7 e1 y - #define STATIC_SHIFT 3
# X1 i; S* H. J; {( l - #define TCINTEN_SHIFT 20
) q i4 N: }- ~ - #define ITCINTEN_SHIFT 21
( h+ F( B) q5 K - #define TCCHEN_SHIFT 22
) R! |& g3 D) }; _+ E1 ?, O - #define ITCCHEN_SHIFT 23
+ Y' d9 J4 I v$ X3 P - & X; v- S; @) b- z: `1 @/ P$ K
- static volatile int irqraised1 = 0;
" [3 O5 }9 P% U2 O' u7 n8 j; D/ V& s7 n6 h - static volatile int irqraised2 = 0;" c1 _4 ~# E K& A0 e1 a6 W
2 S# t2 P0 t% I9 @8 A7 \- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 i5 ^3 a' A/ r. D5 L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 P/ }# P6 c4 W% D& M- ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 b4 b! ^/ ]. q) [% x7 C; f* n - ; v1 A4 u" x2 V
- dma_addr_t dmaphyssrc1 = 0;$ a% W& Q& c* A' P5 V
- dma_addr_t dmaphyssrc2 = 0;
. |) H1 l+ o1 V; j, c4 f2 g) Y - dma_addr_t dmaphysdest1 = 0;9 E6 m. Z$ h9 H7 G1 P* B
- dma_addr_t dmaphysdest2 = 0;' ]8 q9 y5 G1 L; T) U) H6 o
- : L3 B- x: X1 w. n
- char *dmabufsrc1 = NULL;
) [. P: U6 m# j" u' |+ c6 X - char *dmabufsrc2 = NULL;
8 d6 q2 Q1 E& p. H/ [7 n4 Q - char *dmabufdest1 = NULL;
( T) d9 B' J, v+ Q' S6 O$ \% \: c z - char *dmabufdest2 = NULL;# d6 H! u8 L5 K
' T* U5 S' b! X0 {( t- static int acnt = 512;
6 X/ [+ E" L* v6 _8 J0 J - static int bcnt = 8;4 E+ n& @5 I# d1 x
- static int ccnt = 8;2 I' F! o' Q3 S. H! u
8 x8 o; V* }" }% U4 u) ]5 v- module_param(acnt, int, S_IRUGO);- [1 N0 m. c" T* K9 z! C: Y" Z4 ~" @
- module_param(bcnt, int, S_IRUGO);9 c4 R7 K, H6 j. s) v
- module_param(ccnt, int, S_IRUGO);
复制代码 / E3 I' s' f* E0 U4 H
: t: o2 V/ R3 F. x
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) ~/ C2 S$ G& L# z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
1 v* o2 u+ T- D( X1 U* l 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; u' N+ i7 b: b
7 c$ F4 n' q2 V3 _9 i9 r6 i/ q3 w) k3 H$ R) h- F
|
|