|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
n8 f! e8 k; ?- [code]EDMA sample test application
. e4 T, d) |+ X3 D' e1 [) D - /*$ [9 h( ^! }$ H8 R! K% n
- * edma_test.c
2 E$ z5 @* `" c3 P( _/ G - *
: _5 b2 e( ~6 h - * brief EDMA3 Test Application
# b' m/ i$ e8 C0 K) v( ?; j - *
$ U/ C, |/ x1 Y6 W - * This file contains EDMA3 Test code.
5 E7 Q: Q( m1 y6 B' H) D - *
2 V7 p/ [" J/ i/ _: E - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" v y, x3 a1 c- j$ ^3 A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' {& C! U5 N8 |( t {" j - * TO CHANGE.) l) B8 u# C( p
- *9 R% z9 [) k2 g& | f/ G
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; F. L% X/ p4 R7 j% t1 g( c - *
3 j0 [8 O x( B9 m' x4 B+ N - * This program is free software; you can redistribute it and/or
, e/ J$ D% L& z6 V$ t; L: K: b - * modify it under the terms of the GNU General Public License as
0 ^! o" u4 D& g6 A) [ - * published by the Free Software Foundation version 2.
6 \7 G1 W. F; b - *& G' ^' y1 n0 y: H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 m1 }- R$ z$ t) G, H
- * kind, whether express or implied; without even the implied warranty
% B9 |+ U& T5 z; A8 {& `' B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' e/ ]: |! N# n/ K$ Q1 Q - * GNU General Public License for more details.% D3 S! R& `/ e
- */3 g: L/ M+ a$ y5 l
+ V0 `0 a6 @ _1 ~% Z- #include <linux/module.h>
# P& R- R8 J i. B - #include <linux/init.h>- C& D h! X. y$ w( i) C" R2 e; h3 {
- #include <linux/errno.h>
* a. P4 V/ s: D# y4 ]' P - #include <linux/types.h>. ?' J) Y- u: a6 s1 L
- #include <linux/interrupt.h>6 p7 ^5 W9 ]! s+ e V5 d
- #include <asm/io.h>( j, ^3 J" L, W& o4 {1 `) T
- #include <linux/moduleparam.h>
0 ]2 P2 v9 W* ~+ I W - #include <linux/sysctl.h>! r4 b9 A5 B" ?$ e% |0 K. `$ Z- x/ q
- #include <linux/mm.h>" t" g+ R+ i; P3 H/ G9 ?1 T
- #include <linux/dma-mapping.h>
. Q( H J: T0 c! M/ E) }
3 f$ Z6 l" O5 P& O- #include <mach/memory.h>
% j) I$ h J5 s, F2 `: K& p& C0 h - #include <mach/hardware.h>& p& _/ T8 J2 O" U6 W
- #include <mach/irqs.h>
2 v ^6 D+ O; B' x! d T. |% i - #include <asm/hardware/edma.h>
0 z* S) \6 L) l: t) ^7 _ - 0 ^; |) t; Z% C* X- c% C! s
- #undef EDMA3_DEBUG
( G4 h) ~3 z1 [% @) h1 m+ O# I - /*#define EDMA3_DEBUG*/, W) h3 U' G/ I4 Q2 c
- ( N. _0 C! y6 T6 @$ o
- #ifdef EDMA3_DEBUG
# S9 o7 L$ V# C6 x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: v' L) S+ L: B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. Q# S# k. B( H3 o+ {) ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) l$ W# q) Z6 o; M1 J( D - #else
# y4 q4 J. k+ y - #define DMA_PRINTK( x... )
: c9 v5 I. F1 D9 N - #define DMA_FN_IN
) Y8 }. h2 w" f, C) H - #define DMA_FN_OUT% ?2 J% Q# n9 ?5 _8 L" K8 P1 Y8 h
- #endif5 K+ ?7 [: y+ V3 e" V0 }" P) k" R
1 ], G0 o! _# X d- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 F9 Q9 `/ |+ {' t2 M* L% q - #define STATIC_SHIFT 3
?" o {# l' ^2 D) _$ d - #define TCINTEN_SHIFT 20" j2 x0 s; G! k9 l" l2 Y
- #define ITCINTEN_SHIFT 21
E, x" g, D" j5 M! c - #define TCCHEN_SHIFT 22+ j1 j* e. A0 S' ?1 ], h6 J0 _
- #define ITCCHEN_SHIFT 23
+ F' ]$ h: @) ^; V9 S. \5 L
2 a' ?# \9 L% g c3 {' N- static volatile int irqraised1 = 0;
0 d/ M; \4 b* ^7 z, @( s - static volatile int irqraised2 = 0;4 w" B, [" q# x w1 T, t
- + ^9 N5 l' E+ M6 X3 k4 T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" q3 C8 c' i2 s! P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ y/ _6 q. u0 t0 A( C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* t# ^0 W2 d5 u5 Y; q
- ( @3 L3 W; Z* O. _, p' s, V
- dma_addr_t dmaphyssrc1 = 0;
3 G$ D3 c: ~1 j( N; ` - dma_addr_t dmaphyssrc2 = 0;. R7 T+ I- F2 V' A
- dma_addr_t dmaphysdest1 = 0;3 O0 ~# L) h$ J) c5 A- D4 i8 v
- dma_addr_t dmaphysdest2 = 0;
3 D8 I4 Q7 j: G9 w) B4 D3 p
2 ~" v. B" m" ~$ e1 n- char *dmabufsrc1 = NULL;) o$ e" W0 z6 v& \. }7 Q
- char *dmabufsrc2 = NULL;% A$ u$ `# X+ ?' R
- char *dmabufdest1 = NULL;: h( k+ {7 e+ ^1 o) J" m- |3 E
- char *dmabufdest2 = NULL;
, O( T' Y* E4 q* d* ] - 0 X2 [" w" i2 N) ?0 r2 [- T, P0 n
- static int acnt = 512;
+ f* p6 |8 W4 f - static int bcnt = 8;9 @; F% t! r; u. f# u7 J5 N e) I
- static int ccnt = 8;2 ]3 P8 m+ R0 B4 q) Q P1 P
$ u9 y8 z0 ?; q" g% O& K" L- module_param(acnt, int, S_IRUGO);
9 \" P9 ?% [& [ - module_param(bcnt, int, S_IRUGO);
) q5 h4 F0 M7 |0 \3 ]4 `1 j+ }2 ] - module_param(ccnt, int, S_IRUGO);
复制代码
0 o- g" m$ T% G& v- n. G
* D f- K' D( |5 t7 [" K 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- Y+ X" ^( V N- u. r* u; ?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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 ^' N7 O4 W) T' G. i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; b; ^5 ~( P4 m/ U3 _& b
: f3 H' x2 L% O+ ~
) P) f; _' ^0 d) c |
|