|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' W! E/ R0 ]) a+ R3 j- [code]EDMA sample test application0 Y* F4 v6 J3 r* i. q
- /*
" K$ Z' S S6 o. t8 n6 M - * edma_test.c
( W. ]! X/ f. x- x. ~! o - *. [, l$ E, @: r
- * brief EDMA3 Test Application
, p4 ?4 Y/ f. R" q2 S8 h - *. s7 t! U! a: r: H& _) ]5 ^" P
- * This file contains EDMA3 Test code.
5 C& l: P- ^* o* P - *& S' P+ s" N2 O8 q+ U# F
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) Y, H7 \: A8 i2 {! ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- `+ W5 p7 l; |; t8 V' q - * TO CHANGE.
* i; p0 f( g2 R; T n. A3 v0 c" @5 e - *
8 x" s& B4 v) V8 a! d- m8 n9 l - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 z& l# a' |; K& l( d
- *
@7 b# S* P$ \& t - * This program is free software; you can redistribute it and/or1 a3 X1 j7 _: g* s R) ~9 G [
- * modify it under the terms of the GNU General Public License as
8 ^0 C9 g. G( ~3 s1 X - * published by the Free Software Foundation version 2.
( W m# e1 ^3 ^+ P$ ]8 O - *
$ P* ?9 M3 C3 l( [/ S- ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& R- H; N) T$ H - * kind, whether express or implied; without even the implied warranty; L _5 `& t% s# y0 r% q/ R) B+ j3 Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 P% u; O% T- }: A% ~" V
- * GNU General Public License for more details.3 D5 u2 s( @9 s0 M$ J( f1 y
- */* L$ L! F3 q3 z/ Q" F6 `8 f
- 0 [# [4 r' c' o' q9 x
- #include <linux/module.h>9 f6 T9 ?. X$ K9 U% z
- #include <linux/init.h>: Y5 j0 J( y. a+ z. S+ K4 u! j
- #include <linux/errno.h>
* @* r7 q/ M; b- i% J - #include <linux/types.h>
2 D9 a; T7 @# k5 l3 S - #include <linux/interrupt.h>
. ?9 X! l( K. d2 X1 `$ a - #include <asm/io.h>
z6 Y8 t8 E. ?9 M" N - #include <linux/moduleparam.h>! W% Q6 b+ P. K
- #include <linux/sysctl.h>9 x- x" J. R. { c: X ^
- #include <linux/mm.h>$ Q; c$ r; w2 H, I$ y5 Y. W
- #include <linux/dma-mapping.h>
2 q; B1 K- r: p2 w$ o6 n) a4 Z
0 N! \6 ^* `5 E( t8 p6 I- #include <mach/memory.h>+ E; _" z; q6 g0 g( B0 l
- #include <mach/hardware.h> w) F' d; M. I& P) z2 `) M+ Y
- #include <mach/irqs.h>, L- r) f. s. h3 `
- #include <asm/hardware/edma.h>
4 v' N- D6 [( n" h& `# z, M8 G# K
$ ? R/ A7 s+ L5 n: o. N9 ^. J- #undef EDMA3_DEBUG7 Z0 K7 G! D' H% X/ P8 S9 H
- /*#define EDMA3_DEBUG*/
" z# o/ k6 O' O9 i4 j* P% Q0 F5 T - 0 H* `& Q4 |, U) e" t Q# x
- #ifdef EDMA3_DEBUG
- h6 M6 ]0 G0 I+ k" F* `* T9 ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ x% C i, z5 [4 s5 ~ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
y, w/ x7 n& e3 i$ N - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). [; ~) J0 L( s
- #else. `2 `) ^5 Q' v, l1 H% a9 F$ @ x
- #define DMA_PRINTK( x... )1 S" A( g, ?2 |+ Z8 _+ Z
- #define DMA_FN_IN
4 e, J: F: D2 O' i - #define DMA_FN_OUT
. H- A( g( V; Z- i: Y - #endif: _- `2 a3 _- F; z
- & I! |' y7 E: T4 N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 _7 E, _4 k( ~* o* F" D, X
- #define STATIC_SHIFT 3
# Q5 @9 ]3 \; O; b9 B9 U: T - #define TCINTEN_SHIFT 20
. s F/ ?( l5 ^" L! w( M/ @ - #define ITCINTEN_SHIFT 21
) a) e8 F4 F3 K. e - #define TCCHEN_SHIFT 22: H; W5 }/ k, @5 V- E1 M. [3 z5 W
- #define ITCCHEN_SHIFT 230 h2 g; Q5 J8 R; j: e7 _& p _7 I$ `
- 7 J$ C2 B) D5 w1 D' U; a
- static volatile int irqraised1 = 0;
7 f& b7 [; l' X: x7 }" W- W. y - static volatile int irqraised2 = 0;
8 a0 c- w7 U! q& m+ a } - 5 Z. Y4 P* a5 g5 i
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& c! A; ?8 \! P( t+ t- Y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ a) S, f/ t- v+ F8 k! H6 w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, s' Z" Z" P9 R
- 0 i1 \9 C3 v4 R% D. d
- dma_addr_t dmaphyssrc1 = 0;
" {; X) w9 P/ U P+ o* H+ m - dma_addr_t dmaphyssrc2 = 0;
& u* _0 z$ K- z - dma_addr_t dmaphysdest1 = 0;
/ A" v: m* a c0 L - dma_addr_t dmaphysdest2 = 0;6 \$ v3 x T) ?/ o: J# C' e7 y& z
- - P6 X W( E/ ~7 I/ H8 C5 N
- char *dmabufsrc1 = NULL;
+ t+ J( O7 [) r/ v( { - char *dmabufsrc2 = NULL;
. n) Q! l7 J1 M% ?5 H - char *dmabufdest1 = NULL;$ M4 f# ~5 ^7 b
- char *dmabufdest2 = NULL;
" q5 ?) D3 K& V3 J$ X
7 Z( j, V* G j+ l+ I" ]( W$ |- static int acnt = 512;! D& g# F, K( L; c X
- static int bcnt = 8;
$ w4 O6 H- S) T$ P' P. ] - static int ccnt = 8;' _9 ?- u& a+ E2 n
- 9 a0 Q/ ` n' X: k9 b- B
- module_param(acnt, int, S_IRUGO);( M0 V% T) m4 s5 O; }# [1 v) `6 {
- module_param(bcnt, int, S_IRUGO);
0 W0 M9 f, ?, l3 g$ K" X - module_param(ccnt, int, S_IRUGO);
复制代码 . y9 F/ r/ N* O$ q
: R& u; T& Q* j) r1 ~' W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) l! W4 l& ]7 l7 earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, w/ x2 _& i+ p8 K. \3 h 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- `+ C$ ]6 Q! l- q/ F) A
B' M7 L, f5 N4 L& b- {2 L8 u3 A9 m" Q
; ?) |( w0 j/ [ C | |
|