|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 r) {/ a" S* G! s+ B
- [code]EDMA sample test application
; J U- s4 } F0 i, c0 ^7 l! Y - /*" ]7 L: W/ v& k4 K3 z
- * edma_test.c9 x6 ~( B7 |+ V @$ S, p
- *) p% c6 s* E8 U9 L0 {# j! a2 Q# @
- * brief EDMA3 Test Application
6 z6 v5 N/ c. X8 ^) Q; r) G" r - *
3 t! U6 R( h# _7 R" g - * This file contains EDMA3 Test code.6 [4 Q3 h0 G. C. {+ E# n2 J8 x
- *& H' p7 e" L! o7 L
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" r9 ^5 u ^! B: Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& B" \% V( K" ?8 ]
- * TO CHANGE.
/ C5 E4 K2 M/ H/ b/ Q2 J - *
; v- }: m( f2 q! ?0 i( o) I" x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* G' I$ ^. C6 [5 O2 _& c
- *1 M8 u, e$ L4 Z- E
- * This program is free software; you can redistribute it and/or
5 L0 a/ n+ o9 ]9 B7 K1 |5 [ - * modify it under the terms of the GNU General Public License as+ O' K" {) p3 A" k1 H: u0 J$ g5 v
- * published by the Free Software Foundation version 2.* ^1 J+ K2 V* I0 X/ q- o$ z
- *
7 |# } G( n% x, ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) T9 N! E# a& ~- e) f
- * kind, whether express or implied; without even the implied warranty/ Y2 [1 a i8 A! \: z2 r d2 x
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& b' u4 |! K3 w* K4 ~4 h8 S
- * GNU General Public License for more details.
, f) R1 m9 a9 L2 U' |# G - */
?- l1 B: g- Z5 e - ) x' Y# a1 C1 F
- #include <linux/module.h>) q2 S% S" ]! B2 t2 a1 g
- #include <linux/init.h>' w/ l7 x/ I E
- #include <linux/errno.h>
* s' p0 F f. d( y- V* U7 f; r - #include <linux/types.h>: D+ H/ f, E0 a D
- #include <linux/interrupt.h>
. ]1 l a; {) R+ }/ ~+ @3 S - #include <asm/io.h>
$ ^- c1 \2 j0 R6 c& W$ e - #include <linux/moduleparam.h>. q( G' ^" l6 d2 u7 u+ A5 t2 @! s
- #include <linux/sysctl.h>8 I" s$ Q) q" O1 }" ]
- #include <linux/mm.h>; j, V9 O# }; a
- #include <linux/dma-mapping.h># {( m! U- q5 ~0 A
- , V" h; k. v0 q; [% z
- #include <mach/memory.h>
, {7 R& U/ s1 i' z' U* q7 f1 n, { - #include <mach/hardware.h>+ s* [5 U/ E' f! ?2 X! ~6 w0 w
- #include <mach/irqs.h>. v# g4 K1 S9 i( O$ _. [
- #include <asm/hardware/edma.h>
& w# L* L& T" k! y$ b1 l2 { - % [: G8 K5 u2 f
- #undef EDMA3_DEBUG; p* V% s$ j- A# O4 N/ r- j
- /*#define EDMA3_DEBUG*/# ~) m" n* Y) y
+ p2 m- N- }4 v1 p- b, r- #ifdef EDMA3_DEBUG
9 s1 z! \$ P7 Q4 G% N1 A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* }0 c" y, y( d4 h: @ c# X& M( X - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ Y) U5 V7 I1 N2 O3 C' B; B! J, _
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 V! w0 t' e! }( w - #else
" J7 r( a" j6 P2 u$ k5 i: s- ] - #define DMA_PRINTK( x... )
5 g# c. b# T5 h1 f" A - #define DMA_FN_IN/ t6 k* U, F3 Y) [
- #define DMA_FN_OUT
7 H' n% L( y4 Z8 g9 g# ` - #endif
1 K9 g- C5 V% L0 ]
, S4 c. w/ a) Z& A3 f$ C. P% L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 ]( R% q! a6 Z& q- I
- #define STATIC_SHIFT 34 { G; L: I2 R& s) @1 E
- #define TCINTEN_SHIFT 203 Z4 h3 t7 T. g O/ a! U: q
- #define ITCINTEN_SHIFT 21% A$ x; M' @5 S9 }/ X6 l
- #define TCCHEN_SHIFT 22
$ \. j! R8 n/ p+ ~! V - #define ITCCHEN_SHIFT 23
$ d0 N/ T, X) ~- w; V7 `
8 c% d6 l: _& N$ m- static volatile int irqraised1 = 0;4 x+ U" Y3 _( k: T; p; E
- static volatile int irqraised2 = 0;
M8 R/ f; e2 ^( [( L" r, [$ }
( Q$ I! U% d1 n9 e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 s6 S0 B& n4 A - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 y2 v8 R, l6 ]" c+ _3 y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- e7 K; R+ _* a
- & {8 T/ d, T* ?6 U
- dma_addr_t dmaphyssrc1 = 0;
/ J) g# I8 E" Q2 ]0 n% a - dma_addr_t dmaphyssrc2 = 0;
! a7 R, @, N# b/ ~# ^* e - dma_addr_t dmaphysdest1 = 0;7 T4 j d2 _/ @2 t+ I6 q1 c
- dma_addr_t dmaphysdest2 = 0;
+ x" ~. g, M' o, n
# W7 \. x4 O* _$ J, v) Q# a- char *dmabufsrc1 = NULL;
$ \5 Q& U6 E5 t1 F; l/ d# X$ x - char *dmabufsrc2 = NULL;
1 k. r! c2 B# L( Y0 V - char *dmabufdest1 = NULL;! A; @+ H2 a5 P2 \; ?
- char *dmabufdest2 = NULL;
. O% ?$ a2 S% S' { - 4 {* S( X$ q3 Y
- static int acnt = 512;& I. l' q( W. U. B+ U2 d& w
- static int bcnt = 8;
5 i) F* W2 x2 \ {# R - static int ccnt = 8;
8 }! t; |: b, n& ]4 Y& E/ v8 e
, k0 ~" T. u( {- module_param(acnt, int, S_IRUGO);
- z; x1 D; D1 O# B/ D0 ?/ g - module_param(bcnt, int, S_IRUGO);2 C! }. S* _1 D0 S
- module_param(ccnt, int, S_IRUGO);
复制代码 / C, o& a( |9 k( K. W; f
. Z+ I" d; J% [: L% J: ] 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 {2 [! L0 M( n- D/ r) D# w1 y1 k
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: G: w: n4 L6 f! h
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 }' [# I7 n; @. {2 [
; K. z& e9 {2 g+ j B" K
9 h; R/ t) w U& t. Y |
|