|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- f% V* h; P- z4 f5 `* _1 }- [code]EDMA sample test application
6 M; n( R8 O) I, a9 D' z - /*
+ P5 s2 n2 C1 c/ E- |% q: o - * edma_test.c! m% u* X5 c& B0 O
- *$ {1 q) R* o n# l+ o# ]
- * brief EDMA3 Test Application/ r% h! u$ R' p3 r, f/ A1 W4 s
- *) v9 J: @" M+ C$ ^
- * This file contains EDMA3 Test code.4 A6 ~ s9 }4 E5 p
- *
5 P! ?5 o2 B' N m% u - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* E4 e; K- h7 {( o5 Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 A7 }; Z, x# z Q. V+ v1 U - * TO CHANGE.
! g% a' H" a5 N$ ], I( V* ^7 d: m - ** g0 O" M8 {+ `3 I, P
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- V |% Y* }& _+ b f* P* f - *
: W/ N$ _. z5 w" m" F A; e1 M( w- U - * This program is free software; you can redistribute it and/or! ]; |& W' f8 |. z; \9 f, j
- * modify it under the terms of the GNU General Public License as
E2 }+ Q/ d& Q' G& _7 i - * published by the Free Software Foundation version 2.! p9 [, \5 q( R4 V
- * `5 [: m( w/ q+ T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 u/ F0 B0 t- g/ I4 h3 G. J
- * kind, whether express or implied; without even the implied warranty1 a2 g9 b' |, l1 i! q) d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! D$ v' U9 l( |5 G8 e" O! h3 i - * GNU General Public License for more details.3 r$ @1 i+ @8 T- M
- */) X& _) ~- f& C; P% K
9 Z8 K2 _# Q& X0 L, C4 A! O- #include <linux/module.h>
. |8 `6 X5 O7 }/ L9 X2 l } - #include <linux/init.h>
0 F/ c o6 N; K W) Z - #include <linux/errno.h>
! B: t* ~, k( d/ z7 Z9 N$ [ - #include <linux/types.h>
2 B" O( S: p E. O0 S4 f - #include <linux/interrupt.h>2 n; H* p/ E( z& F* V9 }6 W7 ~
- #include <asm/io.h>3 x- ?2 [* X# W% A4 \1 G
- #include <linux/moduleparam.h>4 L2 u& s1 U o y$ K7 R
- #include <linux/sysctl.h>) @- E$ ~& Z+ r: N
- #include <linux/mm.h>/ U# B$ w9 T3 P0 E D0 A
- #include <linux/dma-mapping.h>- g$ D/ w$ f8 F7 H9 Y
U# r {7 `3 ]1 `* X; d7 ~- #include <mach/memory.h>0 _/ {* D9 z# q2 U7 ^' ^
- #include <mach/hardware.h>6 V8 l! `& l- ]" `6 f5 R4 @5 e
- #include <mach/irqs.h>2 l9 M- L3 T, d# d, ^' K
- #include <asm/hardware/edma.h>, u. v7 W* w" y
- ( E* c) {( A B" _# k
- #undef EDMA3_DEBUG
$ K: |: G& F* Y. H' W+ y% Z - /*#define EDMA3_DEBUG*/
" \+ F- J3 |2 Q" s" \3 c6 e; g' b$ d
% p$ g x' Q4 ~# n- d- #ifdef EDMA3_DEBUG8 s% R: n9 n( Y, M" A& j2 h
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 m5 o+ ]; _7 o( C
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! S& {; {# \' o/ v5 a, ^ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" ?7 G' ^; U" @8 I# |
- #else" O1 ]- B0 x) |# N
- #define DMA_PRINTK( x... )
9 i% D5 Z- p+ k, U7 l - #define DMA_FN_IN3 x: ?( k: o) x/ u! D
- #define DMA_FN_OUT
- i3 ]) a" Q# ^) j0 q1 C3 k3 j - #endif( k6 c/ B! a; _3 _9 W6 a
n7 V# V$ k z- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 b# J' I) |9 ], N1 K' S2 o2 C" |
- #define STATIC_SHIFT 3! V/ f0 N9 b* p: ]* \
- #define TCINTEN_SHIFT 20/ \7 r3 Z9 K% s. t1 k" W5 m
- #define ITCINTEN_SHIFT 21
7 m$ ~8 Q2 J# v' o5 L0 t - #define TCCHEN_SHIFT 229 C f2 b: _* L
- #define ITCCHEN_SHIFT 231 f. h! ^1 [" `4 i5 P8 j t" M# q+ u
! H% _7 U1 g5 P, S- static volatile int irqraised1 = 0;" Q* P0 `; Y! Y) C: ]
- static volatile int irqraised2 = 0;* ?$ s2 A* }) Q& g5 a- e+ Z/ C) v7 j
% D4 Y6 Q: R# g/ K4 c- v7 H" V5 H$ W. e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 X; x; G5 O; j5 m- {
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& K! G) M1 r. v% w8 f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 f( }( J- k0 B4 {( {
A% m2 O; V# V5 N1 q |2 o- dma_addr_t dmaphyssrc1 = 0;
" w* e; N! R F8 [8 | - dma_addr_t dmaphyssrc2 = 0;& ^) j) j& z9 p h$ B" @: w* ?
- dma_addr_t dmaphysdest1 = 0;
- {: k( v4 m) d9 D0 G - dma_addr_t dmaphysdest2 = 0;% _( V# n$ n& ?- V7 p
- ! h% t+ j4 y6 h7 p- S8 {
- char *dmabufsrc1 = NULL;
! N4 k0 g9 v( L; b' K - char *dmabufsrc2 = NULL;
$ H2 q% B9 K# q& _% G. F7 f9 g - char *dmabufdest1 = NULL;! u' G" p, s$ w3 h- G! p
- char *dmabufdest2 = NULL;
1 F6 j2 }- x0 s( n* `
. M. } H1 r' x& Y+ z- static int acnt = 512;. E9 W1 ~" `. O- R. `- C" N
- static int bcnt = 8;
3 E3 K2 R. D6 a$ I) ?/ ] - static int ccnt = 8;
- m4 {5 b% ?$ m$ ]& J
5 |( f, U7 A! ?8 n- module_param(acnt, int, S_IRUGO);
/ g( \3 D& X# e& @ - module_param(bcnt, int, S_IRUGO);
0 E( q# [: K' Q3 r5 c4 k8 \$ N - module_param(ccnt, int, S_IRUGO);
复制代码 6 L$ k, T" H, K1 @) |
9 `8 V. \% H/ q6 U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: \ S* w/ X2 T3 |, t5 Rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 t5 ]0 [8 b; m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 n; @; ~2 t- q4 `
, w9 |# v; ^9 R2 F- C
: w ~" O' ]$ }2 P7 e* x' v/ w
|
|