|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- t+ d q' y3 V- [code]EDMA sample test application4 |! h4 C; i6 J: w& q% J
- /*
3 u5 ?# s7 y* I2 |: P - * edma_test.c
3 X: _3 w5 K* V3 j - *
$ N/ V1 ?$ o) W1 \8 i9 w - * brief EDMA3 Test Application
# s7 O, j' w8 I# K/ v7 c% Y7 ~ - *
8 S7 `! v0 p# }) u4 K! K, X - * This file contains EDMA3 Test code.
* _4 }% w: I9 i; d: I - *
" i6 E0 H1 z! B" Z ?8 z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" g- g, T9 M0 H |* X+ M; I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# J; F: X/ T( Y/ j/ ^$ N0 W - * TO CHANGE.
+ n4 j" }9 x1 B: ?. _ - *
5 f% _% N# j! z9 @ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! p& @" I2 a; E7 M( l0 z' D0 f
- *
5 n$ S+ n4 a1 p& S* o& m. ] - * This program is free software; you can redistribute it and/or. d( f7 l m/ A+ m: o! h
- * modify it under the terms of the GNU General Public License as
& M0 }0 [; Y) u$ C4 ]; a7 } - * published by the Free Software Foundation version 2.( Y6 U1 k% }6 b( E& z# p
- *
. ?, J6 r" }2 M* ^$ n' x; ] - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& N, k6 x+ V0 z; l! I; x/ L
- * kind, whether express or implied; without even the implied warranty
- d! F- A! C3 |4 M0 L% Y* d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 ^; y: W c( M - * GNU General Public License for more details.
6 e+ e5 _: M: w; Q; q- K - */ ^% s4 l' {6 z( ?, ^" v0 P5 x, |% d$ ]
- 3 V! ~9 F- X2 f) t
- #include <linux/module.h>
& B' }! ] `$ e. |; q9 L - #include <linux/init.h>8 H/ j: U& V) `; d3 L
- #include <linux/errno.h>
. n: j; ~* |9 u% e5 L, v" u - #include <linux/types.h>2 A2 F# C$ m5 p& u. A$ ~
- #include <linux/interrupt.h>
* ]! J: i8 `1 ?0 t - #include <asm/io.h>1 ?/ g p5 S( m8 `, _8 v6 c
- #include <linux/moduleparam.h>9 c5 E/ X$ d% r* T& h% a' f
- #include <linux/sysctl.h># W( [4 o! y% o, T
- #include <linux/mm.h>) ^5 \: S9 T) k- P( R0 [! x
- #include <linux/dma-mapping.h>6 A5 |7 i8 o/ R! E- |. q
1 X; f! O3 c( i- #include <mach/memory.h>
8 G3 p9 r9 u! x& L3 l* U - #include <mach/hardware.h>4 L% p/ Q0 r z% p7 R( F! [
- #include <mach/irqs.h>, z0 M7 D8 W% \& n1 k
- #include <asm/hardware/edma.h>
, j, q0 e& S2 B- S7 X# ` - " K3 S8 A4 }. V! R3 q
- #undef EDMA3_DEBUG: i; V0 U$ \4 O6 |
- /*#define EDMA3_DEBUG*/
5 {" P" V0 Q& z0 A$ u - $ S. x" U5 p* t
- #ifdef EDMA3_DEBUG
+ s7 z) D s' W& G# d* l+ s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( d7 C: L1 P& X5 T! r4 @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 m* @& F0 S0 `/ }+ R6 K7 `
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): B- o9 O# V5 S) [
- #else1 Y4 d# ^ P7 |8 n- F" E
- #define DMA_PRINTK( x... )
4 p( b' A& V8 y( a' B% F3 | - #define DMA_FN_IN2 Z1 B7 @! U2 _& ?9 G9 a% Y+ j
- #define DMA_FN_OUT
8 M) t; B; z5 {* D. k - #endif
& \7 T0 j D$ [8 e/ @1 f6 k
% W, ~0 \6 \5 R. i% s- x+ D- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" f5 a3 x9 Y; R- ~9 h- c - #define STATIC_SHIFT 3) U1 x7 @* b+ G1 o! X# B9 D
- #define TCINTEN_SHIFT 20
* X2 L% \& I; ?* |+ V - #define ITCINTEN_SHIFT 21
( p3 W( n# ^9 O4 Q9 K - #define TCCHEN_SHIFT 228 Z+ y+ g( c" T! i; i" r" z$ j
- #define ITCCHEN_SHIFT 23# s" g+ n9 ~6 ?3 k- w( D i( b3 j- k
7 M. E3 h4 n7 y* e- static volatile int irqraised1 = 0;
- X* p/ e% Y/ j9 \( q. e6 q" ^ - static volatile int irqraised2 = 0;9 V" e* s' i* L5 ~; d4 {& ]
- & |; C1 z. w, @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, h7 [& X. H1 f- u - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" p- R, P E3 a3 D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- _$ q2 a' _ D, w. s" d
- 6 ~4 x/ }0 q7 ^! u- I) v' n5 \* T0 S4 s
- dma_addr_t dmaphyssrc1 = 0;' Q0 p* \! Y s. T
- dma_addr_t dmaphyssrc2 = 0;
* W! a9 |- d* i4 k) H' p - dma_addr_t dmaphysdest1 = 0;# d- I. j) M6 J3 a5 Q
- dma_addr_t dmaphysdest2 = 0;0 b5 ?+ v: N& W1 Z- w( f% M
9 V0 p# B3 W7 j4 n3 ?: P- char *dmabufsrc1 = NULL;8 U9 C' W T; M* K6 H
- char *dmabufsrc2 = NULL;
6 `0 ~8 |. ^5 T8 X8 c$ Z - char *dmabufdest1 = NULL;
" c: v$ f/ m/ B- N3 d - char *dmabufdest2 = NULL;6 y: Z2 E6 b: g( e+ S
- % J4 u) X6 B) o
- static int acnt = 512;
# m- s" W- O& y9 n5 }# N - static int bcnt = 8;
5 k0 U) ~; ^/ F# _+ |3 F8 G% } C$ K - static int ccnt = 8;
. C1 i- q- j1 u" T/ I: v9 I - - S3 z8 M T( q! {
- module_param(acnt, int, S_IRUGO);
2 n* R. _7 ?, M4 E - module_param(bcnt, int, S_IRUGO);
' }. ?1 n* o& v0 J, E( @8 P - module_param(ccnt, int, S_IRUGO);
复制代码 4 \9 A- H. S$ s& m n. s
/ {& B7 l! x' k! s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 |+ J: I2 O1 T6 x2 [
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 N* N# ~4 a4 ^ @" ]' M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 k2 W+ a# D4 _: I/ N% E8 M
! t$ \2 S ]5 h$ v
$ P+ y; H5 f- {: [0 q- e% W" P |
|