|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& J& x; T$ R8 Y$ r x F' j- [code]EDMA sample test application% K2 ?' r8 g6 N8 t, S
- /*$ n0 _ r) L# j0 x$ b8 W$ r
- * edma_test.c
+ B X' Q( D& P9 I( m7 G* y& W - *
) D" u" f5 e; A - * brief EDMA3 Test Application
6 J1 G) k( h. r7 ^( N3 Z - *' p, m0 t# N2 ^! ` Z
- * This file contains EDMA3 Test code.- Y) ^* W; z/ I, C9 h* R- r) u% `! V6 x
- *% X. Q4 Z. `; W, G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 X2 b9 y2 m3 u, K) f5 ~( r& x( f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 B u- P V+ ~4 M
- * TO CHANGE.3 v& o% I3 E' O5 T- v4 {+ [0 b' o
- *
/ i0 Q# G& o0 c( g, H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 P. f1 n6 f7 }' k$ f4 A - *
8 J# C0 c2 W/ g - * This program is free software; you can redistribute it and/or
9 \" r8 H; y+ e+ Q- A; U4 g - * modify it under the terms of the GNU General Public License as8 U; P8 a) d) s( y) g8 B
- * published by the Free Software Foundation version 2.
6 e+ a4 j/ e. P7 j; A- A' i# c - */ N7 M, P- S$ g ]) }& S! Q' v/ k
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( i+ [- o& X! p, {1 }+ S - * kind, whether express or implied; without even the implied warranty9 F v* Y5 P4 u' x8 o7 i, O. I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ S% p Z" z/ q k - * GNU General Public License for more details.+ T" ^) U6 S$ W" b* F5 ]/ N
- */
( ]5 _& V( ?' ~9 H) W/ d) p3 T
/ c' z* q: L2 K: u" l( P& g' {9 z- #include <linux/module.h>
3 g. M% x% y, Y - #include <linux/init.h>9 G# _3 P0 w1 h3 w
- #include <linux/errno.h>* i8 h+ @2 B" J( L: F2 d' _, |
- #include <linux/types.h>
0 K+ _$ p3 s* w - #include <linux/interrupt.h>5 k4 }% |& e0 E* p4 F1 v
- #include <asm/io.h>* x/ u& q9 C k8 h- f$ A
- #include <linux/moduleparam.h>+ D$ p! }6 @* e; z- A( p
- #include <linux/sysctl.h>
/ `, T$ g3 q0 Z. r1 g. d, f( A; L) ~ t - #include <linux/mm.h>$ ], A6 R C/ f- d3 H. X* K
- #include <linux/dma-mapping.h># \* K% h9 K$ E/ `2 ^& T& ?* `* @
3 j$ L9 ^- R B1 w$ Q7 A- #include <mach/memory.h>4 n, H! V2 P5 [, P# L
- #include <mach/hardware.h>* X9 I o& K8 j/ {. `( v
- #include <mach/irqs.h>/ R+ X9 |6 u) {2 U) M+ d
- #include <asm/hardware/edma.h>" ?8 ^/ }& M9 ?2 u/ u' y! Y1 X
- $ I1 u" w5 z" m) d. G
- #undef EDMA3_DEBUG- S, O) |* U; x$ ~) q
- /*#define EDMA3_DEBUG*/+ ?# P- K, }) k+ F$ Q4 I
" N" D# ~+ q4 j: k- #ifdef EDMA3_DEBUG4 ? n- ?/ I* Y. i6 c+ ]# g1 B: J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 Y, M" t1 x3 |1 F& W
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 U* z* Z3 [+ Y8 V - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 q1 g8 q+ g1 i; ^7 b! E( A; s - #else
$ P" v2 K9 e. _6 f - #define DMA_PRINTK( x... )
: b/ L A5 Z; \ - #define DMA_FN_IN
" F; G4 A3 I7 ?/ G - #define DMA_FN_OUT
1 `4 A4 ~7 H; R" ~! c& i - #endif" ^# @( U- X/ X$ B; H1 J5 @
) M u/ ^0 k& O: {% s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 y3 Z& S( I# m4 y5 D - #define STATIC_SHIFT 3
9 o' C) R7 W8 ` - #define TCINTEN_SHIFT 20+ Q) L7 w: Y; k/ H
- #define ITCINTEN_SHIFT 21
7 \% }2 S. Y; M9 S. _* t5 |! @ - #define TCCHEN_SHIFT 22
7 j; P: D, Y! |4 Y! } - #define ITCCHEN_SHIFT 23
' N+ l9 P. H0 D0 A1 _! k( j
0 a% ~6 g: j- O1 R+ `- static volatile int irqraised1 = 0;. K2 O1 e- w! T. T9 J) |: t6 l
- static volatile int irqraised2 = 0;2 `2 p+ g1 _9 ]9 }( v( z8 i0 A$ s6 m
$ p. r% u! ]4 z" P) w6 K, m' w- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); s7 x: ^( t: a; B, |: ~2 @
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) }1 B# T2 J3 a' t, D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 y' Q: n' ]: t& |: `% D. W
. B0 b( \6 d% V, d4 K# B- dma_addr_t dmaphyssrc1 = 0;
) s2 H; E7 r" f: C: u7 @3 ^ - dma_addr_t dmaphyssrc2 = 0;
! r. [9 E2 X7 u7 G - dma_addr_t dmaphysdest1 = 0;
8 Q! y. t( U( K1 ^; W b% e - dma_addr_t dmaphysdest2 = 0;( p/ {' m9 D) p3 V9 j; w$ K
* \& @2 R5 c5 B; {2 E- char *dmabufsrc1 = NULL;/ b2 F: x& i2 O
- char *dmabufsrc2 = NULL;6 Z Q8 X! o' U% V6 i
- char *dmabufdest1 = NULL;
2 H$ t$ ]. e6 b0 a - char *dmabufdest2 = NULL;/ h) v6 }. G! d1 J
- 0 \8 b& C% q, r) @
- static int acnt = 512;9 v, [# R- O0 l1 N) D
- static int bcnt = 8;1 z! T! D o5 ~' s6 t; w" b
- static int ccnt = 8;% N# E/ q* f) F: v& k. i+ Z
- 1 E) ~ h4 {, q9 h0 Z7 M+ T0 n
- module_param(acnt, int, S_IRUGO);
9 U8 A2 B/ Z2 V5 o' R# c - module_param(bcnt, int, S_IRUGO);( q2 R* R: q: b) [; r
- module_param(ccnt, int, S_IRUGO);
复制代码 $ t2 w' r; B- N$ U
! l& B' h' v& @1 F* o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 Y- M( T+ K' i0 A. W$ h 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* W# T: b0 a/ N3 \+ o! Q. F S
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 v; Y$ g6 t/ L* D4 q
! c( o/ x2 E# \+ A6 D: x4 ~$ P8 Y
1 ~ S( r0 J3 |# |! W |
|