|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ [- L' B4 }9 L4 c5 R
- [code]EDMA sample test application
; x. T( T9 B: h* W - /*9 o4 U5 g2 C* f- t" t2 O5 k
- * edma_test.c
4 _* {) m- ?" }" Q0 Y2 _1 s - *
4 T1 a7 [9 _6 K. _' d& e( F% P - * brief EDMA3 Test Application% W$ g/ Y5 u% ]) }* |" ?) U
- *! K3 E G! }' d6 M* j
- * This file contains EDMA3 Test code.
' o0 H$ ]+ p) X4 Q$ d - *7 G' H8 L7 @8 V8 {, }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" L0 s% S% A$ [) V% ? - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 U6 j" W, h9 U: ] - * TO CHANGE.
1 r( v8 o( @1 y7 [$ q+ A5 v - *" E8 m7 A( g6 A4 l8 k2 \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 ~# g6 X( O& t" X5 p - *, m v/ m7 P W8 A3 v
- * This program is free software; you can redistribute it and/or/ C& v0 l' |4 D! `
- * modify it under the terms of the GNU General Public License as
* ~+ i' {3 k0 `* G5 i - * published by the Free Software Foundation version 2./ n3 L) U* {6 n: f) l4 m( r
- *9 `. _3 k2 m! M/ A$ ]1 [
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" w5 C0 {* z/ e! n( Y2 M2 ?4 x
- * kind, whether express or implied; without even the implied warranty6 a; m# W0 N. F& _8 e
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, {. i7 q5 I0 V
- * GNU General Public License for more details.
; l6 z& a5 e$ c - */( C$ }9 I9 k8 N% h# f1 H) E5 d1 l
- ; F) |6 G( u3 z8 U* n. f y
- #include <linux/module.h>
* n0 t- ^) D. t7 k. e( ?1 i - #include <linux/init.h>
+ d y6 u/ w0 H' \: \, G5 m9 n4 s - #include <linux/errno.h>
5 S m$ e/ C7 n - #include <linux/types.h>
; W+ ?' q; ]# g4 C) | - #include <linux/interrupt.h>
, e+ i: j) U1 N6 H a4 y* { - #include <asm/io.h>) K& I. |7 _1 w
- #include <linux/moduleparam.h>
1 \$ R/ G% d& W1 A! v2 L' Q - #include <linux/sysctl.h>
# Q% J* {" g1 [5 Z5 v( ~ - #include <linux/mm.h>; |6 w2 u, T6 E# _
- #include <linux/dma-mapping.h>
6 ?- o) S, v1 N3 m& [
( }/ u" Z3 N, M/ S2 b' S- #include <mach/memory.h>
% C9 h$ E4 H' g+ B. Q - #include <mach/hardware.h>
; i( O1 V! x4 Q% ^ - #include <mach/irqs.h>$ q6 y) e z' e
- #include <asm/hardware/edma.h>
4 F+ Y5 z Q( m! a( b' C% @( S
& J. q( r' r {3 ?7 N- #undef EDMA3_DEBUG
- Y' H+ b8 N' s8 u7 b3 Q - /*#define EDMA3_DEBUG*/' ~( o* _* g# t3 J) N; i( K
4 h8 O( I- u$ e9 i+ L) j8 K; D- #ifdef EDMA3_DEBUG) E1 d9 P. s0 `/ n
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* R c/ ]) T" i! V7 A4 V& s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ T! ^$ s+ \- P5 E D, K4 p0 c. @ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! v; k( v! ^7 }) t, N4 v/ m4 G p
- #else
7 V! ~/ K# K3 c" |1 n5 t) s - #define DMA_PRINTK( x... )
; `) l* P7 J5 g - #define DMA_FN_IN
+ F: B. c, N5 J7 `, x% A* c - #define DMA_FN_OUT& I0 Q3 X; X. U: A6 J; p
- #endif) ?4 Q, V) T) i* m7 K6 l* }! `
- - H1 o$ `/ ~* m, i' T/ [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 M$ Z I- Y+ w3 A4 O6 B' w- k
- #define STATIC_SHIFT 3
! C& \: X, c* w - #define TCINTEN_SHIFT 20
: O: ^5 l2 s9 m' k - #define ITCINTEN_SHIFT 21
) Q3 P+ D6 L; z - #define TCCHEN_SHIFT 22& Z) c; ]! @% J$ h- r$ u4 U2 c( P
- #define ITCCHEN_SHIFT 23% z T! h, j1 v* A% ?! b; ]
- ' S/ v1 x& {/ ]
- static volatile int irqraised1 = 0;
& m! a' d# }- N" ? - static volatile int irqraised2 = 0;
0 ?$ I3 U: z8 W. w - \6 w0 A; E! {
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# N+ G* X8 z; n9 z( E; }
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 D) q: W! m' P/ a - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# B7 ~& B; x* P7 S: I
- }/ b7 W% _9 ]% f8 r$ _* [- dma_addr_t dmaphyssrc1 = 0;0 V- ]2 b# J" ^
- dma_addr_t dmaphyssrc2 = 0;/ y& R k1 R$ h* z: `
- dma_addr_t dmaphysdest1 = 0;
% I/ a) ~/ C. u - dma_addr_t dmaphysdest2 = 0;9 t6 v9 S* D* Z+ W5 H$ D
6 T% l9 Y* ?5 T E- char *dmabufsrc1 = NULL;
" U: I9 s. a4 n7 s/ W+ ~ - char *dmabufsrc2 = NULL;; h* ^0 y+ }( z; B
- char *dmabufdest1 = NULL;
& L( I5 d( {/ ^ - char *dmabufdest2 = NULL;0 s; m) A1 N3 h( A8 K3 t4 S. o/ B
- & t f$ X7 c$ Q% ?& W2 p7 l
- static int acnt = 512;* M6 n& O9 H; V0 ?" S0 L5 v' T
- static int bcnt = 8;- X. Z" R- i' L/ J2 W" h
- static int ccnt = 8;
) `! R# o8 _; u3 w - 7 b! ] P, N; f
- module_param(acnt, int, S_IRUGO);; |. d6 A$ s/ T; a- l
- module_param(bcnt, int, S_IRUGO);& T; p4 l# R2 K
- module_param(ccnt, int, S_IRUGO);
复制代码 : m N. q* `4 C
! Q+ C% Q0 w- \' ^9 Z3 e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 v& a5 n' O1 o
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 b& j6 }4 Y; J1 C, E- o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 m8 n' K: u$ g+ e$ s& B* |) x9 z1 ?7 w; u1 O4 {
0 K9 S( l* C4 [5 ^/ Z |
|