|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 u3 _ X/ N* G. C4 b8 L. G
- [code]EDMA sample test application
5 U2 l/ N* P2 N1 s9 |& U' B9 i - /*( @1 @! z- c1 Z9 M" D
- * edma_test.c
) X+ Z4 y) \; @. p2 c - *
7 Z) ^% G& N8 ^4 V+ m0 Q - * brief EDMA3 Test Application0 a) u0 U4 u. p/ H+ K
- *
' I& d$ c% O h% X" y; i - * This file contains EDMA3 Test code.
! C' `7 u. Y8 ^% { - *3 [4 ^" ]$ F" K$ H5 }" L* R0 v4 u
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, |, l6 n8 k7 m6 u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& ~$ e' h7 @- W0 n
- * TO CHANGE.
3 p) A( U0 b( y- n; Y - * }( D# S6 ~( y$ x. d! a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- N2 T+ j6 q' @
- *' H) X9 B! \& H2 b4 w+ L% I
- * This program is free software; you can redistribute it and/or9 ], B! C; t# U6 `5 X3 c9 ]
- * modify it under the terms of the GNU General Public License as
% B: z& M+ @. k) ^5 m - * published by the Free Software Foundation version 2.& h& D3 h" H! v, _' X. V5 j
- *
9 C4 |0 X9 z! P. @% E$ c% K - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( m& W" Z/ _7 E9 O: ? - * kind, whether express or implied; without even the implied warranty
* L) z; |# G- t, w- G - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 x$ U- W; N" x& X3 N% ?
- * GNU General Public License for more details.
6 d! U3 t7 H5 k2 b- Z A - */7 a5 f! G9 r! v r) g
4 f8 R9 A7 L; n: U- p3 o. Q- #include <linux/module.h>
2 ~* x& ?$ C# d/ d! _ - #include <linux/init.h>5 M) m6 H$ Y9 [9 w" z' Z# v& {+ _
- #include <linux/errno.h>
$ }7 L$ k' S- j* l. n$ C/ y - #include <linux/types.h>
+ S7 c! K, W2 q' q+ b* ^9 g - #include <linux/interrupt.h>- u" K! K. h! y: E4 r0 k
- #include <asm/io.h>' z) Q0 n, r/ u9 L) \5 G+ c
- #include <linux/moduleparam.h>
1 i* C, Z& R& _( b$ W$ _ - #include <linux/sysctl.h>
- G7 Q) H4 n5 _1 K - #include <linux/mm.h>
5 }9 X! _6 a/ W. v3 z! ]" g - #include <linux/dma-mapping.h>
9 J" Z8 q- P2 b& ] B8 p3 q
8 [3 S; v/ q0 q/ ]; I- #include <mach/memory.h>
0 o. r$ ]$ V- Z2 C9 t - #include <mach/hardware.h>
* m8 Z# v* C! [; o$ l N - #include <mach/irqs.h>. }8 w9 T# k0 z$ s1 f
- #include <asm/hardware/edma.h>$ F# n1 X* M) ^% U" ]5 J
- 9 T2 ? q" w1 G) {- T9 Q
- #undef EDMA3_DEBUG6 F( w. U# }0 a+ C# b* y
- /*#define EDMA3_DEBUG*/
( |/ U2 A- s6 T' P G - 7 s7 G. {! T6 r- |
- #ifdef EDMA3_DEBUG
; _ @; B0 d9 U, B9 I4 j - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: _: M! }4 q% v% S8 ]6 p. q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& f/ c! X& @- W8 A( ~, J - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) D/ a$ Q1 c8 e& A/ A - #else
( i, i n! L# I - #define DMA_PRINTK( x... )/ B( E# f, i% v7 _7 d
- #define DMA_FN_IN
0 C: G, q% E1 m% ?9 v( v, U1 d - #define DMA_FN_OUT
8 }/ X# G7 S6 \! h4 Q' k% H( k- F - #endif* L( y& ~. T/ Y3 G/ F8 s# f8 t
- . B6 D, Q9 y: `) L
- #define MAX_DMA_TRANSFER_IN_BYTES (32768); J4 o0 F: s- t3 n
- #define STATIC_SHIFT 3# u `/ T1 ?0 @ K) g% j$ |# z
- #define TCINTEN_SHIFT 20
9 T( B0 I" O, u. R - #define ITCINTEN_SHIFT 21) v9 _- c* H& w- ^ n0 X4 [4 B
- #define TCCHEN_SHIFT 22
; @9 b5 Q6 a7 P4 F+ \ - #define ITCCHEN_SHIFT 23
- z) Z [/ U9 V8 u
2 F1 h& X7 d% c T4 r! m0 f- static volatile int irqraised1 = 0;2 H: X$ S) {& C# D' p
- static volatile int irqraised2 = 0;% k( \& P" z8 m& F$ c+ q# m1 h
4 I4 j _$ ?+ o3 p/ h& [% V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* c- s6 s, R& H; x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 d1 t y% q, K+ F% ^& B
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' X- j Z/ X+ K- ?
2 S) W V* R1 f- dma_addr_t dmaphyssrc1 = 0; h8 g6 {$ l+ ]- e
- dma_addr_t dmaphyssrc2 = 0;
9 D( ?0 [5 {2 s. ~ - dma_addr_t dmaphysdest1 = 0;
2 V, m* }% A. d4 }% t5 F - dma_addr_t dmaphysdest2 = 0;4 X3 N0 r, ], D
* y3 Z4 M2 X1 S- char *dmabufsrc1 = NULL;
$ a( v2 \ f% ]; t: G g - char *dmabufsrc2 = NULL;5 h1 ^( V5 Y5 S0 L4 u1 ~
- char *dmabufdest1 = NULL;
# X( I, t# e5 E7 b - char *dmabufdest2 = NULL;
+ e# R0 l) i8 }* x4 U v
3 w4 ]$ T: K/ t1 E) |- static int acnt = 512;
9 a9 F' L7 Z( p7 T - static int bcnt = 8;! {! N3 R' [6 |, K% ]: u9 y: z" E
- static int ccnt = 8;6 s2 V# x# J( o0 i
- |' O3 [+ @8 C% d
- module_param(acnt, int, S_IRUGO);
+ q9 [7 R4 P; o0 ~8 o. }! l* f - module_param(bcnt, int, S_IRUGO);
2 u/ \5 M( j. h) W0 W - module_param(ccnt, int, S_IRUGO);
复制代码
8 T7 x1 N8 I' s, ?4 k& o
" [ l9 b7 r) {6 R# n( `8 r 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 g- ^7 e+ x/ E( V8 q6 T$ m) S8 `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 p9 J" u" c' g2 w7 V 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 E+ o1 T# v: e5 c3 ]: K/ H( h/ y
" G# i* k' U: h1 \# ]6 J
2 O0 g. | `$ U3 O! S
|
|