|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 _9 L4 Z# T* ^2 F$ S; T
- [code]EDMA sample test application
, _5 w3 {: Y" p. w. k" \# Y - /*
; G1 T2 _, O/ x' ? - * edma_test.c
1 {8 o( w; g8 ]2 U( G - *7 ]4 H- q! `) ^/ N9 f( W3 ~
- * brief EDMA3 Test Application- ~" ]; Z- I' X( w9 @( m$ N
- *
9 ~ \( U- D+ j( @ - * This file contains EDMA3 Test code.
; P4 p+ r9 R5 D' K7 l - *" G& }0 l& ^+ k ?2 j$ Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ ~# x( ]7 ~; o7 R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) x+ ~( C9 |* a4 b$ C" F
- * TO CHANGE.
0 x( O9 C9 M$ ]- q - *
% N, O! x& z/ @( K [1 t" Q) H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, |9 Q/ J' A% N# b9 e6 K3 s
- *
& S. Z( G8 |# x% C - * This program is free software; you can redistribute it and/or( [# q& \' S8 B4 D1 T
- * modify it under the terms of the GNU General Public License as
' h3 v; l5 `$ X; F8 X/ \1 ]& Y - * published by the Free Software Foundation version 2.
, E) C) _, x! V, k - *, g$ _( d/ @1 T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; F* Z1 `! s$ q; f7 g8 H - * kind, whether express or implied; without even the implied warranty F% m& G9 y4 q R% `+ s; o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 U7 l3 Y" O. k+ E$ u
- * GNU General Public License for more details.
- ^: `" L& V. w5 l$ v0 q8 O: d - */
# d4 X" y o' K* X5 ^ - % r+ r; V! Y. z! A( j9 b- |6 v" ]
- #include <linux/module.h>2 J! o1 |% ^6 Q$ `" Z, r3 }
- #include <linux/init.h>
* F* f' f% v# G' O: i8 W - #include <linux/errno.h>8 ~4 b- Z$ n4 w6 p2 C# [, g7 ^
- #include <linux/types.h>
! N- D) d% T6 {( b/ L( E) G - #include <linux/interrupt.h>
: s; A2 p/ G- C - #include <asm/io.h>
: `: D% G& n0 Q& P - #include <linux/moduleparam.h>
' Y8 g' _ T3 e - #include <linux/sysctl.h>
7 i$ U( v9 h" d. U0 v" p3 |2 z, _ - #include <linux/mm.h>3 d7 r1 l/ u( ?
- #include <linux/dma-mapping.h>
* g, O" S8 }# C5 b2 e+ A - 3 K7 P) Z: E# {
- #include <mach/memory.h>3 Q5 |/ j8 |1 K @0 S, `
- #include <mach/hardware.h>! F1 l& m* x3 \- x
- #include <mach/irqs.h>
/ Z l: D$ _+ F - #include <asm/hardware/edma.h>- n( U$ Y' W+ `7 d- I
; Z( Z5 }3 S* {- #undef EDMA3_DEBUG
/ [/ I1 J* u2 F) M" P8 A! _0 \+ ~( [ - /*#define EDMA3_DEBUG*/$ I3 Q1 e$ |# z
. N8 h6 t- u3 N! T0 Y; ]- #ifdef EDMA3_DEBUG
' I% S5 R' z, ?7 {& v0 \/ B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 J# d4 B& p5 o5 t' ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! q) }9 j# P# X `$ d: ]0 r; b: g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 @1 h( _# A+ @% J# h- e4 v
- #else
& g% X# Q" j9 J - #define DMA_PRINTK( x... )
5 ?7 j, F3 a; i& _0 R+ d; d) v - #define DMA_FN_IN9 x$ m5 g5 i4 g4 t9 O0 @# `0 l
- #define DMA_FN_OUT! l7 ]0 ~ n; z3 M5 |' V
- #endif) r c# Y* [3 H: v& Q% R2 T& ?; Q C
# I3 j5 H2 }' l, d- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" a7 W t. g) R, X3 N
- #define STATIC_SHIFT 3: p5 D0 G1 d" F+ z# D- L/ Q4 K" k
- #define TCINTEN_SHIFT 20 P9 [. ~$ S% E" S
- #define ITCINTEN_SHIFT 21# R/ [8 O4 N" `+ C/ U5 A
- #define TCCHEN_SHIFT 22
4 r+ z) a3 n! l) K - #define ITCCHEN_SHIFT 23" V3 }, w5 U- A
2 A3 w# h7 j: h- static volatile int irqraised1 = 0;0 c$ R3 `* T+ U$ {8 n8 H; a, a
- static volatile int irqraised2 = 0;0 q' W z! [6 a) N3 `% _8 i" q: ?; r
1 N+ J, E/ g, U) @! H0 Y% u3 x |- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; v9 J# {+ R' n* M; q% Y& K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ f2 R. h8 E7 Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 g9 q3 r) V2 q! _7 [' D9 X: b
1 r0 @- q3 s+ b0 X0 L7 D- dma_addr_t dmaphyssrc1 = 0;
' g& Z) e( ~$ o! q( h6 n# I - dma_addr_t dmaphyssrc2 = 0;: d) K6 w1 R$ j# @/ ~
- dma_addr_t dmaphysdest1 = 0;4 _4 L/ b7 o6 {$ Y: n
- dma_addr_t dmaphysdest2 = 0;
' `) X* X l/ m. f
# q$ E, i; O' P0 ~- char *dmabufsrc1 = NULL;; I7 |$ q5 |5 k$ b8 l$ O4 ` h
- char *dmabufsrc2 = NULL;
) R" P% Y2 x( z* g - char *dmabufdest1 = NULL;
5 M' T- f' U6 f2 J% s' h - char *dmabufdest2 = NULL;7 U+ c- f# k5 J( W( z' v
# V# F, ^3 r* I9 L) F7 ?* H% d- [- static int acnt = 512;5 |0 s7 M) D( u: @& Z
- static int bcnt = 8;
! N: H V Y: G, j5 E - static int ccnt = 8;$ `/ O& v; x W- D
- 9 t" G: v1 P# F6 z. S8 n8 N
- module_param(acnt, int, S_IRUGO);, V- ?. s# f8 g
- module_param(bcnt, int, S_IRUGO);
9 f# @/ m, ] q# Y, x8 k - module_param(ccnt, int, S_IRUGO);
复制代码
- G$ P2 H9 b! A6 O- F- f. y3 s1 Y! H) F% P# U( Y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ ^3 U/ S5 ^- E: T/ parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 b& q: P% A. W( h9 ?
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 J0 y# y! M3 j: B6 S D' M: n5 \1 G2 h0 U
% x! w$ @( Z! [7 ]! q( z2 E! M
|
|