|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * S0 T5 w( B0 {2 k0 b
- [code]EDMA sample test application
0 A& [" v, J0 E4 e - /*
) @+ N/ Y3 R. Q7 M6 [7 h - * edma_test.c
/ Q# a# J7 G" h& e( ]6 F) w - *
! U1 h8 l! p% g - * brief EDMA3 Test Application
7 E% p* @" W" V9 S3 {" l: H - *0 M% u" W i1 t( }
- * This file contains EDMA3 Test code." i, D' P0 W1 j- L U
- *
: I7 t, z G! Q7 z+ e - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ K5 l$ r9 t- u9 v; f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 ^3 a: v$ w' O" |4 W5 ?
- * TO CHANGE.
0 U/ x! Z4 L, S3 L# s) U3 i* T - *- y# T+ s' o- m8 w0 R s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 G6 b' B/ R4 n8 C
- *
& K0 W& l7 x! c# [. g) R& \. W - * This program is free software; you can redistribute it and/or
3 a, K& d4 z, @1 G - * modify it under the terms of the GNU General Public License as
[2 H: W, A1 H# I7 I - * published by the Free Software Foundation version 2.% H, D& `# M7 Z# G/ A
- *3 E& f, G( Q' N- m3 s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- G8 P" o% w( c4 {* ]8 ~
- * kind, whether express or implied; without even the implied warranty0 o* p7 r0 c1 C1 y! ?6 V
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) j B$ B0 P* I- ]
- * GNU General Public License for more details.1 Z6 s$ R0 y$ {
- */
$ F |* @6 L. s+ s! R
/ }. M& H+ B! d5 \0 _% }2 _- #include <linux/module.h>7 A) n( ^9 W6 s6 i
- #include <linux/init.h>
8 Q6 u4 ` K7 ` - #include <linux/errno.h>4 O& i5 E+ B: j8 i/ ^# }
- #include <linux/types.h>
+ w! @. H+ X3 F; z ^ - #include <linux/interrupt.h>
9 y: W8 a! y, r" N - #include <asm/io.h>
% R$ q, e: A+ M - #include <linux/moduleparam.h>
# {' j, G& W1 W) J* {4 V5 I - #include <linux/sysctl.h>
9 W5 n& \! a4 {+ D0 D$ x - #include <linux/mm.h>
7 x. U9 s' ~" W; _2 I/ p0 ^ - #include <linux/dma-mapping.h># [2 N* o: F7 W% r: m
- 7 _( {% V* b* B Q6 H3 V! T
- #include <mach/memory.h>' n! z h. Y$ j3 G8 _
- #include <mach/hardware.h>) d: ?& u5 y" y0 k
- #include <mach/irqs.h>& R2 }" J; t. p3 v }, t4 g
- #include <asm/hardware/edma.h>
& Y- }1 i" s3 e+ k- e& U
. Q: |8 F$ k0 e. _- #undef EDMA3_DEBUG
7 c" s2 D* ^3 {0 J/ Z5 g - /*#define EDMA3_DEBUG*/
' q1 E5 F; U$ k0 [
& \/ Z; Z: t% |6 }- #ifdef EDMA3_DEBUG
9 v7 M3 M, Y( w( Q& Z! ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* b/ j& L0 d/ t# i - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 b- x- q% b) X) G( c/ H. | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ r) @: j2 b2 u - #else
1 ^9 N" u4 g2 J - #define DMA_PRINTK( x... ): O+ W3 Z: W' ~; l4 U
- #define DMA_FN_IN
* s7 O& l$ b* w; W$ S* z- c! z - #define DMA_FN_OUT
: J2 r! s$ Y0 n2 _ - #endif
D9 x& |' K# \8 O' e' S, a4 H - : L- Z' i% J! S8 m+ Y: [4 S: T6 j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)- G# I! G6 | s, ~! H: ?
- #define STATIC_SHIFT 31 S3 d0 Y8 ~: {. M: Q3 w9 T3 @1 k
- #define TCINTEN_SHIFT 20) k0 r* W2 D+ l
- #define ITCINTEN_SHIFT 21
( @, g1 v/ p. g- ^& A8 L - #define TCCHEN_SHIFT 22& F+ F) @9 M, H
- #define ITCCHEN_SHIFT 23
3 F. M' O* M Z9 k - # Y. X7 x% n( t
- static volatile int irqraised1 = 0;
1 Q. F! N4 J" ?: T- D% i - static volatile int irqraised2 = 0;
7 U* D/ T6 D3 M& H3 D( [
' G$ L- d( J5 F( R5 p0 [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 n8 `! [, i2 z1 w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 i P& }$ ~' A6 l, m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 {- d( r: s$ t# w4 r3 I - * E* L! K3 \3 s2 @6 f
- dma_addr_t dmaphyssrc1 = 0;5 ?; f! @* y/ S
- dma_addr_t dmaphyssrc2 = 0; \, b1 c" m5 J: \% X T- U" u
- dma_addr_t dmaphysdest1 = 0;) Z0 |2 w% e* M z
- dma_addr_t dmaphysdest2 = 0;
9 [/ Q# r. i9 j( e - E# m7 |- H E4 `9 a
- char *dmabufsrc1 = NULL;
+ n6 L- P1 I5 d+ Y5 ^8 }0 O - char *dmabufsrc2 = NULL;0 _1 h A% v! K) c* k7 z
- char *dmabufdest1 = NULL;* P# j# j2 o2 X `" b- R3 J% H8 `
- char *dmabufdest2 = NULL;
+ X: ]% a% `; J5 |# b; g, s - % B; q) G( E( U4 h. W R
- static int acnt = 512;
% S3 N) @! ?1 { - static int bcnt = 8;
* [0 E# d* n5 ^2 f$ N - static int ccnt = 8;
& i% h" k p0 ~/ M1 E" ~1 ?
) O6 u# U0 e6 U U5 Z- L G& b1 d- module_param(acnt, int, S_IRUGO);
7 `/ O! f- {- R h - module_param(bcnt, int, S_IRUGO);
N0 o- o4 G+ C2 B - module_param(ccnt, int, S_IRUGO);
复制代码 3 E& |+ U! ]: P6 \
4 s/ |3 B$ r7 I4 ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 h4 s- m1 C2 N. n& h5 Varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 \: y" ~7 o! z6 t
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& E- _$ @2 u2 k9 l
+ h# U( K+ D" F$ v9 G. G
9 b: n6 v' S/ q* A" {. d |
|