|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! c* o! s- L) _' Y
- [code]EDMA sample test application; Q1 s3 c5 n) k8 E: M1 q: m5 R
- /*! z5 ]9 o6 L6 r8 w
- * edma_test.c: x; k" h ~2 i, G2 L
- *) `8 ]5 E* @/ M) H
- * brief EDMA3 Test Application
$ m+ a. r% Z: k1 t. g) ^1 v - *) Y2 s& O$ `3 j$ g1 c8 s9 _; ?
- * This file contains EDMA3 Test code.4 R( R7 Q2 F g0 {, p
- *+ N) z9 ` C4 Y9 a+ o
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- c1 Y5 {0 o$ W
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 q V" O7 O8 S/ m% Q/ U - * TO CHANGE.' C% d# L D2 A% g+ t
- *+ }$ d+ J' Z% d; U2 N7 ^& P) |; `
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 e. m. J2 n( h( k
- *
* w% W! m7 B2 q t5 ~9 N9 n9 W2 v' F+ h - * This program is free software; you can redistribute it and/or
% ?" x( Y9 e$ r+ ]- W0 @) P; w - * modify it under the terms of the GNU General Public License as
# E& n5 d- l6 R/ O% B - * published by the Free Software Foundation version 2.6 f1 i2 j/ u! }' V5 U4 F3 _5 d% P
- *
' E# |6 F5 h1 z# E& F& ? - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; P$ g2 k% A6 @% D6 Q! ~; s - * kind, whether express or implied; without even the implied warranty
% Q6 `, E. t$ G! M/ K% _4 } - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- R7 J- K& D0 {$ }$ S - * GNU General Public License for more details.5 |0 p; G4 H% P8 }0 D; |
- */
$ S4 G: W0 A, w/ D b% @
7 o4 p' m" }6 q1 M& T- #include <linux/module.h>0 e' Q, ^6 l% _
- #include <linux/init.h>
0 p6 y! X4 k! F - #include <linux/errno.h>
$ `% o& ~) K; ?" g3 T - #include <linux/types.h>
* Z& Y1 m5 z, n0 Z0 k7 q$ g0 w1 ] - #include <linux/interrupt.h>, }( G; {; u- e( M/ s3 o
- #include <asm/io.h> h d6 `7 D$ n* b- `4 H s
- #include <linux/moduleparam.h>% y/ J9 N- r) |7 B
- #include <linux/sysctl.h>
8 v3 v- |5 a! ?( z- R1 | F - #include <linux/mm.h>4 p$ Y3 K0 A$ \4 S
- #include <linux/dma-mapping.h>5 M" V+ W) D( U2 I
1 w0 N. s O9 L8 i9 w- #include <mach/memory.h>
! D* f9 S' ^ b' l - #include <mach/hardware.h>
# z9 m( i# h3 a. V" j2 z) j/ D - #include <mach/irqs.h>
7 r/ Z: w: {$ B2 E# L2 D( G - #include <asm/hardware/edma.h>0 d* R. @; |6 O9 k9 F
- ; h$ R* b8 k* R3 p5 Y0 u
- #undef EDMA3_DEBUG/ r3 M, l: B- D# Q$ R; ^1 o
- /*#define EDMA3_DEBUG*/8 Y f% Y" Q4 X/ {3 `3 D7 A
- * A4 y' S% Q2 K
- #ifdef EDMA3_DEBUG
2 G& I9 R) f p" Y( \8 ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. p1 ^& Z9 I% M1 E |) ~ _2 B - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) C( H% J' q( w
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, l2 |2 Z0 w/ p5 | - #else
) @: l+ W; H) {1 ^; z: [: E, I - #define DMA_PRINTK( x... )
5 A* H3 A* Y8 n! x! b8 O @ - #define DMA_FN_IN/ z$ b4 c: P" }( i
- #define DMA_FN_OUT
/ }- N. t1 K' d1 F% { - #endif7 h c! r1 Z1 h( K
- 9 Q, i' D; \& M
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). @ ^ h$ Y" E% [- d- x( c4 a
- #define STATIC_SHIFT 3
c; z& f9 Y% L! h: M- U - #define TCINTEN_SHIFT 20 r* m5 N5 I. \( b( c, F' x
- #define ITCINTEN_SHIFT 21+ o S/ h- P, @# F* O$ P# O3 r
- #define TCCHEN_SHIFT 220 _+ l6 \1 n( I$ `+ V, t$ J* F
- #define ITCCHEN_SHIFT 23) m/ D0 g, R' q' Y/ W
. j; h4 T/ x* d# E7 p- static volatile int irqraised1 = 0;
- E& y- H z) ~ - static volatile int irqraised2 = 0;
3 p4 V5 T( ^6 b: r' g( _% o0 N
) b- [4 b8 `, @8 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 L: Z' g% J0 {/ N5 g$ C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 d9 K4 x. H1 P$ D2 _9 K& W. C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 V) S, Z' G. ~% D: B$ w
4 f+ n& N/ ~0 c( J0 x4 O1 F- dma_addr_t dmaphyssrc1 = 0;
+ r* W. C$ a7 R- n - dma_addr_t dmaphyssrc2 = 0;
3 `7 x2 `' C; W" ^: V! Q, @ - dma_addr_t dmaphysdest1 = 0;
' B+ H# D8 u* [, A% `/ k - dma_addr_t dmaphysdest2 = 0;
$ M% R" Y7 V. _% f5 l; A - % e/ ~2 B7 w! }. }9 B
- char *dmabufsrc1 = NULL;) D# e+ @) _+ o+ W: {' M
- char *dmabufsrc2 = NULL;
9 ^2 \( @" Z' t* q0 v - char *dmabufdest1 = NULL;" q% t& j: W3 ]# m$ v6 b8 y" j" y. p
- char *dmabufdest2 = NULL;+ ?1 S$ R5 z ]: B
- / t8 o( B% J: e. \1 X
- static int acnt = 512;( |' d% z4 ]5 B& q; }9 o
- static int bcnt = 8;! F/ Y* H5 B0 S. J& N
- static int ccnt = 8;
/ u5 `9 M7 m2 R# ^ |' |7 q" B - & E" |+ X5 K3 z3 o
- module_param(acnt, int, S_IRUGO);' k; b+ ], G3 ? S; {
- module_param(bcnt, int, S_IRUGO);. x+ u8 w4 O- _6 u0 [
- module_param(ccnt, int, S_IRUGO);
复制代码
( s! {, g! t+ L3 ? Q* ^4 ~% S* f1 T/ j/ q6 l4 W9 S8 E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 F: S! z' U+ d7 uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; P6 J" \& d# W: u 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' y) R1 q0 O% `3 H; O) z# u
2 }% _. w. D( v
. R& C! A. D9 _+ E: V1 {" M |
|