|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " c" t6 P$ i# Y% d% Y
- [code]EDMA sample test application9 F2 d3 I: p0 h: f" r/ [3 k! W
- /*
% Z# \ h8 Z/ Z9 p1 f% v4 A - * edma_test.c
( M& }( p& B6 R - *
+ C2 f. l, J* @+ _6 {2 A - * brief EDMA3 Test Application( m7 g6 s% \6 p \ ]
- *# s, u) a, h& f& E+ r
- * This file contains EDMA3 Test code.6 c2 ^8 B6 G5 `1 s' B' j' v
- *
! Z/ o" K; X) e) G& ?3 Z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ S9 X' B. f% {5 J8 U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' Q+ i3 h3 Y% N5 H2 x( U
- * TO CHANGE.) W9 Z, ^' c. T" B: z; W% {; a
- */ C+ H1 {+ a$ n) F
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# C H$ C& C/ o1 D9 ^1 L% ? - *
. P9 y2 p3 J) m. l - * This program is free software; you can redistribute it and/or }9 O$ ?+ B2 p3 O0 v
- * modify it under the terms of the GNU General Public License as
; ~5 s: m( i( M - * published by the Free Software Foundation version 2.
) t0 D0 q0 \2 [! _: ]+ u! X - *
0 j' o" ^ \( U# z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 `. f" |! {, `3 F8 S
- * kind, whether express or implied; without even the implied warranty
6 p8 C0 ~+ @ s& g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. Z0 L8 L* b0 `( y - * GNU General Public License for more details.
1 g. v3 x j' c - */
1 {! Q8 s8 g4 y* { - 7 o! ?8 D$ p' V. B5 V
- #include <linux/module.h>
/ H0 D& H9 }8 G4 X5 L1 l' L, G - #include <linux/init.h>
) C2 b, n" r* a+ r. @% O7 } - #include <linux/errno.h>
! G& ?- l) }' Z4 ^ - #include <linux/types.h>! p/ I. Z# g0 Z( Z2 N& |
- #include <linux/interrupt.h>6 R( x/ N( ^3 }$ S8 v! D
- #include <asm/io.h>
$ Z, |4 p, M! c - #include <linux/moduleparam.h>
7 h" u$ T0 L! S4 X0 {- b - #include <linux/sysctl.h>( x8 q3 p7 T/ Z( u# ?7 [: ]( z
- #include <linux/mm.h>1 ^) q! Q' g! W" n' b: D! e5 R
- #include <linux/dma-mapping.h>' D& M+ Y( A$ b4 W4 P
- : ?6 U( E. i: ~, o+ B, ?
- #include <mach/memory.h>
- E9 K% c, w$ I" Z1 w4 N/ w" h - #include <mach/hardware.h>
x R. T7 Y' H8 y t - #include <mach/irqs.h>$ x$ N7 K \. i1 r# ?6 m& \6 Q9 O
- #include <asm/hardware/edma.h>1 e/ a" q Y( t7 L, G; V" @3 b5 e
- : Z7 e9 B: q+ d$ f% L! Z
- #undef EDMA3_DEBUG. X4 ?- y& h& K% ?0 D0 k
- /*#define EDMA3_DEBUG*/: [+ } `% ] V1 s- Y( k; i) }
( i& m; F5 t2 G$ l- #ifdef EDMA3_DEBUG
; Z/ m, n+ B2 r: ~4 q2 d - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 r8 I/ j K: O" `6 {% V - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ A r* c; W) @4 X& m) b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# [2 R: J, p2 P5 o9 F! s
- #else2 ~6 u4 @5 D$ @ s6 u
- #define DMA_PRINTK( x... ). [, I+ b4 A; s
- #define DMA_FN_IN" N2 h# ^* j4 z1 p
- #define DMA_FN_OUT0 B& k! e' N A( x" q! o* n" q; ?
- #endif9 @! |! u: @, N8 ]
- ! H9 a% {! H8 n/ B9 Z! {. }& j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 |3 j7 m M. B3 u, m7 G - #define STATIC_SHIFT 3, y5 t( [" d7 p! B9 W3 y+ ]& |
- #define TCINTEN_SHIFT 20, _2 _* [& |( n& K6 z8 H/ U7 \3 J8 f
- #define ITCINTEN_SHIFT 21 C5 L% ]1 S: Q$ a/ e" l# V
- #define TCCHEN_SHIFT 22
- v6 n$ ~. s8 u- `3 p, V; O - #define ITCCHEN_SHIFT 23
! j1 T3 h, M, }, w - 3 m3 Y$ e2 h% ?0 t' }
- static volatile int irqraised1 = 0;% d& R% B+ Y* K* p& g" ]7 M
- static volatile int irqraised2 = 0;& ^+ u2 ]4 |4 r; l. @" ^+ }2 Z
- Y/ S2 A2 H, j9 ?+ W( L
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ n0 p3 C- j& }" N( B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- ]2 [: }/ u8 U - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( z) g3 M; z' h$ u+ t
& b9 C- h6 E7 \* ?- dma_addr_t dmaphyssrc1 = 0;
6 Y+ ~! B7 }$ X/ V5 L ] - dma_addr_t dmaphyssrc2 = 0;
1 Z+ \7 V# m$ W I, e3 { - dma_addr_t dmaphysdest1 = 0;
3 M/ [ v5 j$ [ G7 g# h# A8 p* ]/ G - dma_addr_t dmaphysdest2 = 0;% N! Q$ A% H& ]! L# U
- , g! P; x5 a" S' H4 g' U! J% W
- char *dmabufsrc1 = NULL;
: [. u. F- r4 ^8 G - char *dmabufsrc2 = NULL;; S% i0 v% N, x
- char *dmabufdest1 = NULL;
) m2 D! W0 R! p8 A3 {% t$ S( W - char *dmabufdest2 = NULL;; Y8 W$ M1 u3 l
- , E8 g; L) h9 }/ @ U7 C8 j( ~
- static int acnt = 512;
4 b, Z& ~0 ]. Z - static int bcnt = 8;+ t2 r0 O( Y1 e5 |
- static int ccnt = 8;
! r/ S( _# n; d; r3 m
* _4 C7 G! y# O6 ?1 Z4 t- module_param(acnt, int, S_IRUGO);
8 C8 P( x3 v5 h+ `/ ~ - module_param(bcnt, int, S_IRUGO);) h0 I) P5 [1 i) b/ C" P2 S8 d% ~
- module_param(ccnt, int, S_IRUGO);
复制代码 - b6 V- ], f6 D& Y, E
! }& { W. L* D 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 w; {6 V: e: c& T: Z& 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 H4 P$ U- {" ^2 p# Q8 G 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& o; h8 |: W/ }, E+ w9 L: D
{( R- |6 _) G) C) d3 l! K* f' A
6 p: \* g! D# w6 G
|
|