|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 B8 A% Q9 T* C& N* }6 Y6 _8 z- [code]EDMA sample test application
# k, |( T T+ N, r, d# a* L# C - /*6 X: E1 ~ U- r0 n
- * edma_test.c, a$ o# [$ o' D6 C# x
- *
' h, ] c/ Y" N8 v - * brief EDMA3 Test Application
5 n- c1 \9 X5 Z2 _2 k9 c# O - *
" p( V. _$ h! a# d: k - * This file contains EDMA3 Test code.
$ [! a. J2 x3 i7 t2 K& m1 } - *2 a) R' [( \- A* X9 f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- E- W" Y: h3 E" L( y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT Y$ D2 y) w8 r% A
- * TO CHANGE.
; E' w9 i- `& X* c* L; w6 _ - *- ^. X/ U- ~1 l/ i8 o& i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 r7 s( T" o( j4 }$ p% ]2 x5 `
- *, s' N9 F$ j+ W7 E
- * This program is free software; you can redistribute it and/or; ?4 o) A$ a2 {% n6 O
- * modify it under the terms of the GNU General Public License as1 H( E4 t) O# B& E/ ^; g
- * published by the Free Software Foundation version 2.# Y0 u8 i/ H5 Q4 K( ^% L
- *
+ b2 `4 o X( d: D+ r8 P$ ^0 _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; r9 W* I3 W/ H2 l
- * kind, whether express or implied; without even the implied warranty' Z) Z- ^ S' s* \& T7 S1 A* S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ P; @3 F3 M& W) d2 e - * GNU General Public License for more details.3 n/ U+ N9 k0 b2 Y) J, @+ A
- */* N7 D, ]" G3 I
8 }) A' W8 i( p) i4 H- #include <linux/module.h>5 F/ r. b! M7 S" K) W; f% }' I: `
- #include <linux/init.h>
' m! G+ U% x2 U( m( }5 S - #include <linux/errno.h>6 `3 Z/ w' x* Y8 K
- #include <linux/types.h>6 D; L4 u4 S z% X8 \
- #include <linux/interrupt.h># U, A* m8 n ]. i1 ~" h
- #include <asm/io.h>
- y; I5 }" O, z) D - #include <linux/moduleparam.h>
$ ]7 T! ?. |* z T$ K5 x - #include <linux/sysctl.h>
5 _- V8 l6 d, h) T& F - #include <linux/mm.h>
7 H! c. B% x& L. e2 U: g- l( E - #include <linux/dma-mapping.h>, P' _6 S- V9 K. x
- 0 y+ q- v# o9 V# l; j9 p9 s9 _
- #include <mach/memory.h>
, x3 t$ A$ o) Z# c. o+ r3 S/ L( B2 P2 O - #include <mach/hardware.h>
; @3 w# i I2 a* J4 \8 r - #include <mach/irqs.h>
/ B; G5 t5 d! ~( X4 x - #include <asm/hardware/edma.h>% P @: U1 ^& c/ ]$ Y
- 1 p4 j4 }7 Q/ K/ ]# |; B2 b
- #undef EDMA3_DEBUG3 J0 b! a6 Z9 m$ p& B
- /*#define EDMA3_DEBUG*/
0 {" J$ A M" }: |8 R7 f" T
4 F( F: m! u* X- U- #ifdef EDMA3_DEBUG
& F# b x8 M6 s" N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) @) M: v* X. j' z+ v. r
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 |/ s' v; |9 e! V3 \& N, V8 @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 \7 o. I4 J" L) S! ?7 ]
- #else
" r! A0 A& q" Y* h, d - #define DMA_PRINTK( x... )1 Y$ c3 R0 d) o; b/ g" ~5 [
- #define DMA_FN_IN
; A; x; }+ q; u% w& z i8 \. B% U o - #define DMA_FN_OUT
5 ]3 Z: G3 P) e - #endif
9 H6 |1 T; y3 U) s4 q/ @3 i) _ P
6 \! l0 J0 _5 |( W* j. V2 r! E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- X# K& Y- E- F0 Z. b# X$ v8 q" f - #define STATIC_SHIFT 3
2 y) J" t4 s, v; Q' a - #define TCINTEN_SHIFT 20
* u% s* L: T3 X. v - #define ITCINTEN_SHIFT 21% G: g# a! F$ U) a1 s/ b! V, \( U+ p
- #define TCCHEN_SHIFT 22. k7 S' Q% S7 N1 C8 `6 o
- #define ITCCHEN_SHIFT 23/ D: |, d- B2 T2 C
- % c( W! i: v) H6 Z2 a4 P
- static volatile int irqraised1 = 0;
3 z K2 ~( x0 W& L2 h - static volatile int irqraised2 = 0;# g u; F- E0 I/ z8 |6 p4 r
F2 y7 k: h6 ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" k4 r4 T: E; d& r; `
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& L7 p* d% j: Q3 t$ O( x - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" u. I9 ]6 M2 r( A4 P+ i
4 w$ N/ r+ @0 b6 c- dma_addr_t dmaphyssrc1 = 0;
: l4 k" Z2 J O3 [; e5 g& H - dma_addr_t dmaphyssrc2 = 0;
_1 ^9 R; [" F( q* v - dma_addr_t dmaphysdest1 = 0;
0 [ Q$ f! T& ]% @& @) N. C+ k$ o - dma_addr_t dmaphysdest2 = 0;) C! |; H7 i! c8 M6 f9 n( {
- & {# b5 |4 y1 z) F/ V
- char *dmabufsrc1 = NULL;
, O: o0 \ J$ V1 N% n* @ - char *dmabufsrc2 = NULL;/ a- {* ^" V" S$ r
- char *dmabufdest1 = NULL;
. { U% B! ^0 y; ]* w3 z* i% j - char *dmabufdest2 = NULL;7 I5 P* X5 i' w- z( E! s
- 9 a; x/ ^/ {7 {0 E$ N% b" N
- static int acnt = 512;4 J& L5 H% s3 {6 O. @1 J0 R1 L% C
- static int bcnt = 8;
1 U; _% d G7 m- f" ^7 L - static int ccnt = 8;/ \5 M2 o; s( N% n
, h1 u/ n5 Q2 E$ h( L5 i- module_param(acnt, int, S_IRUGO);
b7 z9 {" @8 m - module_param(bcnt, int, S_IRUGO);
5 d- h& F3 G; Z+ Y) ] - module_param(ccnt, int, S_IRUGO);
复制代码
9 ~. u9 X9 B o+ \9 u6 U5 y+ E, l T, i; s: z: M; u5 Y3 ?6 Y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 h) I( E4 H0 N
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" q" |: g* [: e" @( h+ k
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 @# ^" ^* ]8 d* ^4 G" `3 T+ }$ R5 ]% n# ]1 o# u% Q" ]
; D) q0 T5 ]' f |
|