|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: d+ G$ r6 x$ k. R- [code]EDMA sample test application: K# E# w7 v) a4 `! A1 ^
- /*1 j+ r Q3 ?3 F& y2 c1 `
- * edma_test.c
+ `. ^" m7 E3 q+ [# i! Z - *) x! j6 I- M5 H+ H' m- U- Y$ @+ ^
- * brief EDMA3 Test Application' n+ ~. q5 M( y/ [ K0 P
- *0 j5 a7 c) p8 b1 c: [
- * This file contains EDMA3 Test code.
& M4 F1 B! e, D" x2 u, B - *
+ ?& K* N( V4 y0 }( P& P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 R% ~' s+ Y. i* P3 @+ B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 l' Q# U8 D% @5 }( v! Q/ l* c! H - * TO CHANGE.
( {8 q- t0 T+ \# b2 u - *9 `/ }" H( S7 h. N5 [8 h& |' {
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' Q/ S2 S3 D0 n# x: m) U [" B
- *
* `& @) h4 l/ p* P' K& { - * This program is free software; you can redistribute it and/or! h6 R; ]/ S$ y& e
- * modify it under the terms of the GNU General Public License as
# k! k* d% \! t: D( f6 e1 K - * published by the Free Software Foundation version 2./ i$ S4 Y& d |4 ?; q
- *5 `. S5 d6 E, y( b3 I& H" t$ {. \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; J& P$ E, g1 N7 Q, k% z! W - * kind, whether express or implied; without even the implied warranty0 W( k( b; [+ ?0 I S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 I& C$ ^2 y3 L' b
- * GNU General Public License for more details. g9 Z( ^9 O! z
- */+ R( y" N' Y8 H
^; N8 V: f8 M& |( c- #include <linux/module.h>
; @* k9 E6 K% r0 {% i% R" D: @ - #include <linux/init.h>" _9 ~7 t) Z; }) f# n0 t
- #include <linux/errno.h>
{) ?1 Y/ h& q7 b3 M3 ~, o - #include <linux/types.h>
1 J2 s# e+ s0 `! z2 K - #include <linux/interrupt.h>
; w- r; F; g: Z0 L5 s - #include <asm/io.h>( X( a4 s8 O( a% ~9 ~6 ]8 f- C/ M
- #include <linux/moduleparam.h>3 ?" |& x( `) ^7 X( R0 e3 y% }/ k; b& s" l
- #include <linux/sysctl.h>
9 g! M5 O4 n+ S - #include <linux/mm.h>
$ O3 }# F: t( Z* J7 _9 y5 w - #include <linux/dma-mapping.h>$ P7 a& ]8 {7 } e# h# O
- ) s% ?+ H4 U4 V: M. M8 S3 F2 G
- #include <mach/memory.h>1 w% i7 W- p. V5 x
- #include <mach/hardware.h>
& s: I# e- ~6 f s% x, K - #include <mach/irqs.h>
. A$ c$ b( m o5 {, x - #include <asm/hardware/edma.h>
' x) s( S* T+ e+ s: Z/ L - 5 p/ ^% q; A+ ^ p/ T
- #undef EDMA3_DEBUG5 g# r0 y: \7 o
- /*#define EDMA3_DEBUG*/' `* v. V N8 k/ |7 A0 B3 Y
- ) K% J4 n- e% ^% V2 n
- #ifdef EDMA3_DEBUG
4 Q7 B" }7 K: W0 c1 \/ a+ ?9 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)6 |0 O4 [7 |. q6 S( |+ n
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 W% o5 J" j$ J% w6 X t9 V6 Z$ u3 L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ N3 ]6 E* }' n1 H1 K- [) }/ j - #else0 O9 W: J' A$ N p0 b" T* {# Y
- #define DMA_PRINTK( x... )
2 |9 n- S$ G9 B - #define DMA_FN_IN9 `, l: `* c e' S( i. H" p
- #define DMA_FN_OUT
) H7 S6 ~3 h) f0 D( G: l4 Q4 s - #endif9 I3 L' k" c7 N7 f% b2 e2 X
5 c4 i, a5 c! s9 Z0 ]3 \: O$ C- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' T0 d4 d; J2 b$ I' R7 Q# f9 g3 ]
- #define STATIC_SHIFT 3
; E7 G& Y p, L G! B - #define TCINTEN_SHIFT 20
6 e+ w" y; Y5 b - #define ITCINTEN_SHIFT 21
- J! f! f- m' K, v - #define TCCHEN_SHIFT 22
& y' A: A& A! d. p - #define ITCCHEN_SHIFT 23
- F9 S; l( P# V4 _
8 t3 l. o# b3 S* F* q# n+ K" H- static volatile int irqraised1 = 0;6 R) F& c; m- ^: ^$ N
- static volatile int irqraised2 = 0;
+ V5 I! ~/ G, K( n1 a
8 S4 G$ O& Y+ M# m" g# O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 X0 `/ f) ^# q9 Q" j5 U% |; R( g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 T4 v, c: I" ` o* \8 `! f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 X2 }8 }. @0 g7 F1 Y+ h - 0 E. T- W6 n4 z7 f
- dma_addr_t dmaphyssrc1 = 0;
0 h$ o3 p: V/ x - dma_addr_t dmaphyssrc2 = 0;
. Q, u2 \, J5 r f7 i/ ` - dma_addr_t dmaphysdest1 = 0;' j; v3 A, [/ L8 |
- dma_addr_t dmaphysdest2 = 0;) M2 t* C: h# V, t4 W, z+ R
- " |5 d/ Y0 @* O) y1 d
- char *dmabufsrc1 = NULL;
1 m; w( b( Y [ - char *dmabufsrc2 = NULL;
4 U2 ^2 q7 t P8 Y9 _ - char *dmabufdest1 = NULL;
* y9 P3 y; W! [$ [ - char *dmabufdest2 = NULL;4 m( w L! E9 {" N
- 7 a% \% w1 z" ~# N, ~# x$ X
- static int acnt = 512;. N4 M% M; Y/ N
- static int bcnt = 8;
0 n& l9 @' R2 z! c# {0 \; v( s& P - static int ccnt = 8;& T0 C) Y, V+ `5 z3 d
- ! d2 I/ G" l8 h- a$ I" T! d: w
- module_param(acnt, int, S_IRUGO);( h" U! e& ^; A9 d' r/ E
- module_param(bcnt, int, S_IRUGO);
: c, g: a. O! D0 u4 z9 n& c* t ?+ f) b; H - module_param(ccnt, int, S_IRUGO);
复制代码 / X E1 @9 T3 I* M( Q2 w
1 H& E) o8 c) ^# w% r0 ~( \ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* S/ S! G: \0 S- Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) a6 a( V1 A$ i: j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, d* |9 ^ ~3 q1 }+ D9 @8 @
3 D: }& o8 E* f8 x
% m& ~$ b4 j+ x3 Y2 M& {4 n |
|