|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 m" g& C0 F; r ~- [code]EDMA sample test application% {9 _4 N* F- [, g) ~; K$ W
- /*
7 u9 z& y+ u# d: X4 |# g3 {7 u - * edma_test.c
- x$ C% v+ s' j5 o5 ^$ w7 R9 K - *
: |3 ?9 ]0 Z3 I- O6 [ - * brief EDMA3 Test Application
5 a, M* V( ^( i0 @ - *" q; d) g/ n; k3 |
- * This file contains EDMA3 Test code.
0 \7 ]- T! `* ?" N- A - *
- m0 u# ^; D8 |& e* H+ I - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" P/ G+ D1 Y0 x& z1 \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 f1 `" F$ m# L" X
- * TO CHANGE.
( D& Q' t: p2 s - *+ C& [5 W r5 M9 {7 O
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# }' T& p( o' m2 D; I; V5 [! V
- *$ u8 V2 v; t# }2 _" h! a
- * This program is free software; you can redistribute it and/or1 B% y9 H: ~- s& S0 r) l3 @ ]# A
- * modify it under the terms of the GNU General Public License as6 F$ Y' n8 k/ Y: ~; Q
- * published by the Free Software Foundation version 2.) ]% ?8 m, @8 E) W7 c6 F2 g
- *
7 O$ d( h% `) C, U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; ^: z! P O5 V$ U - * kind, whether express or implied; without even the implied warranty+ P \' E6 |' R" z: I, d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 m! s O) g) _7 T% {, N9 ~
- * GNU General Public License for more details.
0 |$ r& b* _8 F5 M5 ~ - */
- {8 p! t9 U6 s) d# {$ f: [ - 7 R# o9 v6 D/ A/ \
- #include <linux/module.h>
- Q3 F/ N, p" K7 ~ - #include <linux/init.h>
" \$ p. X0 c3 H+ G$ b- D+ Q( W/ l - #include <linux/errno.h>
$ S$ n* c: l h& R - #include <linux/types.h>
9 t1 B/ i" W D/ c9 W - #include <linux/interrupt.h>
. S$ E' k+ g/ G2 l# w3 J - #include <asm/io.h>" T0 _6 B! O! a1 v1 d
- #include <linux/moduleparam.h>
: ]2 t, h# q; t8 |) \ - #include <linux/sysctl.h>) [/ e% i9 f3 y- @- }% y- s
- #include <linux/mm.h>; {+ Q) N5 x2 p# U6 |0 {
- #include <linux/dma-mapping.h>1 h. s9 J" Q' H, ^! ?& C
" p% n: L" U: Z S }, H1 g. N- #include <mach/memory.h>6 w+ t- D7 G, n4 ], [
- #include <mach/hardware.h>
0 ~# \( [9 b6 W3 P - #include <mach/irqs.h>
7 q/ v1 S0 \5 w! { - #include <asm/hardware/edma.h>* C3 z; ~6 D6 {$ f) x5 S
- - I$ }. I) G; |6 ?# o
- #undef EDMA3_DEBUG
& h5 b& N2 _8 }. i - /*#define EDMA3_DEBUG*/) x4 J7 \, d U$ d2 E8 S9 s9 e! o6 C
- # X& `0 B2 P* Q* Q8 R: i" i! i. l5 M
- #ifdef EDMA3_DEBUG
% O" B: \* [, b/ r6 C ?6 b - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 O2 y6 X8 i. C! R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* |' q9 A5 E2 X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( k* W" J; l7 m' v. r9 S
- #else
6 B* x' P- ^5 G& K+ V. B* L' f8 ~ - #define DMA_PRINTK( x... )
% I' _/ U( _- D) j( f - #define DMA_FN_IN
# k+ |0 V+ h" [ - #define DMA_FN_OUT
. P+ }/ x, W+ R* z5 a3 S& u - #endif
3 e. T' R( p5 m( s1 ?
3 [$ [' J* ]% L/ v+ v1 Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ e' F3 ~+ f6 |2 e& P& m# \2 p8 g - #define STATIC_SHIFT 3
( T8 C4 i1 b( j - #define TCINTEN_SHIFT 20
, D, d/ n( Q, A% G5 \% }! \. P - #define ITCINTEN_SHIFT 21
" b; e8 }, X# N5 b6 m4 `. X - #define TCCHEN_SHIFT 22$ w4 O1 ?( e0 c
- #define ITCCHEN_SHIFT 236 _; h3 _& S4 J2 s+ J& p8 S. O
. p$ D, C! S: C; W) w+ w- static volatile int irqraised1 = 0;, U: V4 N6 R$ k% g
- static volatile int irqraised2 = 0;
( B2 }. |2 u' Q, J) h - % ^$ E/ \/ Y# s% J% H: O2 ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; d1 ^9 C$ X! j, l6 ?1 B- f7 r; z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. \! m0 X# R! m# ?) G - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 |" e% O& t2 F2 Y% O - ) |* i$ k: b5 o! X9 u
- dma_addr_t dmaphyssrc1 = 0;
2 ]( E# U! [3 H - dma_addr_t dmaphyssrc2 = 0;
* R1 B8 U! }9 U - dma_addr_t dmaphysdest1 = 0;
5 I2 k9 K) ~4 T( I! M! b/ ~ - dma_addr_t dmaphysdest2 = 0;
/ f4 h% j- U% ]" k) A - 3 x7 y, y) Z- c2 z ~
- char *dmabufsrc1 = NULL;
) B1 H' \) p7 Q; G, Z - char *dmabufsrc2 = NULL;! j7 r+ ~6 b" B9 W& Z3 ]; d _
- char *dmabufdest1 = NULL;
, C2 `+ X3 Z( K - char *dmabufdest2 = NULL;
3 j# a0 w5 G$ z. l: V6 i* c. r - / }& C) ]/ L) \2 m: r5 Y5 ^1 k
- static int acnt = 512;& ?) v" K+ D0 Z8 }6 L7 R6 f
- static int bcnt = 8;
/ {6 J2 B+ D9 c& x: U- Y3 @9 z, F$ | - static int ccnt = 8;2 {& o( j8 Y7 `6 p2 _) y7 s7 t3 S
, p# d! ]& K' I- module_param(acnt, int, S_IRUGO);
2 H+ _; k/ g4 _ | - module_param(bcnt, int, S_IRUGO);& Z; O8 F+ h2 s/ U
- module_param(ccnt, int, S_IRUGO);
复制代码
0 M3 p$ M* t% C4 C' i8 P9 s2 c) X+ h% ]- |! j
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 l3 p8 h: D( P4 Z Darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 w: y3 {2 y! ]" _! W+ A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( Y* ? ]8 s' h% Y: E- ]1 Z% B
8 k6 j6 ~% |' q* h
! v) _, ^. T! y; i/ Z |
|