|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 k9 k2 w$ q5 H. {- [code]EDMA sample test application8 _& M: E" a6 J4 q$ l
- /*9 a$ s$ f! l/ Q4 b$ e2 M4 z" U# n
- * edma_test.c; p. ~6 F# m! t9 k' u
- *" e6 Q9 C2 T. z8 I6 e G7 \3 a
- * brief EDMA3 Test Application- d& v3 Z; _4 p! ] N8 b
- *5 i" h7 {: t; n( O0 N2 r
- * This file contains EDMA3 Test code.# @3 a$ H v$ s
- *. u4 Y4 \! d6 P# V
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! M i4 s* u! l& ]! i. ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; k! l# ~. n$ w
- * TO CHANGE.
2 H2 ]2 F, y* L( m1 v& v - *7 E" |: q* Y% m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 _# E) c7 ~/ [6 ?( M$ x" K - *7 v. ~& K. t- b2 X- h
- * This program is free software; you can redistribute it and/or" C/ A* l4 P" z! R( |7 ~/ z
- * modify it under the terms of the GNU General Public License as* Z( S& Q' M# ]: q
- * published by the Free Software Foundation version 2.: M8 [( |9 n' [) ~/ F/ I0 M# O
- *9 G! u; `* y) q! ~% G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: ^+ F/ \* d$ a' |0 p( k3 J( Z( O: p
- * kind, whether express or implied; without even the implied warranty
7 f7 ~5 ~2 n0 Z: \9 N% p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) O$ r4 A( @" P9 x - * GNU General Public License for more details.
! p! p B: p. ]+ j3 P9 a7 R4 G - */) K: O. r+ O+ S1 S5 w
( L" t& m7 b I- ?1 g c4 h- #include <linux/module.h>
# E) w( n4 n" M. w - #include <linux/init.h>; K0 y6 B3 X4 Q# |
- #include <linux/errno.h>
# H4 ?, a9 I1 Z" N6 b. N - #include <linux/types.h>
) E2 y* D0 w# n- G1 E - #include <linux/interrupt.h>
$ n7 M1 b6 @, V$ B9 P - #include <asm/io.h>% Z2 Y2 @; O0 L/ u
- #include <linux/moduleparam.h>/ u9 F% R6 k" Q/ `0 \5 G
- #include <linux/sysctl.h>( {5 P u# r& @" A7 B; B
- #include <linux/mm.h>- ?" W% | H' s0 z; `! t- O
- #include <linux/dma-mapping.h>
$ d, Q" I( j* V" [3 \2 l - - N% G. o' |: C
- #include <mach/memory.h>
; g6 N! }9 w: }' Z+ \ - #include <mach/hardware.h>
3 O K6 w+ d; [1 R' E h - #include <mach/irqs.h>5 w; A# G6 }! f: Q" e
- #include <asm/hardware/edma.h>8 c% u6 v8 O6 s8 n m' b& Y) Y* U& b
- 1 s: a8 e" h: ] g$ _
- #undef EDMA3_DEBUG4 W3 t( }/ R% g- ?
- /*#define EDMA3_DEBUG*/! ^7 K8 J' A9 C, h9 o
- , h/ z' }/ a8 `% }$ B
- #ifdef EDMA3_DEBUG. H! t' k& a% f: ^4 Z& Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& f8 `( X7 c& c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: @- S7 G8 R6 @- p8 e1 y/ y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" l# `9 \5 f3 a
- #else* `; e3 P. n7 ?
- #define DMA_PRINTK( x... )
, z" r6 V, q9 B$ Z - #define DMA_FN_IN6 w4 W3 w! u0 z
- #define DMA_FN_OUT9 g4 H5 E* c) j5 t# Q$ k. q$ e
- #endif
% k- \( Z( d( f1 y7 ] A& }2 f
& P M$ H0 V* I: j/ a6 T& h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 Y" P8 g1 l5 Z1 [4 q
- #define STATIC_SHIFT 3, M0 G5 ?; k& S2 W) F6 F5 N
- #define TCINTEN_SHIFT 20/ f1 E) k K) k" P" f) p
- #define ITCINTEN_SHIFT 21( |( a6 Z% u% x% I3 v
- #define TCCHEN_SHIFT 22
2 p9 [. j( U# j4 n - #define ITCCHEN_SHIFT 23% D) P, V+ z' u) T" \
- b8 V( a! z8 t6 |( c4 J- static volatile int irqraised1 = 0;
. x, ^5 {6 I( }) }* M - static volatile int irqraised2 = 0;4 M' M5 _6 v2 C7 e7 q
- 8 E2 u) Y, U! q2 n! e+ r1 y4 W) I" C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. N- a% B4 q6 M0 k! ~- S
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 j" D+ a, U) n - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ ?: e7 z; S8 c( X4 T
/ I; O* x) g5 v2 A j1 I- f- dma_addr_t dmaphyssrc1 = 0;
. ]+ P0 G! B$ I# ^) h0 X - dma_addr_t dmaphyssrc2 = 0;
% C4 t0 m) k U; C! x$ n- @) n3 I - dma_addr_t dmaphysdest1 = 0;
. N/ J) u7 K9 \1 d. {' X# V" h - dma_addr_t dmaphysdest2 = 0;
: F9 e9 F+ O2 w# z f
* `) C: Z' P" P3 z- char *dmabufsrc1 = NULL;
! \# C& R" V: F0 S" Q9 ^4 V2 j7 U - char *dmabufsrc2 = NULL;3 K: i4 P* ]( b0 t! `# y; K- f
- char *dmabufdest1 = NULL;
4 e! X/ c/ ~$ V0 X - char *dmabufdest2 = NULL;
6 F# f# ]9 J! S- @5 S5 {% R
3 s6 j9 Q- S4 @5 {% j- static int acnt = 512;
! t" p: \4 t3 \; C - static int bcnt = 8;' O4 S# T7 Z3 Q' K7 R9 L
- static int ccnt = 8;4 v. q1 z, ?4 {3 n* I. k) x
- / D1 c6 l0 d+ ~' C
- module_param(acnt, int, S_IRUGO);& ?1 A' F6 C2 o2 Q8 j& l
- module_param(bcnt, int, S_IRUGO);
2 n9 I1 d" Q. {# q ? - module_param(ccnt, int, S_IRUGO);
复制代码 l- s4 A( R \( C/ s& r
. q+ k: s) u& i: i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 n. k( L1 a& M8 I1 R2 jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- C+ g" Q( v2 f9 Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ t% X4 U8 H: s7 n% B* z I+ W$ |8 k0 f& _5 P7 P
1 y8 i0 t3 X$ u4 C( r( O
|
|