|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. J) G/ t* i! H9 ~- [code]EDMA sample test application
+ F+ n* A' V4 d) B) h- B3 q0 i - /*
- G2 H5 T! V1 k- N% V - * edma_test.c# x" h7 Y6 z2 E/ l4 M
- *
' |! ]( z, F- l+ a+ }: E9 n - * brief EDMA3 Test Application
0 C# t% v. G- e5 ^. U1 v ? - *% f }4 }) N- F# B1 n
- * This file contains EDMA3 Test code.2 _7 u* Q7 e6 I) J3 i: l9 O
- * H5 A/ C0 }9 \+ ~; q R3 i! y7 c! P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: u; u0 s& M* F: B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( D' I6 X; e9 r( ]% f$ q4 O& K
- * TO CHANGE.
# V0 {% i' ^/ }; Y - *
4 ]) ]) E* l. k% l' M2 ]; N - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ V. ?: m D: x' p - *
4 b; E+ f+ r. d3 } - * This program is free software; you can redistribute it and/or
4 O: V4 ]8 }3 i" o! r - * modify it under the terms of the GNU General Public License as
0 s2 A' K' P9 [5 l: ` - * published by the Free Software Foundation version 2.! O* O- I* Y6 u* u3 s
- *
* \* g4 f4 I1 C) ^; v - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) [5 g1 b! z* I" }0 q/ B5 G
- * kind, whether express or implied; without even the implied warranty
! O, k% k5 K+ v( t, K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 f' o4 N: W: f5 k# v& k9 D
- * GNU General Public License for more details.3 _) H; `+ C- O E8 I
- */
L! J5 ^3 t: `$ I2 L4 [$ a
0 T3 F. ]5 R% ?- #include <linux/module.h>* [4 E! i/ a7 s6 k B. V% A; s' L! Z
- #include <linux/init.h>
, @" ?# X+ _* j - #include <linux/errno.h>
* Z+ a4 K. i9 k9 u4 a' Q - #include <linux/types.h>
1 @) V& O* u- y+ d4 `3 ?! M - #include <linux/interrupt.h>
6 Q1 \8 e; J x/ l* u! U8 p - #include <asm/io.h># [2 K1 Y" C, n$ s, b
- #include <linux/moduleparam.h>) S7 ~' a7 \4 |- h e2 i. T
- #include <linux/sysctl.h>
% _) T3 M/ b* i7 ~ - #include <linux/mm.h>
$ R: I5 e, {! D9 f" L+ O/ t: l - #include <linux/dma-mapping.h>
- H: U1 C& j* l6 b2 b
* ^2 Z! G# S4 P- #include <mach/memory.h>
# k8 Z3 T) H2 A* ]% }# r( ` - #include <mach/hardware.h>
- ^& o- B% T" X! v - #include <mach/irqs.h>! k/ g, t& ?* j& B8 g' H- u" R
- #include <asm/hardware/edma.h>
8 h: K. P- c$ P* D& G5 G
) Q( z7 {$ e* O- #undef EDMA3_DEBUG+ P* V( e. {. O I! h! R3 k1 }. |
- /*#define EDMA3_DEBUG*/2 X ~/ C- _; X+ K" P
- 8 G" J: i9 ]; I! ` M' F& U
- #ifdef EDMA3_DEBUG
! V! Q$ E$ C9 j1 ^4 B% V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! d- i+ B& d, K( ?' A
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( H1 L( U- [- q1 d" J! b3 h) D; w
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 p. |3 j' R. b0 k. c0 b" m
- #else0 b# `9 W4 F) {+ G `6 F5 A) p; Q
- #define DMA_PRINTK( x... )
1 v! W: c2 y0 E7 K' n4 D5 S/ X4 g - #define DMA_FN_IN
+ t! U2 K! G" [3 j% c" i$ \ - #define DMA_FN_OUT
: m; j: A2 f9 U, P) v - #endif6 A/ T9 \' ~! \0 U/ h
9 x$ M; P6 _% V3 Y+ F/ k2 k- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 l5 [2 W1 i& V6 l+ _
- #define STATIC_SHIFT 3( y/ @ L6 L) N, j1 l& Z
- #define TCINTEN_SHIFT 20. t8 F1 C6 R% J4 |
- #define ITCINTEN_SHIFT 21
- [9 c3 g! t2 ` - #define TCCHEN_SHIFT 229 Q( w0 E& U9 `* y
- #define ITCCHEN_SHIFT 23* Z1 N' z4 k2 E7 v% i- T5 p
- . V% K8 z& _ W% ^. I9 V
- static volatile int irqraised1 = 0;
& c; V, S" M# m2 v; A - static volatile int irqraised2 = 0;- X; D4 {: o0 Q$ O' X) L) C
3 G* R6 p' }, {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 Q' v; z8 A3 f# X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 y0 H# r7 k, p0 o/ c, o. e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 Z. x& v& K! P# F9 h6 I/ m: {2 K
) ^6 @5 u, x) o! P) F- dma_addr_t dmaphyssrc1 = 0;; \9 N/ ~2 R$ `- }) j8 `
- dma_addr_t dmaphyssrc2 = 0;
" A' Q; Q7 H% P6 R, C7 n! ?% F - dma_addr_t dmaphysdest1 = 0;
' K6 c; T9 I- d4 g& ? - dma_addr_t dmaphysdest2 = 0;
! W0 P' H/ ?4 a+ }
1 b: j5 S3 v8 M- char *dmabufsrc1 = NULL;! ?9 t' f$ a% W) I4 P# r
- char *dmabufsrc2 = NULL;
8 R! V' n9 Y% C3 A( v4 z1 f - char *dmabufdest1 = NULL;
- Z6 B3 ?: k; R3 P# z2 z( E0 l - char *dmabufdest2 = NULL;
8 N* M$ S1 ?; d, [, I" z0 d3 o - 5 A0 H$ M. @$ }3 x! y( T
- static int acnt = 512;
6 b7 A$ h4 Q0 O2 R7 Z: ^+ ]# t - static int bcnt = 8;
! a7 E- U3 O+ V - static int ccnt = 8;
/ Z# ? d. t. u' D6 @7 N: l+ ?
5 E/ ?3 ?1 @( }0 h$ @' `' ?- module_param(acnt, int, S_IRUGO);- Z* c4 {' t1 w0 R; L
- module_param(bcnt, int, S_IRUGO);
7 }. z l6 _2 V' j - module_param(ccnt, int, S_IRUGO);
复制代码 0 U6 _; |6 H0 T- J" J* X. @
, b# X& k# u; n% _: r2 g6 p! R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 B. o+ S; h: N. Z& s v" c5 o7 C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 K1 Y$ j5 @! I% [8 y, Z' O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) O Q: [+ K6 T4 W2 ?
6 U! a: o& f3 k% F6 @: T; J
3 g3 \ F7 o6 e$ [ |
|