|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ |; n% @( n, V) `/ p- [code]EDMA sample test application
+ O# ?3 }/ C: S; x - /*
% _ R" ?7 w, U5 l( q+ ` - * edma_test.c/ A0 i+ Q5 }8 f1 O
- *+ H, a0 `$ ?" Q+ Y+ L1 F
- * brief EDMA3 Test Application m: ]; _% ~( u R4 J- E) r( p2 M
- *2 ?; H$ e7 K( R: s) n7 O) @2 v
- * This file contains EDMA3 Test code.
( _& k+ w5 B$ r$ Q0 V5 s - *
( i* g; y" D* ?+ ]8 x" N - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
z+ X+ {7 }3 J+ A. `$ h7 c! {' D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: x- @9 {2 N) \
- * TO CHANGE.7 g/ F( P, C) y% H* z7 G) j5 B
- *
% T7 S8 F5 v6 D( H4 F: I - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* C6 K, i& k5 t! X, R l - *( J' H: p* a& v8 a4 ^
- * This program is free software; you can redistribute it and/or
- l7 F' C+ K1 l, k1 t - * modify it under the terms of the GNU General Public License as( y% T: C" N% S5 L
- * published by the Free Software Foundation version 2.) n4 N6 }- M5 ^ Q" u6 D+ h: i
- *2 ~' [' M- E$ I6 K j- F6 Y- H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
h; f1 m4 J; N8 y$ b) y - * kind, whether express or implied; without even the implied warranty' k( t7 |. I9 E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! n: A6 Y7 r, ]5 d/ ~( d% j; g
- * GNU General Public License for more details.
3 o8 m6 ^: Q0 {6 ?; R& { - */
7 O0 _+ N/ B) s; t - 6 c% O1 \( X5 I$ z6 q* I
- #include <linux/module.h>$ s) _! e7 U5 f2 X. | v3 q$ ^
- #include <linux/init.h>1 |4 b. `" S6 ?7 r; x! O
- #include <linux/errno.h>% `, ?% y9 s- J* L4 `- w" ~+ T
- #include <linux/types.h>1 R# }1 i F$ [4 e; U3 [
- #include <linux/interrupt.h>( D# P; G( r. \5 o7 t
- #include <asm/io.h>- d" Z) v8 n) K7 j
- #include <linux/moduleparam.h>
& l7 k1 i* P& A2 v) ~ - #include <linux/sysctl.h>
, K X! g/ p w/ ^ - #include <linux/mm.h>
6 Y6 E) y# e; Q3 D" @! ? - #include <linux/dma-mapping.h>; I+ E; {3 u/ R; S
- ( L+ p9 j+ k/ f( M: u7 G
- #include <mach/memory.h>% E/ H' D1 [: U" k% c1 O% \9 E
- #include <mach/hardware.h>
9 H; ]* [/ k4 d# P - #include <mach/irqs.h>
, X( \' s, J R0 c, H0 v- c/ F - #include <asm/hardware/edma.h>
4 h8 \$ K6 _5 u7 g, e - 9 _+ C5 d3 k; q) E/ @- K
- #undef EDMA3_DEBUG
8 U: w/ C; h- k - /*#define EDMA3_DEBUG*/& o( C5 P( M, C: c& P. ~
- % Z# I. M. X6 [
- #ifdef EDMA3_DEBUG4 R- X. L& S( x- Y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% U, n# @! Y( d! V. {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# j0 B7 f& t+ r$ n8 ]8 D4 R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& m0 m- ~+ H" D7 v4 C8 Y
- #else% h) q! r! K; y! V
- #define DMA_PRINTK( x... )
( N% l, h# S- G+ {9 _) G - #define DMA_FN_IN i% e# s1 e8 C# w: L) y
- #define DMA_FN_OUT
* Z5 o. M& l; g% A! D' j+ L - #endif) e, J" M! d, U. z8 x- S7 L! A
- 9 j: V2 Y+ w4 x. B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' ]* K" N) u+ O
- #define STATIC_SHIFT 3* V$ e! h' S; f. L1 C
- #define TCINTEN_SHIFT 20
# | I- L7 E8 T: {0 F% I3 E+ }5 k - #define ITCINTEN_SHIFT 21
8 j7 w4 ~( E# @3 c/ ~, O7 T& x - #define TCCHEN_SHIFT 22( D7 T- t- _1 m3 F# K! ], ~8 I% T1 U
- #define ITCCHEN_SHIFT 23
2 b! o5 d1 m& Y+ v; g3 e. ^2 F6 ?
- d8 I _, d }7 {8 Q4 n5 r" I3 I, `- static volatile int irqraised1 = 0;
+ h; T6 l! u5 e" u/ B6 [6 g - static volatile int irqraised2 = 0;
, G* O7 \- s# P3 E - ; G8 O/ V& G0 M, c9 b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; D0 W7 J1 x j8 J# J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; l7 g7 X M+ r/ ~ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ {4 x. i# u& P: Q
' Z9 e; `; G2 J2 b! @4 e, i t- dma_addr_t dmaphyssrc1 = 0;9 o4 j* `" i; }8 x5 H" W
- dma_addr_t dmaphyssrc2 = 0;* n( W4 e$ q9 \- N7 A
- dma_addr_t dmaphysdest1 = 0;
$ w( a7 E }( H b% ?+ v4 d3 A5 q - dma_addr_t dmaphysdest2 = 0;
+ A. B! i+ N7 @ - 9 s9 F4 G% t( s- E/ v
- char *dmabufsrc1 = NULL;
1 a, I6 \: r1 `1 V! t1 K* h - char *dmabufsrc2 = NULL;
0 s: H) c& Z: k5 @ - char *dmabufdest1 = NULL;
7 C# d- B- g1 b - char *dmabufdest2 = NULL;
* p; q$ W# |( c6 g1 w
8 V$ O, z. G( `' T$ Q- static int acnt = 512;
9 o2 o. x; U/ M% T, l" J W - static int bcnt = 8;) d+ ]% k7 Z4 E5 W! t4 V: X
- static int ccnt = 8;: \# f/ y4 o+ V. `9 l
4 S- c0 R: k& s7 d& _- module_param(acnt, int, S_IRUGO);
, V5 D) r6 G: d0 M& O' d. N u# ] - module_param(bcnt, int, S_IRUGO);
& ]9 V" Q3 l! f* n. u7 D" A6 | - module_param(ccnt, int, S_IRUGO);
复制代码 % b( o% T6 V) p" Z/ e
8 P- e# v, b8 ^$ e: U6 k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" i, v6 t Y5 V' a, b% g
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 |; r" ?1 {, B3 t8 W& f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 U* j* Z e( A
/ Z5 j0 J$ U; ^$ l7 \% s% J& T1 `1 ]0 N
|
|