|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 r% L9 I9 {- s' v- [code]EDMA sample test application
* G$ e$ c! J+ U+ j: [3 F - /*
3 m2 a; y2 N J2 Y - * edma_test.c* ?+ e/ D/ t! R; K8 o
- *; p6 ?! o! K/ n% Q! P
- * brief EDMA3 Test Application
* p }- C: n" R$ G, q1 P% B - *
! a9 V: Q+ |# ^# X - * This file contains EDMA3 Test code.
# D0 O( |) z1 J/ i - ** Z4 _1 Z9 J! e
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
w; Z9 } v9 U& ]# x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 H( u8 v) I5 j7 \/ x0 e - * TO CHANGE.
) Q, F5 U" S5 T - *% ~# h7 o" d- ]7 j' b+ Y& i( z: {8 H
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" o/ j: M- [# _# q2 g- f* \ - *
: ]' ^ L/ G! t - * This program is free software; you can redistribute it and/or2 l) e: x0 a9 v; g' a: }
- * modify it under the terms of the GNU General Public License as
0 n& E6 P) O# O1 O5 T7 z - * published by the Free Software Foundation version 2.
* s B+ i/ y' b! ` - *) a7 ?5 P7 {4 q8 L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: Y% J9 F; F1 y1 p4 y3 y% r - * kind, whether express or implied; without even the implied warranty/ I% {& Z8 y7 W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 ?% O0 f0 t2 f. |1 e0 `) G - * GNU General Public License for more details.
6 D2 p' g) w9 Z+ V( u - */
, ?% e) \' t8 P: Q - - q- a M y& I. \% r
- #include <linux/module.h>$ C% w1 w2 y" t6 @: m+ G
- #include <linux/init.h>$ O- y) k9 e. H: D# C4 i
- #include <linux/errno.h>+ I0 M' m) ~# v( {
- #include <linux/types.h>
3 _0 J7 n( j" X - #include <linux/interrupt.h>7 m6 b. m5 \7 p6 f
- #include <asm/io.h>
4 Q/ A0 i, q" D- H - #include <linux/moduleparam.h>
: W8 [% e& N( Z+ l' X - #include <linux/sysctl.h>0 ~" F/ I, U; h& i4 ]
- #include <linux/mm.h>/ w# i- l$ _8 L- z2 ]9 `7 z5 g
- #include <linux/dma-mapping.h>
0 W4 l$ b5 a4 I. T" G/ v
/ b: R! j- T6 T2 f1 O8 q& I- #include <mach/memory.h>
0 a) o3 K8 {$ \( t- D g% h' d8 d - #include <mach/hardware.h>
2 W7 }7 H- R' Q2 u1 N1 A - #include <mach/irqs.h>
" F. v' a! G$ w - #include <asm/hardware/edma.h>
8 d5 d9 `1 W( E# I& n9 T - % {- ] c0 E( ~3 P# ]
- #undef EDMA3_DEBUG! `9 n$ }$ B, }/ ~8 b/ t
- /*#define EDMA3_DEBUG*/
% O% ?' r, k( i - 6 i3 b* s' z4 |- |
- #ifdef EDMA3_DEBUG7 |+ y, ~+ E9 R5 f; e* a E" O
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; i( }, A3 L: y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( ]. `: l. |" `2 R0 B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 i9 r( _; \7 |" \6 u- L! b% q - #else
# k. c) b0 q' r" v- Q( b - #define DMA_PRINTK( x... )$ [+ E& D: i* L I
- #define DMA_FN_IN
# F( L& ?4 P# ], k2 x - #define DMA_FN_OUT0 n+ ^- O+ y' R. b9 h( |$ C1 ?! [2 u
- #endif
) K7 A6 c# @) l& ~& m3 f: b
1 k# j. L- l8 t# Z, G# y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' D5 l4 S! Z" l9 x3 U2 d' [ - #define STATIC_SHIFT 3
, L9 S3 F& H8 d& i& i - #define TCINTEN_SHIFT 20
9 A2 _9 ^) D( @% ~; I! u# ^# p+ p - #define ITCINTEN_SHIFT 21
& k4 F$ o2 j! f0 Y7 \( d - #define TCCHEN_SHIFT 22
@# Q" ~- R w# `- \ - #define ITCCHEN_SHIFT 23
! A- @- g7 j- J6 s. [& ^ - , W; l0 ^. D( A" Z/ `
- static volatile int irqraised1 = 0;
$ y/ W' j- ~$ J - static volatile int irqraised2 = 0;
% U9 E) V% t1 F& |3 Y
( i/ _- t3 n' I/ T& d* Y& D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% Z; I: U3 p1 L, b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 g, b. Q8 X7 e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' P, Y+ s; f5 l+ n3 F% l - % H. B) ^, r) k, S/ Y, b
- dma_addr_t dmaphyssrc1 = 0;
- s' \4 a' u# s$ p( f K - dma_addr_t dmaphyssrc2 = 0;4 r8 U6 Q: ?5 i0 b- e2 Q& q+ |5 S* t
- dma_addr_t dmaphysdest1 = 0;
: f4 a9 E- d; U# m5 ]2 z. O, |, z. U - dma_addr_t dmaphysdest2 = 0;& z0 f2 i/ b2 [$ ~
- 2 Q: c0 W/ b8 f2 ]9 {" d/ L
- char *dmabufsrc1 = NULL;
6 ]6 M& D1 ]' }% H5 s% V6 P - char *dmabufsrc2 = NULL;7 D) T% Z1 a0 O3 U, {# {, \7 m
- char *dmabufdest1 = NULL;
! p7 u( Q N0 d" y' z2 u - char *dmabufdest2 = NULL;' B7 A; i* Q7 J; Q+ p& N
& Q$ K$ Z( n) a/ t* c" I1 v4 K- static int acnt = 512;# s& N. `2 F$ G( Y
- static int bcnt = 8;
5 ]1 _5 T; _% ?; w4 t5 K - static int ccnt = 8;
" I* G1 j9 H3 i* { - . m/ H! i* y4 K9 _$ U) e" L! C! Y+ d5 D
- module_param(acnt, int, S_IRUGO);5 V1 V e+ P- K8 ^1 p3 x4 h* N0 \
- module_param(bcnt, int, S_IRUGO);
2 V; L, V: C6 y( h; F - module_param(ccnt, int, S_IRUGO);
复制代码 / b4 C1 r: G$ L8 u
3 e) t$ W9 ~4 w2 W& I8 z0 @9 s3 Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ n9 g* b* P' barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
\# E7 _9 W3 q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! u( S) F" _3 t/ H- x+ l9 W) I, Q
& |' j: |0 W) C# ^
# e3 g' y9 A: M0 z |
|