|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 q/ o5 o6 n* X/ z' w9 F- [code]EDMA sample test application
2 |% b" h0 G$ T, T. J' J/ L7 ]; z - /*
. m [* W' d- u( `2 ?0 z - * edma_test.c
+ H5 ~/ K! P; B# ` - *
) v7 Z: l4 e0 F4 F - * brief EDMA3 Test Application0 ~) ], l& {0 E( k
- *, I" z7 x% R( l7 _" G
- * This file contains EDMA3 Test code.
/ P% ~9 ~' _0 v& s: M - *. G( p1 N4 U" V$ h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 T1 ?- ?# Z" W, W
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; r' o( s( J6 B& i - * TO CHANGE.
6 f1 x0 Z: Z" ^/ Y; `) p - *; U( J" ^. x; _5 z* p
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 n+ b' O5 _- P( Z# P6 g - *' @. V" Y8 U, }3 S- @6 Q
- * This program is free software; you can redistribute it and/or* U% o. d6 C1 A/ D
- * modify it under the terms of the GNU General Public License as
: o$ s* B- `& p9 q' g" o8 Y& F6 U - * published by the Free Software Foundation version 2.
% \: l" N; }$ u% i' y: J6 h - *
6 [. x3 t* z4 m) ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any% g# b, c4 M& z( y
- * kind, whether express or implied; without even the implied warranty
- [9 D+ i; n: _/ I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& f( o l. h- i% u) ?/ I - * GNU General Public License for more details.0 i& B0 Y! J: u7 s
- */* E2 ]5 N, V) F8 l9 [4 {
0 t+ s D1 w: `: L2 m, V- #include <linux/module.h>
! R% v, p! ?" i/ P6 F, } - #include <linux/init.h>
+ `7 k* f9 l7 ~ - #include <linux/errno.h>4 f2 v1 f4 n* x* w1 |# \
- #include <linux/types.h>0 j+ v* D$ J: B/ y
- #include <linux/interrupt.h># ?) H6 {3 L2 J: Y8 C' n: z v
- #include <asm/io.h>
% S4 y8 \+ V/ x2 q& F# q - #include <linux/moduleparam.h>
$ Q& N( e+ S8 T- C+ ]5 l# o9 g - #include <linux/sysctl.h>
$ N& t& w- Z9 A( j2 L1 g - #include <linux/mm.h>
. j( G7 e/ p4 H. A# M - #include <linux/dma-mapping.h>9 J5 S R; q5 Y" @$ {
- 0 A9 k( F8 W5 f4 w' w; S
- #include <mach/memory.h>+ T$ y& o2 K; I! K5 D$ q0 X
- #include <mach/hardware.h>
+ f l* S6 F7 K/ `+ Y- \ - #include <mach/irqs.h>
" F; S8 l F% L: Q0 s/ Y# ^ - #include <asm/hardware/edma.h>
i; i" P2 f& F/ d
& Z9 b- G8 L* w' o0 F$ V- #undef EDMA3_DEBUG- o7 M5 x2 t) V
- /*#define EDMA3_DEBUG*/
) E* ~& m2 S2 g+ `+ w; I - + _0 u7 d: c, U5 {9 x% f
- #ifdef EDMA3_DEBUG
& U' @5 f8 h- p0 [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ a+ `( i% o" _+ g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 m# ], y" U. V4 |% M - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ w+ z& O$ \3 y3 ] - #else
' g/ ?$ U: F( G - #define DMA_PRINTK( x... )
0 {5 ]- C2 e4 ?% u& ^* i; ~( l0 i - #define DMA_FN_IN
& n' f7 `2 |5 B - #define DMA_FN_OUT
# E& Y! y; N$ R8 ?0 { - #endif2 K7 ?1 r& ]+ V7 h
1 J+ v' a8 J4 y* z0 _2 {- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" \( G6 w" c1 `9 _ F9 w - #define STATIC_SHIFT 3
- b7 o! t1 X! B, g - #define TCINTEN_SHIFT 20
h, C" _$ r8 N! X - #define ITCINTEN_SHIFT 21) Y3 h. T' q4 P2 s: S6 b: J3 n4 g
- #define TCCHEN_SHIFT 22
" }: r7 D3 q9 R; E- Z - #define ITCCHEN_SHIFT 23
3 a8 h5 o% x% t1 b% A& Y
, W* r0 x3 f/ Z$ e5 _- static volatile int irqraised1 = 0;$ y; Z1 _# Q" K/ S4 n" ~7 y8 ~) U
- static volatile int irqraised2 = 0;
: Z6 r3 Z) s7 j2 [5 A6 K: [
% c, R( b% q6 h( t; |- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% I' K. v' X2 p/ Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' K/ `1 ?7 R& M* j - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ L! }9 z% v" L
- s) u B- Z) Y& A6 n% _' l) w* ^
- dma_addr_t dmaphyssrc1 = 0;
. p' K$ X$ i1 D% X. o - dma_addr_t dmaphyssrc2 = 0;
d% M9 ?) V, a2 W- y0 x: w - dma_addr_t dmaphysdest1 = 0;
. }2 P# G2 a" ?$ Y! V/ p, h - dma_addr_t dmaphysdest2 = 0;
( O6 z3 W% a) N" E3 F - 8 T. V0 x% W0 U1 o$ w$ }0 ]/ m3 [
- char *dmabufsrc1 = NULL;# w1 G: l. v5 G# W
- char *dmabufsrc2 = NULL;2 Z8 t% V1 c$ A
- char *dmabufdest1 = NULL;
3 v" T% ]6 r+ I8 J# I - char *dmabufdest2 = NULL;
- l3 L7 Z4 C7 m# \) N! v, \( L8 F
' c4 c2 h# W$ h- static int acnt = 512;2 N7 l! f$ }) E. W4 g
- static int bcnt = 8;
8 G# @7 I% V2 {' g - static int ccnt = 8;
$ `& T5 b$ q3 ^# ~
* G S9 m! V' m0 E* l9 v4 t- module_param(acnt, int, S_IRUGO);
- q. u* @0 H1 e: T1 g7 h - module_param(bcnt, int, S_IRUGO);
; H1 G0 h+ R$ M) p8 Z5 X - module_param(ccnt, int, S_IRUGO);
复制代码
: [" ?8 T, {3 ~2 w) q7 _- z/ P- |7 {6 ^* d# l) n! P
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 m1 R9 E. |1 Q2 ]( Z3 parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: [+ }3 {6 P, i' `0 O3 _; J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ a A: U: H1 z# m$ w
8 v+ T& [$ h' T; V/ Z! w$ |' L G9 s% B& d
|
|