|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- g" s3 X4 g3 e) k- [code]EDMA sample test application
$ U) ~: ]" d" G, h - /*
# A) u+ q: x9 [4 B - * edma_test.c, P: g& w2 H# `/ |' A B* ~
- *
0 j7 s; d& {" X0 H1 ?) B, E - * brief EDMA3 Test Application
+ q1 y6 x, m+ ] - *
7 P+ ~0 O( l+ C - * This file contains EDMA3 Test code.8 s5 g5 Z8 Z+ E8 X$ [
- *2 J* z9 H& P( c) N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 ~( n5 J& l9 H' X+ ^
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ S' Z+ ?3 U# b1 n) A4 I
- * TO CHANGE.2 `8 Y- N7 O% @# Q" v2 B
- *
3 h3 o6 B$ i4 a; v, ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ w$ C& l' b$ @ - */ M, U9 z: m7 [0 @# \
- * This program is free software; you can redistribute it and/or
9 v$ H4 @& d- r7 e9 V5 u$ [# C - * modify it under the terms of the GNU General Public License as! t* C( F+ I! w3 y9 T: r. L
- * published by the Free Software Foundation version 2.1 f* S( {, ^! V' a$ `
- *
- r: P1 a* R2 n& W# E! O: G$ T9 z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ _0 ?5 m @8 n; f
- * kind, whether express or implied; without even the implied warranty$ ?! `- {6 N. ]9 A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. m9 X" {4 j* S: F( }
- * GNU General Public License for more details.
* {6 M" U/ W- P j4 r - */
1 ?1 g ]/ @: F3 u+ `
4 z8 v) R/ M0 t) c! `5 J- #include <linux/module.h>% r6 M3 z$ J% E/ r5 V5 D, i
- #include <linux/init.h>
- H: T" f9 S4 x+ o1 S* Z - #include <linux/errno.h>/ t$ _2 G& H% J
- #include <linux/types.h>
8 X* D3 @) ~8 n! L' z - #include <linux/interrupt.h>" l1 n7 z# i% s
- #include <asm/io.h>1 E& q( J9 J% |4 e% x
- #include <linux/moduleparam.h>! ~: F9 x$ N: W- m1 X) s6 n/ {% i
- #include <linux/sysctl.h>
6 B8 h* p3 Y; l. h1 z' C0 b - #include <linux/mm.h>" m m" i' X+ i5 K. m/ j' a
- #include <linux/dma-mapping.h>
* q. k) P* x, N. `: ~
& P, S0 `8 \! S7 q6 d- #include <mach/memory.h>
$ r5 Z2 B0 c: D9 a1 v6 g( U0 p - #include <mach/hardware.h>
( ~* V: E( w6 w% e! b. y - #include <mach/irqs.h>
O. A1 I2 F0 C+ K! k' M$ m' i1 | - #include <asm/hardware/edma.h>
$ A0 F% Z0 a# S9 \3 t7 l0 p - , A( `% j9 A8 x
- #undef EDMA3_DEBUG
6 _1 m) U. ]% F3 B* Y1 A - /*#define EDMA3_DEBUG*/
7 O5 ]4 V: D# k - 3 C; W, t& [1 U9 `" ^
- #ifdef EDMA3_DEBUG( R8 k, ]5 n5 q4 ^$ o- u- T% R
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. h$ i7 u3 E9 z- s/ N+ A, L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- `$ a: Z, N( z+ M
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# |# h' g( j& E( c* P! Z+ x2 X0 I5 l, { - #else
, \" I% S4 ^4 Q* }6 C; O - #define DMA_PRINTK( x... )
7 i* h! H8 U1 A3 I# ` - #define DMA_FN_IN) [8 }$ A. Q3 H5 x" B& y
- #define DMA_FN_OUT9 z7 p/ q, N" ~4 f
- #endif
5 W& a0 _1 g; C
8 C" o! F4 X; s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 T: H0 f3 N, T4 {4 i2 O
- #define STATIC_SHIFT 3
/ k3 O+ y! Z" z+ B' R+ l1 f - #define TCINTEN_SHIFT 20% ~: ~1 y- p7 l8 I0 m" h b0 a( a
- #define ITCINTEN_SHIFT 217 q, @' }1 e9 N* B* Y N# o
- #define TCCHEN_SHIFT 22
& e$ k0 R1 a7 C c - #define ITCCHEN_SHIFT 23
2 x) Z @ y- T; C7 n0 z8 t
" L) U) L" F' K9 `! m- static volatile int irqraised1 = 0;
" b& J" `1 R: M( @ - static volatile int irqraised2 = 0;
* m8 v0 B+ Y9 n; X( I
" H. P8 j4 |# Y Z* w6 I9 z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; D! `" i, [5 c# E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ K7 I/ W$ I& M5 S, k* ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" D6 `: U8 m4 {- B) A+ @( v9 W" x/ q
u7 Q I& n! f2 ~- dma_addr_t dmaphyssrc1 = 0;/ [3 n4 g) ~& r- E1 ?( y2 b4 [
- dma_addr_t dmaphyssrc2 = 0;! o9 b/ y$ O, }7 t: ^
- dma_addr_t dmaphysdest1 = 0;6 A6 f, k+ j, U" g, J( S8 j
- dma_addr_t dmaphysdest2 = 0;
. z+ e+ v2 E7 m9 M; | - I* Q; |* Z% }. C% B0 ^( |, q2 @, P
- char *dmabufsrc1 = NULL;6 N D: a1 D. ?% E! e
- char *dmabufsrc2 = NULL;" g0 i9 O6 ]" z! o7 `/ W
- char *dmabufdest1 = NULL;
& M0 `# a- [% L3 }' u* u& B - char *dmabufdest2 = NULL;
$ }+ B9 I: T7 C+ B - , O6 n/ m/ V1 W$ H3 R$ h
- static int acnt = 512;
: P2 k" q8 L' `: ^ - static int bcnt = 8;/ J% w8 h& I$ [) g
- static int ccnt = 8;$ \5 J/ C9 B# V8 k5 X
- $ c3 ?4 O* d4 W
- module_param(acnt, int, S_IRUGO);
) @ g! P( O2 h2 S$ y2 J0 x - module_param(bcnt, int, S_IRUGO);
U* G1 `5 t4 Y - module_param(ccnt, int, S_IRUGO);
复制代码 ( j" N$ u$ X3 ?+ K9 O
( |, N. u. |0 b9 w1 u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 |1 S: h2 k/ E3 C; Z2 @- d9 H. iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ F( v4 Q3 F- K9 ~8 h2 A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 s4 D, ?& [9 x6 n+ K+ }# V8 Y
4 ` U" E, ~- N7 u* J
~7 e6 Z4 w5 ~ |
|