|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& ~& k! Y+ Y7 E7 G6 d6 P4 A0 M- [code]EDMA sample test application
$ X+ U8 T2 n! N: } - /*6 l& f. `' k; R; b
- * edma_test.c& z' x8 {) b- X/ x' i3 F
- *, @- k6 |2 n& b. C* t
- * brief EDMA3 Test Application
4 G7 l3 B' g, o$ |! b% i - *2 @( v6 g7 s2 y- S5 b
- * This file contains EDMA3 Test code./ T. a6 G6 Y, X: G) F6 h
- *
$ J) ?2 P; |: h0 o) f4 m. L - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. Q( g. x8 S$ \: k g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ T# r I- S6 G( O) l3 z7 v
- * TO CHANGE.$ Y1 i* W7 }3 L' J, ~, j( [
- *
3 R' R$ i$ n S - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ N( ^8 f# q& [0 Z; d - *: R" H/ O( i% U- \% U
- * This program is free software; you can redistribute it and/or' {2 m7 Y$ U& a+ j, y, s, R$ v. X" v
- * modify it under the terms of the GNU General Public License as3 B R& y& I& n& i& R3 C6 r5 D
- * published by the Free Software Foundation version 2.2 P6 ?" {/ m2 I9 t# _6 @
- *
7 V0 {& }% ?4 L- l! } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' F% K. Q8 G+ t# q/ L; X
- * kind, whether express or implied; without even the implied warranty8 i" q% P! K+ L$ x. D( s
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 O' q5 D" I& [5 c0 ^) q' A
- * GNU General Public License for more details.
! ~2 G; d( ?% J: v - */
& {# D4 l& L K9 T1 T
8 ]4 s1 s. p, t d- #include <linux/module.h>
! A- [0 k4 y9 n0 k+ p+ Y - #include <linux/init.h>7 ~' N, E1 h$ K) i
- #include <linux/errno.h>
4 C }3 N1 k$ e' l* @5 l! @& I - #include <linux/types.h>; E7 s% ^% t7 O5 r1 x" E+ d9 ~
- #include <linux/interrupt.h>
; E8 `2 w" T0 y( o - #include <asm/io.h>/ w0 }3 b8 l+ W- e1 n# A
- #include <linux/moduleparam.h>% n+ l. @, d; i( p5 P- Z
- #include <linux/sysctl.h>
( N1 h1 u5 J/ q. R7 W( f6 w - #include <linux/mm.h>
5 M; K2 \/ X, h- n - #include <linux/dma-mapping.h>
$ Z, s- R- T: `+ X6 x
& u9 z+ ?3 r% @! X: [% x3 n% a- #include <mach/memory.h>- {! ^5 {# }+ l; b
- #include <mach/hardware.h>
+ M- `( @* u/ k. j; ?# I - #include <mach/irqs.h>. G" N6 E. c9 {% {
- #include <asm/hardware/edma.h>* ~$ |3 s, T2 Y6 M5 j; |1 E! G
- + P) { n5 c0 t* E8 q% t
- #undef EDMA3_DEBUG- V$ E: n; x5 l0 |/ l
- /*#define EDMA3_DEBUG*/
& z# ~( N* u% Z
9 R& P- m3 E a! u+ v- #ifdef EDMA3_DEBUG F% \; ]0 F* h p- c& f
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 u& I# j; N# Y) C" T% M5 v9 O$ d
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. M, h5 C4 m! Q* X+ d5 _ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) _- Q3 t' }8 n( c( {; t
- #else* H; c, s* @' i7 E }6 x) c
- #define DMA_PRINTK( x... )# s8 g8 m& F1 O+ k
- #define DMA_FN_IN
" b2 P; v! n3 a - #define DMA_FN_OUT5 K3 {% `6 G+ f5 M- K: i0 j
- #endif( w% o# r; K/ |) O: ~5 x
- ' d- x5 V H }- i+ L
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 [( q2 T+ U! k% T8 H4 G0 A
- #define STATIC_SHIFT 3( q8 N2 `7 k) C( U8 e* s
- #define TCINTEN_SHIFT 20) B3 o% E$ f7 M `# {9 P" b
- #define ITCINTEN_SHIFT 21
( [/ V: y8 P2 i - #define TCCHEN_SHIFT 22
( p% A5 T( x' d' l1 C - #define ITCCHEN_SHIFT 238 J/ j* @" h, i B
; M4 Q# `) c9 O6 g- i4 G" a; }- static volatile int irqraised1 = 0;
6 G) b% w: |) _% G" R - static volatile int irqraised2 = 0;+ ~, i E6 c* z- L o Z
, b* h& g* j1 A3 c2 v* ~- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% ]6 J$ e& q& M R( j9 f- O: X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% `, M; b2 G* l5 f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 l5 z) I3 l& n0 l/ k) Q( Q
# e; c8 X' |2 ?# n- dma_addr_t dmaphyssrc1 = 0;
7 p- J. r/ E( b - dma_addr_t dmaphyssrc2 = 0;. }5 K9 \8 E$ N/ s, L
- dma_addr_t dmaphysdest1 = 0;
+ u) K$ h% ]4 O - dma_addr_t dmaphysdest2 = 0;" F, N4 i1 F4 y1 W: H0 s
5 }6 S8 ]5 ` I8 b, \4 b- char *dmabufsrc1 = NULL;) I2 Z* R, N- v" ^6 B9 x9 I: a6 b0 j" L5 e
- char *dmabufsrc2 = NULL;/ I3 ]9 u T% p5 K
- char *dmabufdest1 = NULL;) g* p5 `! s4 R5 W! p- A
- char *dmabufdest2 = NULL;
% [( e0 Z5 d. o# ~$ `1 r - + {3 {( U7 |' |7 x& [8 z
- static int acnt = 512;0 P3 E5 w, ~$ y! n" |
- static int bcnt = 8;8 ]. q' b0 \; T' m% j( w: s/ s
- static int ccnt = 8;
9 h0 |% R7 q5 V$ o) @: H% Z. o7 j - " q( D1 }! O! ]2 k9 Q& r
- module_param(acnt, int, S_IRUGO);" w7 E2 Q/ l K, ^2 y
- module_param(bcnt, int, S_IRUGO);
& O; j8 L9 E! u- s$ o V - module_param(ccnt, int, S_IRUGO);
复制代码
0 i5 g) P3 v$ _9 k2 w, g$ _) B2 `+ m+ D6 \! `! {5 z: E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 @ H7 x. S, E- Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& h5 V7 _% y) A+ \& G6 A2 S$ i 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( L* D% ]8 e5 C" V$ p+ M% I5 C
3 ^9 a R: q- ?' Q! k* ^
2 ` U" @* {; j& C% c0 l* T8 F |
|