|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / d( _8 w) p7 {
- [code]EDMA sample test application
3 v: s# j# o2 h E5 A4 b - /*& v9 K m. I0 M5 Q
- * edma_test.c
& j5 d) q9 E" ^ - *
7 l8 ?& e1 H# F3 N - * brief EDMA3 Test Application* e% i( n _1 k& P$ w; o: I
- *
! e* ?. Z) c n! c; X6 h7 R$ \ - * This file contains EDMA3 Test code.
. W# E/ L/ P6 i$ I- K2 W - *3 R, @* y8 Y g8 W3 [( A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 B8 O2 ~/ ^' t" H8 W% \* W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: r6 x. C. z2 Q
- * TO CHANGE.4 o" Q; Q& p i: }" c4 x4 j
- *
8 X! Q J9 v/ c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 e9 a* y, Q7 e6 f- L - *
2 `! l. J9 @' N - * This program is free software; you can redistribute it and/or
8 W# a t. V6 |7 F - * modify it under the terms of the GNU General Public License as
* C' b! j( J3 T - * published by the Free Software Foundation version 2.+ Y* K: S( }1 U$ q- C/ S5 P. P5 R
- *. N8 A, w8 [7 [# y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" f9 S4 n, S5 \: l+ y6 E2 j0 I - * kind, whether express or implied; without even the implied warranty, j, q5 R: ]/ Z' K( P5 A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) F# e4 o. _: } - * GNU General Public License for more details." X v% [7 L1 H& W% K; o- I
- */
. h6 [/ `/ B, @ - 2 G+ W0 X: l- j' w7 F3 p/ V* [4 u
- #include <linux/module.h>
6 X. v6 l$ w* T; K( a. W$ _8 k2 C - #include <linux/init.h>4 W+ Z# l3 D/ t# ]
- #include <linux/errno.h>
$ P+ E/ k+ [1 d - #include <linux/types.h>8 N6 m/ c$ ^/ ]0 A2 f5 Y
- #include <linux/interrupt.h>
7 T7 f7 c0 |9 y' t# ^& d9 Z1 ~ - #include <asm/io.h>
0 }, S0 [; ]' q. @6 l1 R. H$ O - #include <linux/moduleparam.h>
J/ u' B% J" [! Y" ^+ Q - #include <linux/sysctl.h>
# |! w6 Y) h4 ]9 f$ t4 r - #include <linux/mm.h>
; C3 m7 k1 b) q8 k* ^+ S4 b2 w - #include <linux/dma-mapping.h>, Y) u. b/ ]- s, S) u' z: M! Z
- # J; V, M* a' r3 Q7 k+ ]* p0 G: @
- #include <mach/memory.h>
/ G' {8 s$ o9 l - #include <mach/hardware.h>" k. s! d i8 l5 `* M
- #include <mach/irqs.h>1 g4 N, _5 I7 i1 U
- #include <asm/hardware/edma.h>
7 Y: D2 A& u1 L/ F) ~
9 Z, W% N; n Z2 k; h$ `- #undef EDMA3_DEBUG7 R' W/ M0 }; M
- /*#define EDMA3_DEBUG*// U/ B; U* _/ i/ V2 ?/ I
' S, X8 M8 Q; z. d% s0 G5 Y6 w- #ifdef EDMA3_DEBUG ?: R5 u1 k t' U$ \/ R
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. m8 G _7 B" Q! d% S. l - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) F- ~8 O+ d: H0 G% @/ r' w
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 i7 }# ?# l6 _
- #else0 x$ v9 M# h j
- #define DMA_PRINTK( x... )
, Q( ?1 Z: ^; E. f# Q6 @% [* S - #define DMA_FN_IN
" G4 q8 W+ N6 k - #define DMA_FN_OUT0 f1 L; |$ Y1 q& P/ T j- W( J) Z
- #endif' `* [+ k7 g+ m# L0 }+ {
, C& E' g! F5 y9 f- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! z& T W" }- N( u0 W: Z2 @ - #define STATIC_SHIFT 3
1 ^4 \" q1 x" w+ t - #define TCINTEN_SHIFT 20! m. H9 }- l. G7 x! ?- [
- #define ITCINTEN_SHIFT 21
( B- L. I$ Q" E - #define TCCHEN_SHIFT 22
- u5 c. D" x( Q; L* O - #define ITCCHEN_SHIFT 23
) q; z3 N0 {9 l" o% W/ R' }# ?
; k, r# |3 h: T9 T* Q1 \; |2 Y) o5 x- static volatile int irqraised1 = 0;
# p* R' J) G4 G' _) J. Z' l - static volatile int irqraised2 = 0;% `9 s* g* ?# _/ }
- ! c7 D$ i+ u" g
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 d0 t9 }% ~7 A& x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: l* w" j1 c% s, L0 R4 ^ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: w( \5 U9 k$ _2 L+ l - 1 w) t: T, q3 C* b
- dma_addr_t dmaphyssrc1 = 0;$ U) z# N3 `2 R
- dma_addr_t dmaphyssrc2 = 0;; h+ L& ~: ?( M$ e, F6 w
- dma_addr_t dmaphysdest1 = 0;
4 Y. ~: }8 L( W1 B - dma_addr_t dmaphysdest2 = 0;
7 I) B5 W, U8 \3 ` _1 a
K. w3 ?' o7 K( ?- char *dmabufsrc1 = NULL;' K$ h7 m i2 K% y3 J% l9 x) h3 I) H
- char *dmabufsrc2 = NULL;
- X/ B5 |2 i1 T- W6 ^' k - char *dmabufdest1 = NULL;& d. z4 K6 v6 u; r
- char *dmabufdest2 = NULL;
' D7 u. S1 K2 y
, I' R( L, v) ]8 V9 w% k# H% @/ i, S- static int acnt = 512;
0 `* D. o& d s" ]1 R( @' e# x; d$ l - static int bcnt = 8;
' P0 T" v3 N u6 g+ o! U7 h - static int ccnt = 8;# Z7 M2 U" W* t
5 W% B5 d; S O4 C- module_param(acnt, int, S_IRUGO);2 s' E: W2 f. T4 s* G
- module_param(bcnt, int, S_IRUGO);% n& U$ ^4 A4 ~
- module_param(ccnt, int, S_IRUGO);
复制代码
" o: R* P; i) r0 ]! G
( ~! I8 w7 e* M6 R! H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ X: J. f2 w. s3 _! v, s2 @* larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ d* d# x# d9 V8 G" z/ M! g2 U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" ] M2 K: u0 B8 s, X& t I9 z6 D0 G* ^0 j2 O( c, N
9 D& L3 K- O1 R! G o
|
|