|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 K, f+ L* N( W
- [code]EDMA sample test application
& z& h* ?4 [% I+ ] - /*
& z2 B* \0 u# @$ m - * edma_test.c
2 C! j" X& ]- p/ r& K# n - *
( ?& S _2 z1 w; k1 A3 F - * brief EDMA3 Test Application
0 ^( @. D7 d. g U) f+ ~! s5 m - *
/ T; a1 X8 t/ k8 B) p$ M O) _ - * This file contains EDMA3 Test code.
~; H' d& e7 c, V1 Y - *
6 b' M W" U0 D( ~! ^ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' u* p0 }$ `8 ~2 v1 r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; N% u. |5 B& m2 _0 R6 w& o# V# l! g' j - * TO CHANGE.
. `) P' d2 L! ?$ J1 i5 _0 ]8 l - *& N+ @3 o- b! e3 g+ {% j0 q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 a4 ~! y0 ^. U& p7 P- o$ P
- *: m9 O" P1 n/ I+ R/ @9 f/ c
- * This program is free software; you can redistribute it and/or4 R1 R" o- s& e; V$ l
- * modify it under the terms of the GNU General Public License as
- F* j* i$ H" ?( X p - * published by the Free Software Foundation version 2.
1 `" g' O% Y/ L8 S9 j$ }3 E: O - *; f/ v8 v. U$ U1 R0 k/ \/ s0 o
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any& K! w a' z5 Z) b5 y
- * kind, whether express or implied; without even the implied warranty% D( G O9 d. ~7 ?+ h/ l6 c( ^
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 \; X4 d" Z: m+ \( V
- * GNU General Public License for more details.
6 S% |$ X+ d8 S, Y; @ - */
) w( a% n8 V* @& {9 G( W - 2 A( D+ u1 l& v4 ^) r/ A% b
- #include <linux/module.h>2 V. o; A {, c9 T, t7 J
- #include <linux/init.h>
8 V- D8 ?) D8 v7 K: b - #include <linux/errno.h>9 N$ i P/ k+ I. o' Z0 h* C
- #include <linux/types.h>
_6 g5 U0 P$ `' i - #include <linux/interrupt.h>
" U; p3 g$ Y+ J' \% ? - #include <asm/io.h>! [8 a+ @ h2 u3 J& x8 M: ]' y
- #include <linux/moduleparam.h>9 Q! _8 g4 {6 s! q+ c! a
- #include <linux/sysctl.h>
" W A8 G3 Q7 S& Z* s q. t - #include <linux/mm.h>8 q. \3 f7 h& o* i4 j
- #include <linux/dma-mapping.h>" p+ y$ e4 m g2 D
& r5 s! L3 y+ [6 k9 p) |& I- #include <mach/memory.h>, b* w+ {% ^% v: ^8 u0 s
- #include <mach/hardware.h>; o& ] d( L1 p+ {& z3 k% n6 `
- #include <mach/irqs.h>
0 k# z8 E2 \, ~9 Y - #include <asm/hardware/edma.h>
" `% y# O& m5 h6 B5 Q9 a
5 f) r1 |- E: a" E- #undef EDMA3_DEBUG
9 W; h) K. J. W$ l - /*#define EDMA3_DEBUG*/
( Z6 w8 }/ a5 O% R9 T" Z) ` - 4 ^3 B/ Y" v+ @" S/ K
- #ifdef EDMA3_DEBUG
" m1 u: F) i- ]9 a5 _5 \6 K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ n; T, |, R( K3 c& N! v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( l. R4 y( ]) v9 U" @/ J
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; T( _4 @# @1 s2 j - #else
) M& K$ g9 y: M1 o. v) F$ q - #define DMA_PRINTK( x... )
: G, I3 {4 [9 }) \ - #define DMA_FN_IN& b% @4 z/ U B/ v1 `' Y
- #define DMA_FN_OUT
6 k o, [ s9 m* @; Z - #endif
' z0 ^1 z) A, c0 n2 ~- L - , A8 r8 D4 J# F$ K7 f4 \5 j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, X; D+ V5 o+ Y4 B$ t& N( e p% { - #define STATIC_SHIFT 34 m) K/ u: k5 Q( O, F; V
- #define TCINTEN_SHIFT 20' o- f7 K2 m" U0 ^3 |/ b
- #define ITCINTEN_SHIFT 21* }' k7 M4 N% C6 ^' E
- #define TCCHEN_SHIFT 22
' U# Z: N/ F: g0 x$ T% H - #define ITCCHEN_SHIFT 23
) w' d! T$ ^' r V6 J0 L$ { S: P - 7 K8 j* ~8 _* B4 j
- static volatile int irqraised1 = 0;) a- Q% K/ Y4 ^8 S; b
- static volatile int irqraised2 = 0;
! M+ o/ g8 U( E4 g3 s) e - ; ]$ E6 h$ `7 _; p& Q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 ?( c: z! h' D8 z$ Y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: b# [8 _3 E% v( _: R8 g: J- D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& D9 K$ w, {9 X1 K
- . e& G0 P& @6 ^: }# U, H, Q
- dma_addr_t dmaphyssrc1 = 0;/ o2 |) m |2 Q, d$ j
- dma_addr_t dmaphyssrc2 = 0;
5 E7 K# q. M2 V7 Z# `/ S; T - dma_addr_t dmaphysdest1 = 0;
3 r3 I/ J0 k2 M& R2 A - dma_addr_t dmaphysdest2 = 0;
/ p" J0 X: \0 s) n! C2 p- C
! p9 t3 H' I5 A- char *dmabufsrc1 = NULL;
6 X' Y8 C+ S. U - char *dmabufsrc2 = NULL;1 j0 D. T1 I$ G) p
- char *dmabufdest1 = NULL;
& u* B2 B: }' C - char *dmabufdest2 = NULL;
) u* B$ V/ g3 A$ v" E - 9 t; L5 e d$ T: d! j
- static int acnt = 512;1 L' S, T7 D* K2 C- d: x
- static int bcnt = 8;
: ]- \ L/ B+ V - static int ccnt = 8;
$ V9 ?4 u8 z) s& |3 u. M" Y @
& s3 Q& |- L i( h4 v0 t+ s/ Z6 m- module_param(acnt, int, S_IRUGO);
" q9 o8 L% B4 A. G( V, P - module_param(bcnt, int, S_IRUGO);
2 ?/ e3 p- d8 g' f( M7 Q# z - module_param(ccnt, int, S_IRUGO);
复制代码 % f4 p9 ~8 w, Q- {- v2 E! a
9 U, W1 d0 q1 a9 Y5 r5 _9 g+ q) e
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ s5 A# _) E% i5 [# B: U5 carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; C, y, t% T1 ]2 D7 N; z- N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ [9 x p f1 i4 q2 {
5 X$ K1 k( ], o
) W7 j7 q1 K8 a1 D7 Y' v+ n' W |
|