|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ I; ~* S. s* F# U$ M- [code]EDMA sample test application
1 {; Q2 D) j" U; I7 O - /*
0 q$ |8 M! ^- O0 }. Z! i - * edma_test.c) i; m& Z5 Z& r |1 p5 r
- *1 z; ?( C7 ~) j) a" E/ v; ^
- * brief EDMA3 Test Application
+ m; i+ @5 i0 P1 s - *" S. P5 O% l0 g7 y4 @% n, d2 J
- * This file contains EDMA3 Test code.- v9 z) e& d( }; o
- *
, P1 d0 Z# T3 b& I) {) @+ y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" H# d( z3 H4 R, @6 _ l* m. H) `4 V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 K& p% f# w( q' q- `
- * TO CHANGE.( o8 Q/ M# ]8 ]% Z
- ** R1 }8 y p6 n$ n- b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 N9 k! w" E) D1 p3 x
- *. o E# H2 ~6 V# L0 b/ x
- * This program is free software; you can redistribute it and/or
. c8 E/ c9 ^; h/ U: N7 Y - * modify it under the terms of the GNU General Public License as
+ g9 Z1 J% z5 L% H8 K7 Z - * published by the Free Software Foundation version 2.! s0 v5 F1 u% d+ ~! s0 i
- *
; r( h2 s5 k4 e9 M9 O& g; @* I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, n" y% b# e% g, L0 ^ - * kind, whether express or implied; without even the implied warranty( H; h+ G3 p# x5 h8 [
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 R% Z5 |0 g+ i2 \8 J
- * GNU General Public License for more details.
0 q: O! J3 ]1 J! m4 A4 r - */6 w; Y* w( j2 q, E" N* j9 z- x
2 u9 g% T K2 j0 O* ]( K; ]- #include <linux/module.h>
3 A, Y+ z k+ \8 p6 ]" \$ _# t - #include <linux/init.h>
6 U. h9 z) f5 i5 G Q6 _& f( f - #include <linux/errno.h>
0 U: q" o: J }0 q' v - #include <linux/types.h>. \& ~) M# y5 u% C
- #include <linux/interrupt.h>
$ u8 C* U7 I' l$ ^- @5 X8 A! w - #include <asm/io.h>
; A4 D% g8 O: H7 d: F* N |7 \+ ` - #include <linux/moduleparam.h>& M7 u: L: H, i/ S; S r$ E
- #include <linux/sysctl.h>: |, j, q9 A6 C; _
- #include <linux/mm.h>
) o; w3 h6 r% Q4 Q - #include <linux/dma-mapping.h>( I) o6 j3 E7 T8 b
- 9 R ?; f2 Y2 Q |, e. b3 a! x! l
- #include <mach/memory.h>
& D: s) ^( ?, j7 h$ m( R* S - #include <mach/hardware.h>
9 G: Y! C- N" c9 F - #include <mach/irqs.h>: A4 \ T: J( E4 L6 A
- #include <asm/hardware/edma.h>
' d W' C0 S! c1 i5 K, v U
% ]) r+ _9 l, T: N$ e- #undef EDMA3_DEBUG
) k6 N2 @6 x( O9 f: v U+ z - /*#define EDMA3_DEBUG*/
. i' l& F F" M" _! k
. Y2 J, L; I! M$ B- #ifdef EDMA3_DEBUG/ g( B b/ E" @) j6 t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' P! a9 \8 B- {0 [/ p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 M3 y: i+ n. {" y' M1 i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 j" |# |1 N/ f' k7 D; Z- O
- #else
: E( r3 M& Z& e - #define DMA_PRINTK( x... )
" Y" p$ ~# B" U4 q - #define DMA_FN_IN- X0 }" }8 w( I) \3 w3 J+ K
- #define DMA_FN_OUT
" T% j% L5 g) c! D - #endif
( p6 E% c! ]. s - ' P- }) c4 W8 ?! | A; g, g
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ l" L7 o. B* J9 ?/ @ w
- #define STATIC_SHIFT 3
- N% A; h7 R* l8 R) r - #define TCINTEN_SHIFT 203 M+ d$ H3 g1 w& g; T& G( Q
- #define ITCINTEN_SHIFT 21' I: p1 w- A" `+ L
- #define TCCHEN_SHIFT 22
# z7 ]/ @3 r. H5 Y/ Z: r; @ - #define ITCCHEN_SHIFT 23
" A+ y e8 i0 K% y/ m' x% C# E
9 J6 q) ?) U# e9 W0 W0 z% S! Y- static volatile int irqraised1 = 0;
$ P/ G' r- {$ G5 D* C4 @ - static volatile int irqraised2 = 0;3 n5 J. ^, Y1 y! P
- ( I5 Q0 A/ r. w7 ~$ u" O2 E* L4 @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 p h9 O# W+ I8 F8 A/ N1 d5 U! C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- Q& u& w& O2 n& E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% l- \( \; }8 g3 y* Y8 y k8 J$ C
- " K& X5 i M3 n& W! F
- dma_addr_t dmaphyssrc1 = 0;, u6 U4 U& k% h; g6 B* {3 \
- dma_addr_t dmaphyssrc2 = 0;) ^& M) ^1 \ d' p
- dma_addr_t dmaphysdest1 = 0;! D5 A3 ^% @" z' u1 {
- dma_addr_t dmaphysdest2 = 0;# X: H- Y$ V5 K# z
- ! d) l5 D6 w/ i! j
- char *dmabufsrc1 = NULL;
) ]+ I# I( C, Y6 B0 T/ i& Y - char *dmabufsrc2 = NULL;: |- i& e. A6 r2 {7 y
- char *dmabufdest1 = NULL;& x7 P0 r: o7 @2 G- W& A
- char *dmabufdest2 = NULL;
* A- Q' z" k, b& I! M* W5 _ - 1 [- q- B" j+ b' F/ J: j
- static int acnt = 512;
[+ N1 Z( x6 ? - static int bcnt = 8;
# M1 V/ Z N$ `9 \ - static int ccnt = 8;( c: _( k0 j4 O) Z% f" n5 z5 V" @5 L
- , O/ e, v0 S* c
- module_param(acnt, int, S_IRUGO);
) c# z, z. P+ C - module_param(bcnt, int, S_IRUGO);, s, J C: _# ]5 d
- module_param(ccnt, int, S_IRUGO);
复制代码
" i2 n3 ^9 T4 ^/ L# ?1 a( B8 g
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, s ] v$ t5 h( Q5 x2 A$ o9 narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 A7 n0 g; _; p# A' n% z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 V- C2 P* @9 I: e4 N7 d6 Q
9 d* g( h3 M' J- u
0 f( c" Q0 l" I" V( H
|
|