|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 H' W( l: U2 Q$ Q- [code]EDMA sample test application
6 N0 B! R8 p/ M% |; P" d - /*
2 U# F& m% n) m - * edma_test.c+ J! ~% R6 C- @) K# k2 y; w" @
- *
' c. K7 `1 m$ D* }3 ? - * brief EDMA3 Test Application
$ O/ v& M4 _5 B V) u1 ]$ _ - *
* o1 G4 E; \% s( b - * This file contains EDMA3 Test code.
9 r+ V' U) f8 K7 x& ?) d* J! s5 D - *( M) y% Q; r$ [ Z% I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! @4 B3 O6 v9 V: p1 H - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. H7 W3 |/ G# U, x8 n( w
- * TO CHANGE.
& C5 @; `1 @' [. q. C& [ - *8 U& {/ u) G4 R1 O' N
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" P5 r/ Q2 _" U2 ]; F
- *! h" ^; N4 i5 h; K; L
- * This program is free software; you can redistribute it and/or
+ ]% X: m7 a$ v L - * modify it under the terms of the GNU General Public License as
3 `$ y3 @/ Q$ d9 M' z - * published by the Free Software Foundation version 2.
) e9 ?) Y! v2 l; S - *( s7 ^( q9 d3 `, ? ?: t
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 f3 s- w4 H, x( _ k" e
- * kind, whether express or implied; without even the implied warranty$ u2 ~! }$ c# v% A% B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( n# g; ]1 a( L5 j* g! y! ~+ R
- * GNU General Public License for more details.
9 U1 N9 H4 @6 c1 _ G7 y0 r - */
* o- |: V% p: L% u - ; ^/ x" f8 r3 r" @& P9 F! A
- #include <linux/module.h>8 S" N4 t0 s5 j* X6 ^
- #include <linux/init.h>
: A: ]: j }8 E. H - #include <linux/errno.h>$ y( S# I4 c- a% }9 w2 \
- #include <linux/types.h>
6 t' k* M5 S# I4 \ - #include <linux/interrupt.h>
" k7 }/ |& F8 ]7 G- o - #include <asm/io.h>. M! @' n5 \# d$ ?4 B
- #include <linux/moduleparam.h>& r. Y* ^( P* Q" e
- #include <linux/sysctl.h>
) Q$ p6 L V1 | - #include <linux/mm.h>: w; Y; d, ` `( T2 P F* Z( `& J
- #include <linux/dma-mapping.h>
7 B& e M& n7 l! U: C - 8 s: i) i/ ] z% o) x9 e# Y7 G
- #include <mach/memory.h>
$ G8 X8 \1 R0 C# I0 K - #include <mach/hardware.h>7 I/ [3 r0 P0 `& [2 s
- #include <mach/irqs.h># T: M/ k$ K8 T4 q( |! L1 A
- #include <asm/hardware/edma.h>! d, A1 A. I6 F( I7 `/ c
- & O. \# {4 v9 q# F" K
- #undef EDMA3_DEBUG
% o# v* p1 |* K+ d. }8 ]! U* f3 [ - /*#define EDMA3_DEBUG*/
' C. `, |2 ?! O/ h" k; _0 z) h( h - d/ D" R! X4 N) J5 X; B: O6 t
- #ifdef EDMA3_DEBUG
t$ y% G7 }2 p3 B6 i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& v5 G6 B4 Q9 Z X O6 K5 N' q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ [( ~$ |( L: l; M6 u& @4 W
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 k E; ? B. U, p3 o - #else
; |: x. p* K7 g - #define DMA_PRINTK( x... )
2 f1 O$ a$ p2 [ f( k7 h/ X - #define DMA_FN_IN
3 p1 J/ S! l4 Y- u, V4 [& _1 }% x - #define DMA_FN_OUT
0 h R: [( J4 y" k5 o - #endif: f$ u, E6 ^& ?- E" E
* d9 ?. ?5 @0 X( ^- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 {! t2 o& ?) @1 T0 f2 R
- #define STATIC_SHIFT 3
' S, f+ ~: j1 b \& e6 t0 A; y4 ] - #define TCINTEN_SHIFT 204 l1 t# e% y5 i3 }: b9 l% r
- #define ITCINTEN_SHIFT 21/ P, N+ y$ n' [( |- K4 O0 U7 [
- #define TCCHEN_SHIFT 22: d3 T! Q/ h# ]6 Y1 G
- #define ITCCHEN_SHIFT 23
- U4 M/ a' B' ]7 f
2 ^! t, |5 C' k0 x0 h- static volatile int irqraised1 = 0;
5 T7 j2 q, n% c0 N) ~ - static volatile int irqraised2 = 0;
; M. z! X/ \$ c- r! u8 N
/ z$ e/ o( ?. i0 B# T" g n4 p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! `- W! ^$ v: W) L) { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* |; S4 W' k( d2 a3 _2 o/ p4 e7 p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, _6 P4 i( ~8 m2 [. l
- p7 n g7 X) W, I- dma_addr_t dmaphyssrc1 = 0;
: B1 `8 H0 k2 c - dma_addr_t dmaphyssrc2 = 0;1 H' S2 Z3 Z2 P9 x
- dma_addr_t dmaphysdest1 = 0;5 p- x V3 h% W! P0 N* m
- dma_addr_t dmaphysdest2 = 0;5 K! l# Y& ~+ ^& ]' _3 R
- ' b2 c/ [3 N* ?% q8 A- Q% S5 F z
- char *dmabufsrc1 = NULL;
" V$ g, _+ \) t1 g; x# M - char *dmabufsrc2 = NULL;
3 H, f# j2 u1 w/ a. P6 q - char *dmabufdest1 = NULL;
* X; B- e. d8 s7 X0 C2 y% L - char *dmabufdest2 = NULL;8 O9 b2 z c! `& K9 n g0 |
9 L- K# O' o. U3 a6 x! ~- static int acnt = 512;
0 g- E! \; g: p - static int bcnt = 8;
. ~' }/ _# q4 d9 D& @0 n7 u - static int ccnt = 8;: S% n5 _: J/ B# v
- # m" J" U2 L" ]: s* Z' G/ h
- module_param(acnt, int, S_IRUGO);
9 P( q L+ C" I5 a - module_param(bcnt, int, S_IRUGO);) U% v+ B% o# ]- S' W
- module_param(ccnt, int, S_IRUGO);
复制代码
1 \0 ?- e4 X* _9 `* \" U+ P
- q% ?7 v5 b- W( R6 ?8 Z# Y3 R9 n 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" @# _5 E) J3 a, R8 j) b5 Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: i" U- a8 X& V: j7 _
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 Q5 O7 \. k6 \" K4 b! U# l
* q( c; K0 l/ w" D b+ A% n$ C0 _
: o! \7 d- s. W( J ? |
|