|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 M- {3 c4 F; k4 a7 {
- [code]EDMA sample test application* _$ e* A+ n# o
- /*
& ]. L: d* F1 c" v. D& S - * edma_test.c: B; J( ^5 g+ V' @
- *
" x7 \! q0 ^ R1 {$ l/ ^ - * brief EDMA3 Test Application
, o9 K* i6 \! w# b" L5 G - *
( S' o- g2 B* r; \+ g# i6 x - * This file contains EDMA3 Test code.5 q" G6 B9 j# e" Q, F2 o( j
- *
6 F; x- D& A4 J( @# G l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" f$ T! i% n7 S, B0 d - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 b' i0 E0 U0 I; q' g
- * TO CHANGE.- j( d. x+ o. v
- *6 `9 T# |8 ?8 Q: B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- \; O/ R% P3 _% M - *$ _8 w4 o: Z) n( ]: Z% Q
- * This program is free software; you can redistribute it and/or4 v: j3 W3 F. O: {4 i' D
- * modify it under the terms of the GNU General Public License as
. A1 Z5 i+ U* n% L9 ^5 V1 l% V - * published by the Free Software Foundation version 2.! L* c2 J8 `6 u( Z* \7 y
- *
8 E: q+ i' x& A9 t3 V# l6 k) B6 ^# } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# T$ C$ w" H2 K+ j, Q) F. r5 { - * kind, whether express or implied; without even the implied warranty1 s: c4 J7 g" k( L# |0 J8 V! q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ o7 l" v! t+ C0 r; [2 O' u+ N3 V1 F7 c - * GNU General Public License for more details.
( s. F% x8 |6 r7 ?7 w4 ? - */
# v& U e9 t5 m. m: s9 P7 \. ] - 6 q" X p. T/ l4 I' d, ^' C8 A+ B; L% p
- #include <linux/module.h>/ s/ W' r+ h. A& k; @
- #include <linux/init.h>& i+ x6 N7 R' Q; S8 `. ]
- #include <linux/errno.h>
. W8 R/ e6 Y. F, y2 Y - #include <linux/types.h>
1 i: o2 n: Z9 g* M - #include <linux/interrupt.h>8 k6 e% R, d: D( b
- #include <asm/io.h>
* ~ k# v f* r3 b - #include <linux/moduleparam.h>
% z( X1 j6 \; k& ~6 }1 Y2 ^- e) } - #include <linux/sysctl.h>. @( g! d0 W% b" k7 g1 ?
- #include <linux/mm.h>
2 y! Q* I o4 ]% U3 t - #include <linux/dma-mapping.h>
. t: E3 t7 w- u0 @
$ u# Y1 ^; _8 X6 K- #include <mach/memory.h>
6 g- P1 Z6 |( J1 U# G - #include <mach/hardware.h>7 o( V' K6 ^8 b/ J( l9 o
- #include <mach/irqs.h>( `" J& P: j B3 H/ Z
- #include <asm/hardware/edma.h>
( U7 f$ J: I5 U# _0 ]' M
4 Z/ k* R- b! v0 y; `- #undef EDMA3_DEBUG
9 A( m4 t2 G; S0 Y6 f$ s - /*#define EDMA3_DEBUG*/9 Q9 L& u$ Y# R9 x c1 \
, [! m. ?% W5 o- #ifdef EDMA3_DEBUG# N0 F8 h9 M9 y7 E* }
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* Q) d6 p9 A1 u - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! u5 u; L* I" h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* G* g' B. R7 I3 @; {! D - #else( m& ~: A/ ^6 a
- #define DMA_PRINTK( x... )
8 v+ ~6 g' F7 \9 V% V0 w% u3 j1 r4 s - #define DMA_FN_IN! f8 @9 [1 i P0 d3 F
- #define DMA_FN_OUT. _2 y/ d8 s6 c3 k8 D
- #endif& F6 J/ n% z4 w
- 4 C8 g2 f9 ^* x" W; U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ |, ~( f. \; ` - #define STATIC_SHIFT 3: E- [. T# g& m1 j& ]1 w: F
- #define TCINTEN_SHIFT 209 G6 w) Z5 I/ ~, |
- #define ITCINTEN_SHIFT 21- W1 T' x4 R8 m% V/ ^9 ^
- #define TCCHEN_SHIFT 22
- _0 Q& Q# D7 d R - #define ITCCHEN_SHIFT 23) m4 G/ a, x" ?
) M8 l5 `% g' U7 R* }% _4 v- static volatile int irqraised1 = 0;
+ }; j+ z/ r8 A# F, `9 f0 p. g - static volatile int irqraised2 = 0;2 O$ J) f2 }+ Z( U
- B9 L; {; t8 P7 ~6 H' r7 l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ a. ]/ ?1 k3 Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 d5 v" G. x' c* q8 P) y& j - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ U* c& X% G; d - 8 p3 A: O& M/ v% E( b
- dma_addr_t dmaphyssrc1 = 0;
! h( Z! H& [/ Q$ l5 v1 \& D - dma_addr_t dmaphyssrc2 = 0;
6 n: ` @6 |2 E8 C( i - dma_addr_t dmaphysdest1 = 0;
' g0 K1 ?& Q; t4 v8 i - dma_addr_t dmaphysdest2 = 0;
1 c% w& g: R& v% W& N- T# E8 [& F) ]
2 {: d6 R2 ~8 o( L$ M- char *dmabufsrc1 = NULL;. b2 j+ w6 _* F0 z3 y
- char *dmabufsrc2 = NULL;6 h. j3 c! w; ?6 i6 H
- char *dmabufdest1 = NULL;
6 k/ E* H* ^' g) o/ h; ? - char *dmabufdest2 = NULL;7 e: |: l: k, m% ~
9 D, u3 c" x! Q3 [- static int acnt = 512;
$ i1 | K ?. q - static int bcnt = 8;' l+ J8 o4 Q9 R+ X" }5 ?
- static int ccnt = 8;! f* N+ O6 B* U; ]7 Z8 w+ c! V
# A; z2 Q4 B' l" F3 [( e) U- module_param(acnt, int, S_IRUGO);' s- ^9 k" |7 H1 V8 U
- module_param(bcnt, int, S_IRUGO);4 W/ Y! r7 Y7 N
- module_param(ccnt, int, S_IRUGO);
复制代码 8 n5 Z$ T M$ o7 R. v
6 @3 x" q. z2 [1 x1 b' B" D5 Y1 P
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, w8 r# ?2 O: d. _
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& b6 E" ~% k: |) ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) c* y: {# s6 }$ m' L
) r' ]. a" u7 R. J0 F
: }. B* A5 l+ l0 g) @" U Z |
|