|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; z1 u7 s/ _3 q1 n# U4 O: A) s- [code]EDMA sample test application
. N5 i; T% ^8 w( ~; E# w4 W, Z% Z - /*
7 D# Q# ?/ u- }9 u* V9 i - * edma_test.c
& {/ W4 ?' l8 ]7 I$ R( C" C: H% _ - *$ Y, I" B( o, i7 O$ j, R) Q
- * brief EDMA3 Test Application
T4 m" K6 x) x7 l; f - *! g* ~# k7 r( F$ u ?! |
- * This file contains EDMA3 Test code.! c' e9 D8 l8 P5 P$ m5 f# E% s: ~' _
- *0 k5 _" w* W) Y; j6 }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 V D/ E3 W- r. S) D. |$ h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* _* y3 G" h9 {$ D7 j9 u
- * TO CHANGE.6 i& A" ^+ A- L: X
- *& @. ^% l* o7 \/ c/ _( a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. c% r6 z& Y5 z. V* v y+ ~: ~ - *
9 p; ?0 G6 X* T7 ]& ~: w - * This program is free software; you can redistribute it and/or
$ w/ Z# A% L' x! Y) u+ i - * modify it under the terms of the GNU General Public License as
$ I6 x A: _( G1 a: p# X - * published by the Free Software Foundation version 2.1 T" \ P9 D7 t2 D- q: A" E
- *' d% F0 q2 ?; o* M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' ?9 M5 J- j+ w2 D( x+ w9 W
- * kind, whether express or implied; without even the implied warranty
2 s% A- ?6 F: l3 T5 b4 k q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 n b6 L! C3 H6 K5 X% D, C! j2 d - * GNU General Public License for more details.
. |3 @) I/ _4 v( S2 f; P - */1 u, {- x5 \ M8 _ }
( O6 a e0 D) h, m- #include <linux/module.h>
; M2 {# a3 I6 E& R9 x3 P - #include <linux/init.h># l' f2 L4 Q$ p& h
- #include <linux/errno.h>
9 f6 T, C) h; F' |; B5 z) w1 ~ - #include <linux/types.h>
) [* ] ^3 U' Q: a' f* m4 W - #include <linux/interrupt.h>
4 i/ u' Y& z9 i; b5 { - #include <asm/io.h>
" X% y; S+ x5 V7 C$ I4 { - #include <linux/moduleparam.h>7 j; R3 w! S& M6 @# {! @* ~) r
- #include <linux/sysctl.h>
~$ w0 N3 @% x0 K2 n, l - #include <linux/mm.h>
2 {$ p$ T! z0 L. U1 P n - #include <linux/dma-mapping.h>" M3 w& B4 i0 {' y9 X6 y
- & p; ]( t6 M' A* R- g
- #include <mach/memory.h>" w5 a" d0 }( w4 P. n% J
- #include <mach/hardware.h>, y+ x& @6 x# D+ P, J7 ^
- #include <mach/irqs.h>
, z8 m/ S: T. [0 U! D - #include <asm/hardware/edma.h>' E* t; [+ L" _# m4 W z0 i) A# ?1 N
- # @! F4 Y. L! l- r% k) A8 R1 I
- #undef EDMA3_DEBUG
1 y0 P( D! f; `+ b/ w; I - /*#define EDMA3_DEBUG*/
& _/ L8 ?2 [2 `; d4 _ - # X$ D" P% w- E. Q
- #ifdef EDMA3_DEBUG* f: q, }- a: ?# P
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 Y8 m1 O8 b( \; z- N' B, k$ n9 h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 w |8 L; M, b- U. y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 g4 \5 t0 ^8 i3 B4 p8 F1 A8 z; w3 s, E
- #else4 d D7 j8 |( X- [
- #define DMA_PRINTK( x... )+ z2 a9 d1 m/ h8 G& W4 R8 S, v! _
- #define DMA_FN_IN
$ f9 y! T% ^# A - #define DMA_FN_OUT
0 N* D# [8 R. S& @ - #endif
( v5 @. |+ U+ h! P9 _
* G9 L" t3 [5 _( J0 E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" t5 D' ? L. ?- D( }2 W9 W: U
- #define STATIC_SHIFT 37 r$ H1 x! H$ q2 _8 z( v2 y/ D
- #define TCINTEN_SHIFT 202 a$ ~/ k! p4 N, s; T
- #define ITCINTEN_SHIFT 21/ G# I9 X% }% o& k1 S
- #define TCCHEN_SHIFT 22$ ~9 a0 f$ T+ B/ L( W! k- j
- #define ITCCHEN_SHIFT 238 [% k; X% n( ~
- 8 O; Q$ Y; D: k8 @
- static volatile int irqraised1 = 0;
9 Q. _2 p% a. O3 D( V5 S - static volatile int irqraised2 = 0;3 }; [8 v% w/ R1 e4 M
( m" c+ M" T8 n" a6 q6 p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ l* g" C: j% p F - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% ?+ _" D& W5 E1 A6 d0 i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% z: U/ l# v: y, l# N( \8 Q1 K - + G) f- a7 z O) j' @$ o3 k
- dma_addr_t dmaphyssrc1 = 0;
$ N: z- d) K& Q+ U& I - dma_addr_t dmaphyssrc2 = 0;
! X8 ~+ M) ^6 W' r( L; |7 l& J; d4 V - dma_addr_t dmaphysdest1 = 0;
( E z* P m, K$ { - dma_addr_t dmaphysdest2 = 0;
. y7 Z3 @; m9 z; [
2 I3 U7 ?5 s2 M% [- char *dmabufsrc1 = NULL;
( I3 T' B) e+ u" R+ e! W - char *dmabufsrc2 = NULL;! @8 ?8 t$ A9 C I2 q+ \; A
- char *dmabufdest1 = NULL;, }9 A7 m( y: e9 n( z6 Z* I; F0 x
- char *dmabufdest2 = NULL;
7 O/ ~. t6 x! q- z8 S
) b' n0 M. k( C, F* j( i2 o- static int acnt = 512;! c5 b0 w( f0 L- N. o8 o$ q
- static int bcnt = 8;9 ~ s' K x3 V) _* \+ H: b( ^
- static int ccnt = 8;
. J2 M! c6 k' x1 P8 _2 Q8 @
4 p3 A4 X- m! S6 {, _! s5 ?- module_param(acnt, int, S_IRUGO);
' L& T. U/ x1 |4 y/ K - module_param(bcnt, int, S_IRUGO);
N$ m& f6 V8 p! x5 u; i - module_param(ccnt, int, S_IRUGO);
复制代码 " E3 ]9 B% l* {! O# ^
6 N. Z, T$ z0 ^+ k+ y' X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 @' a) N7 q! L+ L
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& h! V3 @0 \! G6 p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' ] o! U0 ?5 q: O A& _: k8 R4 { X* h& F h
, b6 h Z% J& f0 V( Z* |: s9 R$ D |
|