|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 A* T( R: [7 ^8 n7 u0 S
- [code]EDMA sample test application7 X+ G9 |- _& W7 q. q6 h9 }
- /*
: P3 ?4 I! U. f5 Q X - * edma_test.c
: j) L3 a' h ^! B - *
$ ~9 {" h) j& T- A - * brief EDMA3 Test Application$ P( S6 z# M8 U
- *; Y5 h) A+ Y1 L3 T \
- * This file contains EDMA3 Test code.
" A' x" a- B; P$ e, P - *
, _+ o7 }: z p& q& l% J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; ]7 I2 p9 P9 v" }" V% C. q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& D4 W0 c( s8 Q s+ z% V" S
- * TO CHANGE.' [; R( y R+ o
- *
; Q7 O$ x( Y( ~! q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. C& |* o! _$ k3 q4 A8 @/ | - *6 D( l) J ^ H8 `6 Y
- * This program is free software; you can redistribute it and/or
9 O# e. i( Z$ T/ F1 w% u - * modify it under the terms of the GNU General Public License as
8 E5 F8 z$ w( l - * published by the Free Software Foundation version 2.* K. [. ~$ x8 }! S0 w. |
- *0 f9 ~+ S# h, @% }/ f( Y, d7 E2 A. _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" ?+ a' x7 E' k* V1 Q) f- B; |
- * kind, whether express or implied; without even the implied warranty
. L, p( J2 R& g* D* B I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; a& `$ y2 N, v9 Y' [ - * GNU General Public License for more details.
' `7 \7 C( Y# n: l+ O# x - */
# M8 N3 K0 ^$ N1 D" i% V- a" O z - + k3 D% r) q3 b9 \# u
- #include <linux/module.h>
" k2 s& S& M# ` - #include <linux/init.h>% t& a4 ~- i& @8 R
- #include <linux/errno.h>+ I: E& i2 b' n( p2 \
- #include <linux/types.h>
/ P8 O, H: y& j - #include <linux/interrupt.h>3 F( \+ p5 j; M* {& h+ f
- #include <asm/io.h>7 o N% T+ t" x: g/ [/ j; m
- #include <linux/moduleparam.h>1 h. v" k& O4 X+ X, Q! p- J) q
- #include <linux/sysctl.h># o3 x3 y3 ]+ N6 a4 w. U: `
- #include <linux/mm.h>1 e% w9 p5 B' G% A3 ^/ z' r
- #include <linux/dma-mapping.h>
. w& l' k+ D) J; V( `: h; ] - : g, c1 H3 V8 ~: M$ s6 m# {
- #include <mach/memory.h>
6 J& T3 i: R: T' ~( @ - #include <mach/hardware.h>
& Z) X9 m9 D. p! h7 L% X0 K - #include <mach/irqs.h>
0 ?9 K; K( p0 w" y: B - #include <asm/hardware/edma.h>( X+ N- t0 D5 K
- - t! L% T; T( g: C6 G+ z9 j
- #undef EDMA3_DEBUG9 G, V; c4 I* V1 f
- /*#define EDMA3_DEBUG*/% e0 z5 m( C& \) P }8 _
- & |: k) G+ Z) W' q" F l9 `! c
- #ifdef EDMA3_DEBUG5 ]* J. j+ t- R7 F" n' N* k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 {% g" q4 D1 }9 e
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' `; b+ }" R8 U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 r9 f2 G5 `& a( j9 o, g - #else
1 e; l3 {0 a. o: A+ |% R6 t - #define DMA_PRINTK( x... )2 |* t- e; K/ r) ~* [) D5 W- X
- #define DMA_FN_IN$ X9 T. N+ e$ j4 q H- @9 T2 l
- #define DMA_FN_OUT
: @& D, p( b& X% q _. M# a& p - #endif
$ P7 w) z+ T8 w% @0 y2 N - & V# J6 U a$ p: g) d: p
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 P# f" R3 B+ Z3 N" n2 {: u
- #define STATIC_SHIFT 3
) ?& [; m) r. H! C5 q9 o- d - #define TCINTEN_SHIFT 20$ g% P) y0 i2 A2 n
- #define ITCINTEN_SHIFT 21- h1 ?: i4 S9 A+ }- y
- #define TCCHEN_SHIFT 22
& R$ Y& l2 Z. B% X - #define ITCCHEN_SHIFT 238 r7 u. D2 y; p% f$ c3 ^" Y
- + |& P" f4 q- Z: r0 Y+ e5 X
- static volatile int irqraised1 = 0;' @6 F. l' e# X; N! h8 |! W
- static volatile int irqraised2 = 0;
6 x+ r, r: G6 ?' `+ X - $ z1 B8 I# @% P2 B* c T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ ^; Y! f, ], A7 l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 e8 M4 q6 G" W0 E, t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 ]! i) b4 Q" Q - + U5 M9 s' Q* r) l: c
- dma_addr_t dmaphyssrc1 = 0;
& x8 J3 ^& J* u- b2 F: t5 Q - dma_addr_t dmaphyssrc2 = 0;
1 P7 U9 D8 ^% p+ P" O! F - dma_addr_t dmaphysdest1 = 0;8 J ?3 r) J5 U, J. U
- dma_addr_t dmaphysdest2 = 0;
: }. c. H, |' R3 S5 a - + Z" `, _0 \& k5 S4 r+ W9 A! x
- char *dmabufsrc1 = NULL;' a- U# T/ v& h O6 r7 T/ a
- char *dmabufsrc2 = NULL;
% H6 T& B3 o$ r4 ]- D# A - char *dmabufdest1 = NULL;+ O V J4 v& M5 T
- char *dmabufdest2 = NULL;
$ [. K+ q4 ]6 J2 R M, z* [
8 S$ E7 p! V3 d$ h W) k- static int acnt = 512;
- c. R- X( U6 W6 a: ] D - static int bcnt = 8;. G( q6 l* R( s, y5 a) m, \+ I8 o! A
- static int ccnt = 8;+ n( d* x3 B. J' s
- + e5 d9 p+ z4 a- }; K% X6 Z, ]
- module_param(acnt, int, S_IRUGO);- m# Z, p1 Q3 k) r
- module_param(bcnt, int, S_IRUGO);
* ^9 z# {1 H& A2 K+ t9 Z# d4 }& u - module_param(ccnt, int, S_IRUGO);
复制代码 " Q, j5 I7 v5 h1 s# b6 P
. O7 |0 Y! n1 C
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 D) ]5 k" G0 W/ B, c" g. h4 C M
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 G* O7 c' ^) G( L
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 z7 _, j) x6 H8 B4 Y; `
# q) c3 f! L! V! `, C1 p7 y: B
|
|