|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 r' {/ Z- R5 d" L6 e
- [code]EDMA sample test application
. N% B# v b9 ?6 I1 D5 c - /*
& z- m+ p# T4 t9 r - * edma_test.c
6 h4 ]' k0 \: Q. K0 E7 F4 J2 k - *: p- C" h) i \( K, x
- * brief EDMA3 Test Application
8 `7 G' A6 e" B# D; ^ - *+ h( K: R, t' E7 I$ w8 J
- * This file contains EDMA3 Test code.& D( H& e# d( @2 X* |; Y
- *1 R1 o# g3 F/ }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 Y6 w5 h! o) ?- h- V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 Q+ `. b6 b' A- {$ U( `' b
- * TO CHANGE.
: T! Q7 G& K" I; F9 w - *" Q M1 [; ^' A4 I4 K
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 x' x5 a8 a3 U9 o: n/ p - *
: [6 T* \) p: r- Y- O. n - * This program is free software; you can redistribute it and/or) Y* Q1 b2 s+ F$ m& D F& {5 F" Y
- * modify it under the terms of the GNU General Public License as
* U$ u1 {4 A$ o `/ _, M8 J - * published by the Free Software Foundation version 2.
0 ~) Q; w/ ^5 o! T3 |. B4 F% U7 S - *) ]7 X) C& U& |2 u- ~' f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ b7 p1 Q- L# q X$ ~3 R - * kind, whether express or implied; without even the implied warranty2 T, V4 M* v7 d! ^ y, y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 @1 j7 s3 E L0 C; ^) }* f: D. Q
- * GNU General Public License for more details.
R3 A. }( M% { - */
1 W/ o% [4 P& `6 q# H$ s - ; ~8 p' {' l# Q( f- i s
- #include <linux/module.h>- q4 x9 j: o( x' J: k8 y6 T
- #include <linux/init.h>/ r( E) _; d& j+ C
- #include <linux/errno.h>
! V7 ?& ]8 T4 N; ]" P4 ] - #include <linux/types.h>2 c& V7 [' m: \; U* `* V4 v7 x o2 A
- #include <linux/interrupt.h>
+ L5 `+ X9 Y: Y! C6 e - #include <asm/io.h>
1 Y3 Y3 V9 _8 P7 o6 m - #include <linux/moduleparam.h>1 W6 K) P8 \ Q" b' z
- #include <linux/sysctl.h>
* p4 e( t' F% E - #include <linux/mm.h>' V2 B" s% r, |7 e" l; n' a2 @$ \+ u. L
- #include <linux/dma-mapping.h>- b) D3 M8 H( T# o( O
5 i1 t9 a* B p0 Z0 M1 y- #include <mach/memory.h>7 ?$ [& y4 W; V q6 L
- #include <mach/hardware.h>
1 e, }8 f: c# \5 h1 A - #include <mach/irqs.h>7 p* {7 }# o2 t' N: \, h1 w
- #include <asm/hardware/edma.h>0 l% d, g% ~1 i. J1 r: `0 V0 D
- 7 t# C1 w$ [1 f3 j# B
- #undef EDMA3_DEBUG
1 }/ U$ L1 P, G7 X/ H0 M( E9 _9 t7 A - /*#define EDMA3_DEBUG*/
, Z) m& D$ o- ]/ l0 l; l& G - ) [9 z) J) A$ G4 {% [
- #ifdef EDMA3_DEBUG: T% Q j- a( @" z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( n8 U$ ~" Z6 C( B% X7 y% K% f. X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 F! a$ m& y; ^0 N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 D/ |2 l# b5 V% t - #else
3 ?& |: k {/ [5 Q" u, l' k - #define DMA_PRINTK( x... )
+ G2 f0 V) T& V o - #define DMA_FN_IN5 {+ _; q: N' Y1 Z
- #define DMA_FN_OUT6 V. s% Y3 z( ^3 C4 _3 x8 ^
- #endif
$ M. p+ K9 F; {0 I
! `" y# Z- K/ F' A- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, E. [. `& t" z* b) q* s - #define STATIC_SHIFT 31 U: _# t/ D7 B7 }# W; O7 L0 C
- #define TCINTEN_SHIFT 20+ S/ G" [0 p7 U3 h3 s0 U
- #define ITCINTEN_SHIFT 21" Y1 ^5 h! |0 ~8 z6 O9 ]; ]
- #define TCCHEN_SHIFT 22
, u1 c' j/ U8 w# A. ]) {. w! O - #define ITCCHEN_SHIFT 23
) z" J4 M' Y' l - # [" l% O5 J* o3 F$ s3 z& V
- static volatile int irqraised1 = 0;
7 q/ D3 u, u$ u7 h0 |9 s - static volatile int irqraised2 = 0;. h- s& K+ J6 {( _ a/ j8 C/ i2 q
- : `9 O y4 z: a0 \* {
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 I9 h! p6 t9 {8 x1 l. } x# V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 o4 M$ _# w. E9 }( A+ M, j* m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( b; r; q7 Q; u! M/ c - 5 u* w, S& v7 m* t
- dma_addr_t dmaphyssrc1 = 0;
6 ~7 x& s0 o' m* V2 j - dma_addr_t dmaphyssrc2 = 0;
* G' }. d2 S8 S2 @- h% h - dma_addr_t dmaphysdest1 = 0;
. S' E1 k( y4 w/ U0 H( N1 M - dma_addr_t dmaphysdest2 = 0;
c0 w9 W1 Y( ?: @, A - % a! `8 L: S5 S; R3 Z$ v
- char *dmabufsrc1 = NULL;
$ N/ ] Z; ], Z1 m - char *dmabufsrc2 = NULL;1 j' M$ `9 c C
- char *dmabufdest1 = NULL;4 P% O7 Z3 Q# T( `
- char *dmabufdest2 = NULL;
! D2 P3 U- Y3 t9 {# H8 e. T* \
& ]4 Z2 l! j8 j; E, P e- static int acnt = 512;( ]7 @1 o) K0 J. g u8 L
- static int bcnt = 8;6 Q% ]6 T; E* x6 [
- static int ccnt = 8;" ]% }4 W) o8 V: f3 `1 Z9 I
- : S% h. s% t; a3 }
- module_param(acnt, int, S_IRUGO);. ^$ {# _- m; v- ]6 t/ J
- module_param(bcnt, int, S_IRUGO);
P/ j+ y e" n3 B% N F - module_param(ccnt, int, S_IRUGO);
复制代码 - v5 }1 H7 F9 W+ G5 {1 c1 e# z2 W8 J* y5 R
6 [ J! C' J- ` `: N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% k5 u6 F+ z' _! I9 ?5 V
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- W" J3 o/ T5 b6 e8 m1 u 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ z3 _2 T5 B* |) F
7 D- N" t. B& T( }$ I3 }
3 p; E0 b( W/ ^! Z. |7 `4 n1 O ~
|
|