|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. p( b# I0 b( R5 n7 L: p' L- [code]EDMA sample test application
+ O' u0 x; V4 t4 H s" D - /*1 C, Y0 \% K. r8 h- X' ?* ^
- * edma_test.c
" t7 y/ B& C% P5 D1 I" r$ A - *
; R5 p P9 u6 K( w8 b - * brief EDMA3 Test Application
1 m% G$ V: v+ d - *! E, Q- a. Z0 A- M& D9 T* \- {
- * This file contains EDMA3 Test code.
2 K! r, o" u2 m* w" u, M( W - *
) j. g, \/ Y7 j& I# i7 s$ ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. P& |6 I* F" Z+ O( L# o e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( A# s: R5 R/ s- t! J% N# a - * TO CHANGE.) d2 R$ Z- i7 L) R' N
- *) L6 J; v) J0 _! v9 I x! u' i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% h& I6 k8 R# t& `5 S6 J. A
- *
0 Z, q1 i, c8 P - * This program is free software; you can redistribute it and/or
- G5 P7 K1 o$ H+ w - * modify it under the terms of the GNU General Public License as
7 R1 W3 h1 m. O/ K - * published by the Free Software Foundation version 2.
# f7 L! e7 F( } - *5 w3 W$ v8 @+ F" v; w! k0 _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 f* |# J: w8 w& ?* w2 q2 F: e/ N
- * kind, whether express or implied; without even the implied warranty' j. z6 w( H' b7 s7 ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- l+ e$ L) g; i* I - * GNU General Public License for more details.
( P u3 l( b7 h% W2 n - */2 N8 H1 H, U3 {- }& }8 \
- : `# l( Y/ S( U" C# t, h
- #include <linux/module.h>
9 J2 t, x$ `6 S" s! K - #include <linux/init.h>: S# m3 j4 V- D% a
- #include <linux/errno.h>
7 d1 Q) l! z- h( F - #include <linux/types.h>
! X( O: ^& y5 @% B' V9 ` - #include <linux/interrupt.h>
3 @! ?2 W/ G, F n# ]0 V - #include <asm/io.h>
% q2 G2 j' j, j+ g/ L - #include <linux/moduleparam.h>6 j- U- a! s' f4 R8 L! d$ R
- #include <linux/sysctl.h>
6 E% s M7 O$ s - #include <linux/mm.h>
# U# x% v* f$ v! i2 k& C - #include <linux/dma-mapping.h>
4 l C; \ u) E$ N1 q V6 s
; T" l/ J7 C7 {. Q; H- #include <mach/memory.h>5 d1 q3 i+ m! {( x6 P- a
- #include <mach/hardware.h>
( Z" X X0 n, }/ L" H! o2 g% x - #include <mach/irqs.h>
% m) N# \- t6 `# D - #include <asm/hardware/edma.h>
. c7 |$ @) C% F( Y/ o0 E; G2 M - ' m6 w5 e0 l: B8 y! u
- #undef EDMA3_DEBUG
/ o- {8 Z3 K8 W3 ]5 E - /*#define EDMA3_DEBUG*/% V5 J- g3 I: Q, ^6 m8 w W* f
' l9 H1 o6 D% b' U- #ifdef EDMA3_DEBUG
; n$ J# K f8 J& U1 T7 d9 j% S/ d9 ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 h! _3 ^8 u. G L, s. f4 N
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! J& k7 p$ `9 W# Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! ~' N- @" y1 a% L8 a - #else' W7 F- ?' a5 k9 y
- #define DMA_PRINTK( x... ); R- S! f4 E. t0 z
- #define DMA_FN_IN
2 @5 t- _" J7 Y7 H4 a - #define DMA_FN_OUT
/ N. H) L! K. R S8 M - #endif
8 j6 x: V6 e$ @" u3 X( h8 d - & b9 T# J/ f4 e' v
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 r! s/ n8 q6 T6 ]( x - #define STATIC_SHIFT 3
9 J% D$ ^( t4 h9 T( H3 ?- X3 L - #define TCINTEN_SHIFT 20
+ Q( o$ q# M! r0 [( h - #define ITCINTEN_SHIFT 21 t: ^4 ] F9 {, j* g* ^% _- G
- #define TCCHEN_SHIFT 22 [' h- j3 i0 X4 c# G& ]+ t
- #define ITCCHEN_SHIFT 23
8 ~4 B# a2 G N# N2 Q9 i! n - . N. e# l; j h6 V4 T. b" @: c: ~
- static volatile int irqraised1 = 0;6 h5 ]( w0 b z) h0 k! V# A, [
- static volatile int irqraised2 = 0;1 O$ f# ]* G' H1 G5 y+ Y
( r0 N$ o) b: z* M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) X. _$ [2 [ D8 I$ G1 b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 N+ \2 R: g) E% d% P - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* l5 c O$ D! E$ E% O: u
3 o: l0 ~5 |8 b* ?; w- dma_addr_t dmaphyssrc1 = 0;; V$ R7 V* O# a! \
- dma_addr_t dmaphyssrc2 = 0;* ] o. [% e+ \( X6 i2 M
- dma_addr_t dmaphysdest1 = 0;% g1 J, k, }0 f
- dma_addr_t dmaphysdest2 = 0;' q4 W h% b0 p3 A
( P, X2 R$ k, E" Q- char *dmabufsrc1 = NULL;
0 S" x2 q! R3 n3 D - char *dmabufsrc2 = NULL;
7 M2 l) m: K0 X3 V& ]( @ - char *dmabufdest1 = NULL;
& \; a. o+ T6 k0 u" |3 Y - char *dmabufdest2 = NULL;
3 i7 n* Z: A( Z$ y* w
5 I0 T: {* L! t, w [) M- static int acnt = 512;4 O$ Z0 S; U: _# t( h
- static int bcnt = 8;
7 X' r0 [# l0 r8 A' L- i - static int ccnt = 8; V" J1 R/ ~ f! ^ h
- - P! {+ Q- e/ ~, Q7 f
- module_param(acnt, int, S_IRUGO);
, L5 F$ K* h7 D8 w - module_param(bcnt, int, S_IRUGO);
9 g+ p8 c. m& r4 O; o5 Y$ J - module_param(ccnt, int, S_IRUGO);
复制代码 : f7 V. N2 r @5 B
5 s8 Q5 U" W" U& O
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 @8 F8 I2 o7 J! e7 R. @' oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 B, b* n( D. h* M. t( Q7 H; ~ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: J: h5 A" o, _2 J
3 v) {& H7 k2 D+ o
' \: N) I6 C9 h% @+ m2 i3 G+ y |
|