|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . u) D/ i1 Q. t
- [code]EDMA sample test application
4 q4 @9 V1 P4 p( C$ R - /*
, x& F5 B% q4 G1 S" l - * edma_test.c
" h0 |/ O, I. I' S! `: D - *
# Z$ P6 q# O# D+ f& @! d - * brief EDMA3 Test Application' M8 e* A5 _9 y/ v/ ]; x0 b* F
- *
& S4 u; V; m6 i - * This file contains EDMA3 Test code.1 y3 O( u- `, P& ^
- *1 N; I, C: Y* i4 E% o* d/ ?
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 @% R8 c( }, E' G$ u" T! t/ l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, W$ \& f$ `" {5 Q2 ^* d$ D
- * TO CHANGE.
# w/ X( G8 c$ z& e: V" {; Q - *
) R* U' R& e: v6 c, s5 b- U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- {" l u' {- \4 \8 Q2 i4 j
- *0 A. Q1 E5 n! N* c
- * This program is free software; you can redistribute it and/or, b9 l/ `2 a5 z7 t0 B
- * modify it under the terms of the GNU General Public License as: D# c4 u4 g. O* L) `3 s
- * published by the Free Software Foundation version 2.. y5 x" [4 ^6 Z
- *
$ g" d, P% w8 S, Z) T - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) P. x) L2 { c- x- d - * kind, whether express or implied; without even the implied warranty
1 e8 d2 Z. H, ]4 W& @* E7 o: j - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, P2 K7 M- H: n" Q& ]4 k - * GNU General Public License for more details.
, u2 X# z1 c' n! u+ ?' T' p3 B - */. H. X4 \( X t3 { f
- , u- l/ w: e0 C! x3 i! \/ A" q( Z
- #include <linux/module.h>) S& q9 T0 O4 B: _6 I
- #include <linux/init.h>
# z9 M" p6 k& _. S% [ - #include <linux/errno.h>
% A t! ^9 P+ E) ` U8 E" w - #include <linux/types.h>; r& | y& |, t% W8 w
- #include <linux/interrupt.h>
. w! P- A% N* b3 @. U/ N# j - #include <asm/io.h>) d! B& B' U* V7 Y# H5 Y: F
- #include <linux/moduleparam.h>
; F: K7 v% W7 d* y: c - #include <linux/sysctl.h>/ F" K+ [' x( @; X+ C9 f
- #include <linux/mm.h>
- U- L; x( a: l' L- i, h" i - #include <linux/dma-mapping.h>
2 R" [- ?: `- V - . I7 H+ ]' h8 t
- #include <mach/memory.h>: x* V, u4 o; o9 V
- #include <mach/hardware.h>
1 R0 z5 l, a9 S/ `) p: `5 G4 e - #include <mach/irqs.h>
5 X& p1 _1 c0 L% q" U% X" K! J" j - #include <asm/hardware/edma.h>* W; L! S6 b4 Z8 E( C
- $ W. l7 j4 i1 u/ A8 J) T( U; i
- #undef EDMA3_DEBUG
: f/ A: |, |6 C( Q6 p+ G8 } - /*#define EDMA3_DEBUG*/
0 X7 d) z( [. P% L: _# r
1 K$ U% \) h& C+ A- #ifdef EDMA3_DEBUG6 Z' I5 J8 L- m1 Y9 D1 a2 b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 J! }5 N2 M- G2 ~6 c5 Y. z& \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* f5 k" m5 x' u- Q( f3 n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& i! W, I+ e$ D( s& G6 ^# h7 V
- #else
, A c q( c2 T5 ?" Z6 P& X, P - #define DMA_PRINTK( x... )2 Y, d5 @6 A* R% _/ M* z& I
- #define DMA_FN_IN
$ `& d `! | |; ~1 [ - #define DMA_FN_OUT9 s# X# g) F; k; l1 L V9 ^( t
- #endif4 I9 D: j6 r- S( s/ S* p( L U
4 i; U; b" k9 }6 M- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 Z" L/ {6 K9 U. I - #define STATIC_SHIFT 33 t" ^, i; w/ \4 ]7 m4 m" r+ ?- G
- #define TCINTEN_SHIFT 20
0 w, H" t e0 I" V5 s/ h* | - #define ITCINTEN_SHIFT 21
2 U# j A. e( I0 r2 w - #define TCCHEN_SHIFT 22' b+ ]& J5 M% W: g9 {9 ^" f v
- #define ITCCHEN_SHIFT 23- @# s5 H& D/ }& k. {7 f
- ( J: X: a4 K- T1 ^( b6 e( ^+ E7 ?
- static volatile int irqraised1 = 0;. s- R/ M, W N* [1 \; i' Y
- static volatile int irqraised2 = 0;0 Z( m/ \- v4 f/ q# [. D
9 t' `" }! q, h2 T7 C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 z- V! `3 P/ t- b0 b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 l {8 [5 @% G/ @
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# F; l( D) W6 g0 q
7 h- u0 m. I& ~9 j* L$ J y: }9 z3 Z- dma_addr_t dmaphyssrc1 = 0;
# h+ h( }9 p; p- }; i1 ] - dma_addr_t dmaphyssrc2 = 0;
. f9 V! n: ^% u7 | - dma_addr_t dmaphysdest1 = 0;9 _% I) f" \/ o! b, I
- dma_addr_t dmaphysdest2 = 0;
" t! i' M a6 F2 {* M/ }5 o
8 ]- i# n& _: }- char *dmabufsrc1 = NULL;4 }0 i, |6 O9 e: s( w
- char *dmabufsrc2 = NULL;
% F% d$ [: X7 f F& a - char *dmabufdest1 = NULL;
: \1 U8 A# ]4 ]) i0 [6 }! n& y+ s - char *dmabufdest2 = NULL;( c8 c7 y- Z' U& G2 d# M8 e8 Q
3 W( w9 H1 r. c( f7 F5 v- static int acnt = 512;
7 h) R ]( `* C" ^2 D - static int bcnt = 8;; O6 \' c) p# @: K o0 H! r+ G
- static int ccnt = 8;
* J9 K9 S7 K+ Y6 b" Q
6 ?. a6 h, H7 o- module_param(acnt, int, S_IRUGO);2 |9 R3 e% x+ e: g9 T
- module_param(bcnt, int, S_IRUGO);$ d% ~/ C+ X$ T. s( B8 Y
- module_param(ccnt, int, S_IRUGO);
复制代码 & B: n4 ?* k7 d' ]- S
7 f. y) |$ X1 P' x. C/ X- ?) z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! J6 Q9 b& {/ E' n8 W7 V0 A) xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) X+ _$ ]6 ^1 V$ |
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: f! o; t3 s! o
8 S$ F8 K. R, m o
6 x0 N) T# l. O% I
|
|