|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - Y+ {" J" w$ P- J- x
- [code]EDMA sample test application
* y1 r1 y8 {' \+ X - /*
$ I, A: G( X3 P& b3 q; d - * edma_test.c7 v& o) u0 z; e1 v9 C
- *
8 P- K8 b* k* e - * brief EDMA3 Test Application9 p5 y- h& I2 L# [ f" p* F% |% I+ z
- *
/ z# T6 `- l6 y2 s4 }: P/ K - * This file contains EDMA3 Test code.
3 ]& ]% D- x( n( |2 e. o3 m6 s6 t - *
2 y, {0 Y0 x. @ r, { - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: J) G" t+ R9 [! Z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 R3 K1 a2 [2 g+ Y5 U g - * TO CHANGE.
& n0 B& Z/ O$ ]! A8 ?1 a - *
( T$ o6 P% w5 R k6 P( z! ^9 u - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 I6 F: N4 E3 N& L
- *" g# O- A: t% L+ G/ N4 b
- * This program is free software; you can redistribute it and/or" [1 D5 n# d+ M$ y# `
- * modify it under the terms of the GNU General Public License as" E% c0 c. g4 M K% s3 J/ F
- * published by the Free Software Foundation version 2.: [$ j- C" a6 ]
- *
, |! Z$ f) R! ^" {/ n, c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any: ?& ?4 ?/ O0 {" i0 w5 }
- * kind, whether express or implied; without even the implied warranty% v: s' G( \; o! _
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; V- v3 K) e/ }- s" f1 W# @9 C" y - * GNU General Public License for more details.4 D5 M$ S& C% z. f B! H1 F
- */
3 F+ b) ~& u$ c5 W - / A( M- Z% _. y; c+ ^
- #include <linux/module.h>
9 r' _, Y$ @) V3 n& P* w/ J - #include <linux/init.h>
1 I& \, b+ \7 m9 m. G! t; u2 ? - #include <linux/errno.h>
9 O& |" @1 k0 k2 V' u& Q - #include <linux/types.h>, r) D+ q0 b( ]5 r
- #include <linux/interrupt.h>+ Z: z5 n3 d: j7 Q( H+ T |
- #include <asm/io.h>, u7 b# z5 Q& m
- #include <linux/moduleparam.h>
9 p6 u7 W% e. R; \3 p) k( Y - #include <linux/sysctl.h>3 U4 `4 w+ R- y4 x
- #include <linux/mm.h>& y- t1 F. i7 K: a# k e0 R ~2 i
- #include <linux/dma-mapping.h>
' k/ J o- d8 ~" g. R3 D
: J% p. N! \9 l+ e6 v% n- #include <mach/memory.h>$ f& }$ ^2 J# `! O
- #include <mach/hardware.h>! O T4 i0 y7 k& W
- #include <mach/irqs.h>3 x' P5 q0 Y& \: q4 W1 z6 L, K
- #include <asm/hardware/edma.h>, w% Z- { H0 r* z7 `
& m7 u3 p. z' k/ l! `- #undef EDMA3_DEBUG
0 p( {$ K/ T# `1 B8 ^ - /*#define EDMA3_DEBUG*/# O" c9 O6 P: x$ Y2 a, b) R
* X) u4 R, o1 I q- #ifdef EDMA3_DEBUG
5 ]4 T% A/ A: m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 [/ p6 N2 Y+ G( i- [
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* ^. T" u( [: Y* G# Y4 C* }+ y1 H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# g4 g R9 w- |; w& Y - #else
* [7 E" b% M7 ?. m9 e - #define DMA_PRINTK( x... )
9 x( `9 B+ }6 B% N' Y - #define DMA_FN_IN8 m! u p' R+ b9 p! }- V3 q- U
- #define DMA_FN_OUT$ d0 T( w+ D6 p% [4 r3 {
- #endif
9 `4 f1 P6 d+ Y- P3 G% f
7 z* G2 O0 T0 w9 @- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( D k6 z6 z/ v5 D. G3 R# g - #define STATIC_SHIFT 3# l! [8 V3 w5 y% h9 z2 X
- #define TCINTEN_SHIFT 20( d3 l$ j. |' F( D" Q- H: n3 U
- #define ITCINTEN_SHIFT 21
7 g8 v/ I1 G' G, S# O8 O) c0 @ - #define TCCHEN_SHIFT 22 v; v Q/ U: t1 @) j7 p
- #define ITCCHEN_SHIFT 235 I( `# S/ }' B7 s
/ c! F+ [' W- H. i v- static volatile int irqraised1 = 0;* |& e, \; A' H# X+ k: h5 k# O
- static volatile int irqraised2 = 0;. F; t( {$ b# m2 \: n8 m
- c! O& m) T" u3 f @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 }0 |; l( ?) n1 Z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% }, Q0 X" z& H) S' V, w2 V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. }; {# K! G" ~' N" d D
- $ Q; N3 E) n/ o- p, Y$ T+ B: B
- dma_addr_t dmaphyssrc1 = 0;# p" _& R& m( n" I, i
- dma_addr_t dmaphyssrc2 = 0;
' P1 S- _5 m4 K* _ - dma_addr_t dmaphysdest1 = 0;
& P( F% p# i4 P1 }: u0 ~$ _ - dma_addr_t dmaphysdest2 = 0;+ m; ~- G/ Z0 }" x
) D( e# \# W4 s: T- P- char *dmabufsrc1 = NULL;
1 d- X! [' s/ v; y - char *dmabufsrc2 = NULL;! G6 ?+ `1 A$ }2 R) e& U3 I8 M
- char *dmabufdest1 = NULL;$ S0 S5 S4 Y) o" K% @ ^! Q; m
- char *dmabufdest2 = NULL;2 i& u4 W2 |+ w/ s$ F' T+ d
0 M# V4 y) x' F- q- r- static int acnt = 512;9 R% C8 H ]& H" r+ T
- static int bcnt = 8;
1 b' s0 H5 Q9 F - static int ccnt = 8;: f, i4 E# k( c& }$ z) j
- 7 E6 ]: J- u- @% P1 @: ]
- module_param(acnt, int, S_IRUGO);) i _# }* z3 \ g
- module_param(bcnt, int, S_IRUGO);
6 B6 B k/ M: ?# D- ^: { - module_param(ccnt, int, S_IRUGO);
复制代码
% `, N {! H; F( |" u1 C+ @$ c/ A/ J+ r- H1 A% X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' J, A1 c' S1 e& ?- q8 f
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 F% E& m3 h$ K& C6 F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( }$ q7 T$ ^2 Y$ S
. T: U7 V C& l6 _3 U
. O# M: L0 S( l |
|