|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 Z5 C+ d+ [( c8 }/ C0 {. Q- w
- [code]EDMA sample test application
6 |. M& h2 c3 V, X; b/ j - /*- c/ G& e' s6 u( R
- * edma_test.c
6 q5 s. I9 c8 |0 u4 N - *
- A- ?% ], e$ ~! X; _0 o4 l - * brief EDMA3 Test Application8 P- I6 |) t% a
- *6 P0 s6 S; x2 ]. i1 Z0 ], D% e4 p
- * This file contains EDMA3 Test code.
; k! O; \6 W* y0 [" R - *
1 e' K; G# w6 a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 i8 _+ F! `6 i/ \( }: R7 g3 P. A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( M8 j3 ], E( b6 l" v4 O
- * TO CHANGE.) M4 `' k7 y' g
- *) }9 O/ [% a# Y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% Y+ l/ y7 m* o* R+ a3 i
- *
3 r2 a+ h/ I3 b0 P- Q9 r - * This program is free software; you can redistribute it and/or6 Y$ e2 u- _& L
- * modify it under the terms of the GNU General Public License as
! {5 l( \- X, o& D) s - * published by the Free Software Foundation version 2.- q* ~$ g/ p& i U
- *' b& H* Q" E' R" ~" a
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any r, m h# P' e' q/ {- ?
- * kind, whether express or implied; without even the implied warranty2 w7 E; n; d7 Y* F1 S1 W% T
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! k. W0 \0 ?3 I s - * GNU General Public License for more details.8 O7 ?) \& u D% ^/ y( i0 W
- */
0 W3 ~ V& c- B! ^ - . p- Z( q8 @6 x% @
- #include <linux/module.h>9 ^! \0 D; X8 ~/ W4 U n' A5 g
- #include <linux/init.h>
2 V. ]8 N2 E/ X- [7 k# G - #include <linux/errno.h>5 e' O- y) e% `# f' ^1 ^
- #include <linux/types.h>
0 \4 {5 r( l; Z% s' S - #include <linux/interrupt.h>, I7 _3 P' {+ K( \1 k% C
- #include <asm/io.h>1 i5 G T [* f( |
- #include <linux/moduleparam.h>
3 G6 D h l9 S1 x) E) |; p - #include <linux/sysctl.h>
) C0 Z# |% Y$ m$ F- v2 y - #include <linux/mm.h>
3 }/ o; D. v3 `0 u1 v) Z* F5 `8 n! c - #include <linux/dma-mapping.h>
1 o! i1 {& U* c$ \. o5 ~
8 q; y' O' F1 K! z4 c- #include <mach/memory.h>7 E P( @+ ]% [# K
- #include <mach/hardware.h>
6 k1 c( P9 ~7 B$ n) y5 Q' U/ i) R - #include <mach/irqs.h>" A# B3 S: t- `
- #include <asm/hardware/edma.h>
" ?$ X+ [0 r s+ d
; ~) K/ ]+ E9 i8 D! s3 F- #undef EDMA3_DEBUG: ~' p# g/ L ^
- /*#define EDMA3_DEBUG*/
4 E6 w) e* {! v; x0 I p4 J9 @
( _4 u6 s9 Z% w" y$ _+ q. ^- #ifdef EDMA3_DEBUG+ o6 Y, i1 R5 H( _" Y `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ D) i! J1 p& K1 j' B o
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* c; R5 n2 W. A8 m/ K - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" A( [) O; \& q1 }
- #else( D9 _( s- ^8 H- o# F
- #define DMA_PRINTK( x... )
' p7 O6 ]$ {6 }* S - #define DMA_FN_IN
! }- d$ ~% {# l8 R# j; N - #define DMA_FN_OUT: I. p7 v- W2 `/ m$ x
- #endif
1 l: ^. V# }& k( x( e/ ?4 y; o - , M. d+ M1 `1 ?
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- S6 j/ ^; r0 {0 n5 c9 {6 f
- #define STATIC_SHIFT 3
; f1 j& C! g; i - #define TCINTEN_SHIFT 203 M7 w* Y5 U( c( h" V$ k6 @. O
- #define ITCINTEN_SHIFT 217 p5 w" Q* J$ P
- #define TCCHEN_SHIFT 22: Q8 j6 f# E$ Y' m6 d; e
- #define ITCCHEN_SHIFT 23& Y# h0 n9 v% A. Q
$ z2 z" @8 G7 J' I- static volatile int irqraised1 = 0;( z. |/ M* f e+ Z& _
- static volatile int irqraised2 = 0;5 _, X$ E6 n7 M/ v9 ]" ^, ?: N
; G W$ I/ A. `, g' m6 A1 d z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 O3 O$ i" o& U, z" r E$ h - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- f$ _3 i9 k- ?" f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 I+ J5 i) e9 X) I+ O5 ^! m% c
- , }. S# j1 u2 U
- dma_addr_t dmaphyssrc1 = 0;$ S. q9 Y' g ~; P. e, ^
- dma_addr_t dmaphyssrc2 = 0;
' z N4 m5 {* u5 C* D1 b; d - dma_addr_t dmaphysdest1 = 0;
4 V* M/ S8 E. i; S! K% _/ l4 i9 J - dma_addr_t dmaphysdest2 = 0;1 I# ]) |+ R, Y; j7 A
- 3 n9 S. n) z" F m4 b
- char *dmabufsrc1 = NULL;
5 A, t" o6 ?) E. o) u, l4 n! T - char *dmabufsrc2 = NULL;
9 g9 a" ^! Y! ^0 Z) P - char *dmabufdest1 = NULL;: V5 n/ ]9 t+ B3 l6 F1 D
- char *dmabufdest2 = NULL;
3 Y1 y. E4 l6 S4 | - V8 }8 m$ J/ h/ X! ^
- static int acnt = 512;
% E0 M+ i4 M& x& m& R/ p; ~; ` - static int bcnt = 8;: S- W, \7 I' o% u
- static int ccnt = 8;# T. w8 w. x1 V
- 0 o+ a, e$ J6 L3 F( r1 z2 ?+ K
- module_param(acnt, int, S_IRUGO);, X' {0 C* v; g- b4 F
- module_param(bcnt, int, S_IRUGO);# i* E) K- j1 j% j: U0 u
- module_param(ccnt, int, S_IRUGO);
复制代码
! ]8 O r% G5 b) Y& f7 [3 t: {3 ~/ H( O# m- `2 K. [: V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 n2 b+ L& O$ t& [* }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( v4 L' d7 q7 n- w4 f2 ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: {- M8 L) t0 z# f
/ o& X4 V! N( x/ d. \) K, H8 H% [8 ~' j
|
|