|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 \' U; t* i. H. A- [code]EDMA sample test application
" x2 L p8 _3 `- o8 ~ - /* M1 Q5 O3 i8 J- e5 A" g
- * edma_test.c% A% q- F5 e/ |% x& W$ x0 G
- *1 i" |6 m2 |1 n3 c! y
- * brief EDMA3 Test Application
( F7 |0 e1 j1 u' N4 } - *
; Z7 U2 W$ G9 z+ A - * This file contains EDMA3 Test code.5 p' H& c$ Q# N I" W: K
- *
/ ~4 ~" k8 D5 I1 ]. { - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ X2 e' q" H1 E% M4 M, {0 V - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 s6 l7 h2 b _, P/ b- t: Y, z6 h: u0 I - * TO CHANGE.# ^% ~7 g! p4 G! ^$ g3 M
- *
* Z1 m3 l. ~" ?# _& O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! {- G8 L4 O0 }. g6 |- n2 o# q
- *9 c* P5 W$ l) @% }$ T$ b
- * This program is free software; you can redistribute it and/or
2 _% F2 X" m y. W6 S% } - * modify it under the terms of the GNU General Public License as2 ] i+ n% u' {! H8 ]+ V) |
- * published by the Free Software Foundation version 2." `, b: k9 {$ g2 }" [$ ~5 Y# r3 Y: P% y
- *
& m8 b: E6 G9 m9 H. C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' f2 c+ i% K& ?5 ^) X( X' O
- * kind, whether express or implied; without even the implied warranty
8 Z7 Q' d# `* c: g! F - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ }3 P& N, K; n1 A3 a, ] - * GNU General Public License for more details.
( b6 B6 P3 s6 D - */$ L4 ~1 T6 |5 d! J( O0 h2 f
- * b: @" I) V( X: ?( Y: {* J. {
- #include <linux/module.h>4 R' r0 _, m0 w) {3 q& a+ x! X
- #include <linux/init.h>
' ]( h3 H% p- u+ m - #include <linux/errno.h>* Y8 H" u4 ~* @ r6 h# j; W8 ^
- #include <linux/types.h>
Y7 A0 M' Q4 U3 p: x - #include <linux/interrupt.h>
8 N" Q$ z* | z% n2 }# M6 |: J9 l - #include <asm/io.h>
( i2 |8 ^/ C3 T* s, F, D - #include <linux/moduleparam.h>
, ^: g1 O% G7 \4 T$ } - #include <linux/sysctl.h>
8 F; U1 Y3 Z" @% c) i1 ?4 p - #include <linux/mm.h>7 R9 \) J: h3 z" p3 O! P" v
- #include <linux/dma-mapping.h>! x' z7 L- p/ _5 S
- 1 y# ~5 q3 Q% C7 k$ J# t
- #include <mach/memory.h>
* _* Y( S& @6 {; H% _3 K - #include <mach/hardware.h>
a' [" h- Q4 S3 F - #include <mach/irqs.h>; I; y2 i0 Y2 X) A. f
- #include <asm/hardware/edma.h>& h; m* Z; G. W" |* l
) u" L% E% V* p& z3 G- #undef EDMA3_DEBUG
5 ]- Q; d) F" R. v o( k - /*#define EDMA3_DEBUG*/1 C q$ M" V9 g! k
- % x l& \. r) u
- #ifdef EDMA3_DEBUG$ [1 p7 D" c" T0 a6 b; x* I8 g
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ ~8 @& @% _, r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ t9 G. R) C, [- u5 u6 y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). I4 x' a/ W- ]- @5 M E
- #else
$ Q% g+ r* L0 u4 u - #define DMA_PRINTK( x... )
* O/ Z2 P: J% C, ~ - #define DMA_FN_IN! y$ E1 f9 w+ j! _0 s4 z! e9 W5 E
- #define DMA_FN_OUT3 J' T: D+ r. `3 p3 ~( N; ~3 s
- #endif
7 I% v" C! d, }5 t8 t
! m, I% d# D4 j5 g3 M# L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 a( w( t2 b9 f. i - #define STATIC_SHIFT 3- M7 ]- g- a0 k- M- ^
- #define TCINTEN_SHIFT 20
# Y- q$ u& |8 s) G/ h* [# [ - #define ITCINTEN_SHIFT 21+ B5 `+ F' U8 T$ E
- #define TCCHEN_SHIFT 22
0 @4 ^; B$ q+ G5 u" y - #define ITCCHEN_SHIFT 23! V/ x; Z2 j0 V& J5 x
9 V! O I, F. Q0 B' p L- static volatile int irqraised1 = 0;8 g) W: M# H5 B" k
- static volatile int irqraised2 = 0;, U& P0 R m1 Q7 ? H. y+ A
4 B6 L3 p$ D8 [ G! A4 d- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 e D- T( H0 j8 T |( T4 x q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, P ?. B3 v) ~) Z! ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( y' l+ _% ?1 ]) W( M
^2 T+ U* Q; E& q' i: I6 m- dma_addr_t dmaphyssrc1 = 0;
3 e+ m, b+ r! T( u3 N2 T - dma_addr_t dmaphyssrc2 = 0;
) j$ T$ R- x) |, j+ C# h - dma_addr_t dmaphysdest1 = 0;3 t: @6 ]4 Z: s) w. |
- dma_addr_t dmaphysdest2 = 0;
- u4 T! L3 b/ ?' l* h
: n! x3 P2 B) C. `8 `$ R& m+ T: [- char *dmabufsrc1 = NULL;
: w4 x* W) ~' z2 _+ b# z - char *dmabufsrc2 = NULL;
5 W- k& F3 t& q% O - char *dmabufdest1 = NULL;
- l, H$ j1 Q7 K8 [ - char *dmabufdest2 = NULL;
: ~7 y7 ~4 e$ x1 H8 k8 Z+ X - 3 m8 M, b F2 P5 X1 Q3 K
- static int acnt = 512;; N/ D1 T" g! h4 A/ ^+ m+ J+ H
- static int bcnt = 8;
4 w: b( C0 Q4 b) i+ p/ |/ A# D - static int ccnt = 8;) i& S0 L: g: r) c6 V6 {$ x
, P- C8 U7 ]# A& s/ L# M% w- module_param(acnt, int, S_IRUGO);6 M" s* u$ Z- }& K
- module_param(bcnt, int, S_IRUGO);
" i: }4 _9 t5 u - module_param(ccnt, int, S_IRUGO);
复制代码 % o4 i5 n! G) S
: }- h8 L0 Q$ x* V4 e/ Z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* c& ]! h8 N" {6 Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) A7 F n6 _! f" c0 @+ h 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ q; D9 V2 ^. s+ T
# a$ } J9 ?: r& O' B- V6 B
' s) o5 z# G* w; N |
|