|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' g2 X) ]1 y7 L6 z4 o- [code]EDMA sample test application8 X( p+ e, h* \9 H& C. \
- /*
|$ c' u' P) O) g8 Q- M - * edma_test.c( x! b! L8 ~1 b/ d. L) ?
- *
, I1 v$ E% g7 Y2 ] T - * brief EDMA3 Test Application
. ?3 m- H$ j' _- U3 @ - *
6 C n/ N7 {7 }+ H% o1 [6 n O! D - * This file contains EDMA3 Test code.; f I$ Z) ~2 u0 A% d6 N4 c* U
- *
, ~9 B$ R& \ l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 S3 B& b4 h! I1 y9 W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 D$ h- {' X( J3 j# N9 C- ?8 c
- * TO CHANGE.. F5 Q5 ?+ I z- S* P# m
- *3 ?- [" y+ d+ y( Q, |: q$ z+ \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ g$ B1 t3 K; S$ d, C7 g
- *
# L9 _2 R7 O; }( X; h - * This program is free software; you can redistribute it and/or5 m8 L2 Q0 N. H2 e! _. W
- * modify it under the terms of the GNU General Public License as
( p/ V& U' c" p, }8 B- z - * published by the Free Software Foundation version 2.
7 a; q% U3 M. ?$ v - *- [. p7 u9 s! B/ |" v
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: v# ?3 H; g f3 @4 _ [' w/ S - * kind, whether express or implied; without even the implied warranty) D& ^8 u a9 G( Y! S" r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! l" P3 t4 q5 i4 {' a" D9 l1 M
- * GNU General Public License for more details." g( C" u/ z: y; f6 w
- */
9 D& S3 P& \9 c( V7 f) b7 d g/ r8 u
+ Q+ }. ]$ f2 N" ^' ^- #include <linux/module.h>) t! ^* x( g+ C5 Q! h
- #include <linux/init.h>
8 `% X. {6 R) ^: U# X - #include <linux/errno.h>' E$ V1 S& v( O+ h7 |' n
- #include <linux/types.h>
3 l3 r2 R( ]( e% ?5 k- O+ F' h. A - #include <linux/interrupt.h>+ x( \9 r. d( D0 D0 V
- #include <asm/io.h>5 Z* g* ]& _8 M5 p& s+ G
- #include <linux/moduleparam.h>' j" }: s1 w w1 x& T9 ~
- #include <linux/sysctl.h>
$ R. c N' B4 f - #include <linux/mm.h>
& C2 L" W4 s! R; r$ c9 U7 n - #include <linux/dma-mapping.h>
6 @" `4 `- K2 n- u( ~8 L) j& q
# w" j( P6 Q" u- #include <mach/memory.h>; z4 ?1 o7 p( A. B4 K2 K& [- M0 C
- #include <mach/hardware.h>
1 X9 w) m9 N- m E - #include <mach/irqs.h>
- u& l! Z! K% S4 f/ I! i+ U0 b( P - #include <asm/hardware/edma.h>' r; W0 \9 ?4 T6 @: E
0 d, n& x3 k; n7 H5 E9 J8 R! c- #undef EDMA3_DEBUG
; k/ X7 l$ {7 W9 Q5 \6 X1 _8 E - /*#define EDMA3_DEBUG*/" B5 Y7 o2 U2 R3 V7 g6 [' W
% ?( [$ C& o V3 g& r" U! _- #ifdef EDMA3_DEBUG# P+ Q9 P2 a( q5 Q! a, ^3 ~# p( v3 H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 }3 y5 B6 {- i- O2 D' z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( E+ q. U" u: `% F* f( I2 Z
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 A4 j0 [8 u! d+ L* c! E - #else
$ `8 s: `2 p, Z e% n: m: r - #define DMA_PRINTK( x... )
: T E6 w4 { A9 I - #define DMA_FN_IN) D" S6 C7 s- W+ [+ t* U" J0 L
- #define DMA_FN_OUT
6 l" `% ^7 |: a) M3 V$ ]2 X - #endif& p4 e' ^ v% q; }
- : S$ D! a9 e- O; W
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 W9 y* I- g8 y
- #define STATIC_SHIFT 3
* _) c o; l2 o3 |6 B2 V - #define TCINTEN_SHIFT 20$ z% b2 T; Z( e" T+ g, q
- #define ITCINTEN_SHIFT 211 t! z h6 X5 D. m
- #define TCCHEN_SHIFT 22
. i% V; a: u. k p9 Z& B - #define ITCCHEN_SHIFT 23
7 y2 c: W0 Z& M. N E8 i
5 J: Y* W/ y$ L- static volatile int irqraised1 = 0;
1 L/ i( }9 P7 w - static volatile int irqraised2 = 0;; m; p9 [1 `* N, f. a
- ! u+ I J5 A' Q' d
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' u( k/ Z" X3 p - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' V9 {# x$ ~$ c5 X4 Y: Y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ |( c9 J* W& d5 c5 D5 Y* J
. D1 Y, t& ^; C" [3 U$ O- dma_addr_t dmaphyssrc1 = 0;
R9 k! I1 y0 O - dma_addr_t dmaphyssrc2 = 0;' P0 l4 i2 c! b: i7 D
- dma_addr_t dmaphysdest1 = 0;" i6 G5 i: n7 f* i
- dma_addr_t dmaphysdest2 = 0;
% T" N7 z% G% W: r- n' G! Z - - [ \& l6 ~4 V! F# J5 f
- char *dmabufsrc1 = NULL;' v6 p0 V: g& G2 ~0 d0 E
- char *dmabufsrc2 = NULL;$ |3 a8 L1 u i1 F7 L G3 O
- char *dmabufdest1 = NULL;8 h# o- g D1 A: W# ~2 X
- char *dmabufdest2 = NULL;; j6 y9 ], N8 c: w
( `+ D( M9 I, H# n- static int acnt = 512;6 r$ o; {' a/ ^
- static int bcnt = 8;
& q8 u; s) b3 u - static int ccnt = 8;
, h9 D$ M% r1 G" _9 Q9 [' H - 6 r& s/ G+ k* A$ I# f( c: Y
- module_param(acnt, int, S_IRUGO);: N& `8 d& ?* B% }; `) M! ?1 e% o
- module_param(bcnt, int, S_IRUGO);/ Y* l/ T9 W2 k+ H! j& Q8 l; E
- module_param(ccnt, int, S_IRUGO);
复制代码 ) Y9 r% |8 E1 h- ^: f* F T( b
9 S0 a: B8 t% @: t* G- }* V! H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ Y8 P9 o4 _+ J0 B: b' U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! ?( I; s4 h; u6 p6 p# Q, P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' ~5 [5 M* D3 s& a _
; M' D, V. E. z) Z
: o5 R" S" e; ]" [ |
|