|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* T$ R, V/ h6 G7 X( b7 j2 ~- [code]EDMA sample test application
; B8 w/ p3 R* n" b2 M- l% K - /*$ c5 Y6 N* I" \ o. g8 J6 i! l9 S
- * edma_test.c
' r% S ~+ c1 f5 L. V% H - *2 q0 y2 K* r, j, W/ P
- * brief EDMA3 Test Application
( {4 n) s5 h6 u; q. ] - *7 C# l" z1 j2 `: e: A+ B% _" ~
- * This file contains EDMA3 Test code.
. x% S% e; _" ]: g, J! v - *& v; l$ x, m, E- B
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 w3 o( E9 W6 [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 ^& s, [7 j- x, e* B4 P
- * TO CHANGE.
6 M" Y* k: q0 t( I$ x- p - *
0 S* Y8 @0 E8 N - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: o* W: @7 D, D$ ?1 e) e5 P" `
- *
5 r4 h. P$ X6 v0 y* z u - * This program is free software; you can redistribute it and/or
) M! F& \# r# e: Y- A - * modify it under the terms of the GNU General Public License as
3 p& N, R+ S6 H z+ w% K - * published by the Free Software Foundation version 2.
2 T3 A3 B+ i1 e! B0 ~; r+ Q - *
5 C7 \$ p6 M5 a `4 d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* `4 h* @4 i& x" Y4 n0 ` K- j1 s - * kind, whether express or implied; without even the implied warranty
' a$ z7 |7 x2 }4 J% e& \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! Y1 R r( F! ^! G+ [& i, t - * GNU General Public License for more details.( q& B. L" I% e$ j2 w0 k0 N! [) V
- */
5 D1 q7 ^6 ^4 t, M- H/ w: F- @% f5 E
! X" j) ~$ m# C+ o% q) |& l- #include <linux/module.h> |7 u6 W" W; U5 P
- #include <linux/init.h>* Q# M2 W: ?0 W6 J" c0 a/ j
- #include <linux/errno.h>* K- |1 g) F" Q6 Z, `2 @
- #include <linux/types.h>9 x/ p% Y9 \% u7 {3 A
- #include <linux/interrupt.h>
+ X7 S, P7 O8 g - #include <asm/io.h>
7 l, V, Y: g2 H2 \; K3 G - #include <linux/moduleparam.h>
) h0 r4 p( v- a$ C1 O, H1 T - #include <linux/sysctl.h>
4 ?' b, u, K6 N' i7 V$ l ? - #include <linux/mm.h>
2 [" z' [4 |$ ^2 M+ T$ v - #include <linux/dma-mapping.h>
. N! Z0 j0 C6 f2 N9 M
* R% [! x7 M; @( U- #include <mach/memory.h>
$ U7 L7 G6 e. _& u1 c - #include <mach/hardware.h>
$ ^8 ~3 r+ ]. _1 \ - #include <mach/irqs.h>2 I8 \* ^4 k3 K" @% n- t
- #include <asm/hardware/edma.h>
6 X; F' u. e; n+ D - * E+ F# s! @* h3 T! k6 r
- #undef EDMA3_DEBUG
1 f' s, H+ s5 W; C) C - /*#define EDMA3_DEBUG*/
5 t' m3 _$ t6 ^. S
: `0 d6 h9 i: G! t5 D6 Q- #ifdef EDMA3_DEBUG1 _2 n( |+ L0 a- b& b8 [! |4 X
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ |8 c( W/ _% w8 d: T# _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). J$ s2 A' m4 r V! [2 l
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# @$ v1 J- l) O$ u7 ~/ o
- #else
, K! D, B+ b8 G L: T - #define DMA_PRINTK( x... )" I" W2 Q9 l) ]4 i( O: |0 E0 Q
- #define DMA_FN_IN
+ }1 s; N9 C' t! n( d) \/ S) ] - #define DMA_FN_OUT) ]3 O: \9 A. n9 F
- #endif* j0 @1 R; {- p( J$ c4 f1 `
# P* f- W5 | f2 M; R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 ]- W" f O3 f; s( i - #define STATIC_SHIFT 3
. J3 x+ J1 V8 Q( X( j! z - #define TCINTEN_SHIFT 20
' ]) w( @# B# {4 J/ O# z( X( { - #define ITCINTEN_SHIFT 214 c7 W& t! l F1 Z, O0 q0 L V
- #define TCCHEN_SHIFT 22+ s5 O9 u6 ^9 \5 y; X' z
- #define ITCCHEN_SHIFT 238 A( d+ ?' f- Q# s
- ) @2 C5 f% E Q5 R
- static volatile int irqraised1 = 0;& z4 X: \% Y! c6 B" w$ q! R
- static volatile int irqraised2 = 0;
: F2 H! _( S" A9 k4 D$ {
. j( z0 h: b$ p$ R- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 ]* @' d n& g2 X6 a - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" T t& O8 p* n1 ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; s0 N1 F( X: ^
- ) c( Z( }% Q: n8 W6 ~; k% G' a' d
- dma_addr_t dmaphyssrc1 = 0; e+ {' p, M- j# S9 m }, z# k
- dma_addr_t dmaphyssrc2 = 0;
U2 v2 t9 p s+ }9 x, _) P - dma_addr_t dmaphysdest1 = 0;9 N5 o+ q4 e1 a$ |& A
- dma_addr_t dmaphysdest2 = 0;. l( t. k* z& W$ Y
- / L. t7 p1 j$ ?/ s. u( H3 N
- char *dmabufsrc1 = NULL;: o3 K+ ^, c" x: Z
- char *dmabufsrc2 = NULL; J& N6 z L4 W" K6 X: z7 m
- char *dmabufdest1 = NULL;
! _ o# q1 ~. \: U( J' C - char *dmabufdest2 = NULL;9 {1 p# W* o6 q) Z) j1 d
: V* x N, X1 I" T- static int acnt = 512;) B& K0 c6 V* V6 ~2 [
- static int bcnt = 8;
5 d$ { ^$ G% M# N( R - static int ccnt = 8;
" ~6 L- a9 r2 g; A$ z# W5 Q m& I# @
) W1 E" Y6 ], N$ L- module_param(acnt, int, S_IRUGO);
2 ?0 z3 x9 m) w/ u8 s/ S( U3 g - module_param(bcnt, int, S_IRUGO);3 j+ W9 d( A# ]
- module_param(ccnt, int, S_IRUGO);
复制代码
) B6 Z# H: G' z l+ ?# G& s7 }6 e. n7 I% x2 I3 I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 v8 ^) c0 G# Z1 ]: V' H5 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ d" P7 g. ^, {' T
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ B) v" z, _5 {6 ^/ @* t7 q
0 ~$ {* t! U2 f4 G. u& g0 q! `& j6 a- Y6 f( [6 r. b0 s
|
|