|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 h. s& I6 W( l, N1 Y- [code]EDMA sample test application
0 Q5 S4 t8 W0 J: Y1 {3 k1 l - /*
1 }% ]# a& q5 k! Y% b! l( m7 i - * edma_test.c
0 p7 a* m9 p1 p i' V1 y - *
# i3 f0 R* H8 {2 [1 Q3 A, ` - * brief EDMA3 Test Application5 C: w: c4 z& k" _1 ~
- *2 c) s. C/ G2 k. v- b
- * This file contains EDMA3 Test code.& L3 i9 |% X' x, U( O% n
- *8 l0 R; t" |, ?+ [/ z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
B7 n6 w4 ^; K9 b' t: x2 T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, h( {. J4 [- V+ P2 T - * TO CHANGE./ }1 Q" h) }& o" K5 j! _8 h( Y
- *
) ?) E& |, l/ g0 z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! K( y9 V. |" m* t! R6 ?
- *
" ^( L! i9 H* R0 v% ~- K - * This program is free software; you can redistribute it and/or, x( J# ~; U; e
- * modify it under the terms of the GNU General Public License as
u( r" V& Y( G. ~ - * published by the Free Software Foundation version 2.
, w' ^4 c# |. l# |4 @. ]( } - *
# @( Q4 |3 d7 E, _9 ~$ ^ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 Q# Z# M. y+ |7 E! m" b y
- * kind, whether express or implied; without even the implied warranty
5 `# @! Q9 ?2 G8 x& U4 X4 N9 a8 h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- Z0 i' @/ h) A* P* J* q
- * GNU General Public License for more details.1 B5 M" L- b6 R: t, b
- */
6 \: }5 d' z- M7 v4 X% ]. V/ ~/ L - & G% P8 {& Q6 p, Y
- #include <linux/module.h>
`( H. Q& {7 j0 p1 {( \ - #include <linux/init.h>
% Z$ |, I8 t2 B r7 U0 `! t" N- ` - #include <linux/errno.h>5 `6 R! z# w/ O- N0 l) K
- #include <linux/types.h>! ?1 O- s" x: _/ B
- #include <linux/interrupt.h>
7 f; Q- O1 o7 Q% o& A7 ] - #include <asm/io.h>
/ S, z! P- K0 Q. w ? - #include <linux/moduleparam.h>' G. {! o( I& T8 k" P
- #include <linux/sysctl.h>, l0 N& g% z3 t+ Q) {6 g
- #include <linux/mm.h>
( R5 m; p: T9 b - #include <linux/dma-mapping.h>
! E! C" A% Y9 N. P& Z# q7 ^
& @3 G( [5 r1 I5 |8 N' l- #include <mach/memory.h># i: s: u+ k1 W- |
- #include <mach/hardware.h>
5 d" J* f3 P0 X) U. N - #include <mach/irqs.h> M3 R1 @, D: A" m# |# n
- #include <asm/hardware/edma.h>: e7 v& H/ ^& d* [: j+ o
$ f" O' J) x W, R7 n( K9 d3 ?; z3 s- r- #undef EDMA3_DEBUG7 I) H5 b& P! E8 N
- /*#define EDMA3_DEBUG*/
* G" _, R$ ?& E, Z8 J
' E; n7 W: h+ S, h: `- #ifdef EDMA3_DEBUG2 j8 F, E* I6 |/ m i0 A
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ e1 p, n3 i# R: C8 t* c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* |7 U7 \# O- {- l5 @1 v
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% B1 p% \' q1 n) [8 W) \ - #else
, S8 N$ e8 f o4 s$ K - #define DMA_PRINTK( x... )' w. F K' }1 \/ w8 Q/ m
- #define DMA_FN_IN3 O) y8 M5 H& y- ^8 @& w
- #define DMA_FN_OUT: x; x8 s! S- O1 a+ |
- #endif
- ~& ]8 \8 ~0 O1 \0 V - 5 ?1 w6 _4 l( G1 `, o" k5 z X( c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ W, F. {8 q4 u: m# o0 m/ F2 d - #define STATIC_SHIFT 3
% q) |! c% ^/ O0 R - #define TCINTEN_SHIFT 20
# n% z( L5 I; b4 u6 V2 v4 ]6 S - #define ITCINTEN_SHIFT 21
+ |% r# W: | u6 e - #define TCCHEN_SHIFT 22" w4 f( C4 W( N, a* j, I
- #define ITCCHEN_SHIFT 237 A2 e* g1 {+ Z& ~
* d3 ?% {+ ^9 o) O+ C3 R7 T- static volatile int irqraised1 = 0;! h& X# `- A2 I
- static volatile int irqraised2 = 0;
) C. |) g! Y% E/ K9 {( t+ q l# G
' T$ l9 O9 X; u+ C. w% W/ c: x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) G8 v" F1 Y2 U4 v( V! e5 y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 @6 d5 r% L f- U - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 N+ ^4 O z: W d9 f7 P% G$ X
2 ]- ~6 s, r6 M8 _, i6 a- dma_addr_t dmaphyssrc1 = 0;' U5 W& z) e+ q( \5 J. j( H/ h
- dma_addr_t dmaphyssrc2 = 0;
; ^4 S4 O+ d- [: g! ?6 Y - dma_addr_t dmaphysdest1 = 0;
6 M N2 E7 i: y! _" W8 S { - dma_addr_t dmaphysdest2 = 0;
! q \2 b, s4 V {
9 l6 J+ _: K/ d- char *dmabufsrc1 = NULL;& Q {$ Q! X, F/ t
- char *dmabufsrc2 = NULL;
# R. K! B1 c" X( Z, ~5 P - char *dmabufdest1 = NULL;8 D j3 d1 d/ o7 h, f
- char *dmabufdest2 = NULL;
0 f) ~: J A0 L6 H3 H3 H% b9 r8 M
% }- u( L5 U5 T) z2 I3 S4 y- static int acnt = 512; v% p! X1 O; {" ^7 w
- static int bcnt = 8;/ z4 q. ~. \* p$ D9 y- U/ m" Q
- static int ccnt = 8;& N+ Q) G/ T3 Y, ^' x- M0 o9 d# h
- 9 G/ |+ V6 m9 Y* \ P
- module_param(acnt, int, S_IRUGO); c0 G' m3 ^% J( z! {8 T
- module_param(bcnt, int, S_IRUGO);
$ J6 ^ u! S- ?% b- G1 Y - module_param(ccnt, int, S_IRUGO);
复制代码 3 l% Y3 E1 l: Z# S
9 t, J/ c. |8 }- _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ m7 Q* j. H# q& h! Q0 P1 l5 X; V
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$ S" f' f3 U% x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ h3 q# Z- f1 n9 ]% [
9 f7 o( }* C/ l/ Y* n+ Y, u/ _- P2 _# k; O% \
|
|