|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 l2 X3 I$ ]. Z; ]: N! ^. `3 B- [code]EDMA sample test application
$ M7 L& I+ ^* W. F, Z - /*
; ^: Q5 F6 f/ E0 a2 C - * edma_test.c) P: G( R0 t& T3 N# Q3 r
- *" R+ Z) G( f) G4 L/ ?8 T
- * brief EDMA3 Test Application( c$ F% x) r1 n; A, G2 n6 r
- *
+ I' O$ K( J* T3 e% u8 X - * This file contains EDMA3 Test code.
1 m0 d- _( R: H - *
" S7 Z" C2 }% {, K; @, C6 E - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- Y8 C. c: }2 ?& |
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, T! ?- T& z1 o5 _3 A: {1 b* k
- * TO CHANGE.
2 r; o- r$ J2 b& y& D. N - *4 V) n* v- j6 k! ~- @
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
@7 f' `! f+ C* K1 t1 h) X7 q$ j2 r - *
& r# L6 I$ v6 A - * This program is free software; you can redistribute it and/or
1 s7 P4 [" w- O' Y: o2 @6 G" T - * modify it under the terms of the GNU General Public License as
9 m4 v$ k8 Y7 V0 d - * published by the Free Software Foundation version 2.- _; s5 r& y$ P# B* z$ A! c' a
- *9 j9 ^+ N$ D# r
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% m! [. o4 T8 @& t( x. W+ \ - * kind, whether express or implied; without even the implied warranty
2 K5 F0 h* I# h& N% [ U" f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 b9 f: m: t4 k) A - * GNU General Public License for more details.
$ S6 w+ z+ w% Q" L. ]9 d$ c - */. z$ p1 }# E7 s: s# h& U/ L2 v
- ! n8 g+ M: Z# L
- #include <linux/module.h>- [ y% r- P. o9 a- h% H; T
- #include <linux/init.h>
4 i; h" I; u) e& E8 h: p' F9 Q - #include <linux/errno.h>
$ R) ^/ y, |7 p3 A3 z' v& J. V) H+ z - #include <linux/types.h>
3 j/ t+ M+ C+ G7 F8 L( ?) a - #include <linux/interrupt.h>
, @* V; e0 k) K! L- Q9 N+ R9 n2 W ^ - #include <asm/io.h>, s0 m. L- T% j) t
- #include <linux/moduleparam.h>
/ X F) s1 q2 h; s- T% ?2 v - #include <linux/sysctl.h>
4 {8 ?1 m2 |" d! i" ~ - #include <linux/mm.h>* D& O/ O U: q* Y1 _$ Z
- #include <linux/dma-mapping.h>
# ~" {- n4 s0 a' z/ g
& w7 Q4 H4 @6 B8 C4 |& h# ]+ n- #include <mach/memory.h>9 Y1 y9 e# V" F% D
- #include <mach/hardware.h>' p4 W" E4 G+ Y: o, S/ e: X
- #include <mach/irqs.h>. R6 G2 Y8 t* o8 e% T, w
- #include <asm/hardware/edma.h>" y5 ]; I) S" y9 h, ]$ V
# }- H9 C7 ^2 }; Q4 }- #undef EDMA3_DEBUG6 d" f7 g6 g: \
- /*#define EDMA3_DEBUG*/4 V2 D v+ Y1 F" I+ p. u1 T
2 {: B6 R0 u% n1 R- H3 ]- #ifdef EDMA3_DEBUG6 G2 i: [9 t9 |2 i' Z* q/ L
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( e: x+ ]0 j n1 P! r4 Y% P( H- n - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) F! j* p; E& s; i( i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). `" c9 H1 Q7 L% p# O" z: u+ P
- #else
) h, u7 Y8 n" z- _3 i/ E3 ]7 A - #define DMA_PRINTK( x... )
/ ^0 W. B2 x. G. g( u - #define DMA_FN_IN
! \( Q. F. B3 c7 e% r+ q - #define DMA_FN_OUT
?' d* g! | u - #endif+ x1 E/ O) m& g
) S9 H- I: W Q+ @0 g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- k8 ^9 W+ R7 V( u b3 J - #define STATIC_SHIFT 3& ?3 T$ c2 H! y U- N
- #define TCINTEN_SHIFT 20; K$ r0 k; ?6 a
- #define ITCINTEN_SHIFT 21
; c% X' ~5 o/ K8 w, l - #define TCCHEN_SHIFT 22
- Z. p" D" G! c! S% m - #define ITCCHEN_SHIFT 23 z; I9 u& X! H- V
- 0 x2 a Q4 I! ? |2 C
- static volatile int irqraised1 = 0;
5 _# X8 Q1 ?* H! r! M9 E - static volatile int irqraised2 = 0;9 ~* f; d% q$ |: L
n- Z w2 P W7 u: k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. u0 t) e+ W& b+ Y/ x3 Q2 {2 S* x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 k; L; ]9 _* M5 `, x9 J - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( q6 V/ J {) J7 u+ Z! X: P
) o: _: ?! ^) B) _& U# k: _9 ^ W- dma_addr_t dmaphyssrc1 = 0;
1 l7 E9 h- J0 d; o) X- D - dma_addr_t dmaphyssrc2 = 0;3 f% J% Z" H5 v9 s
- dma_addr_t dmaphysdest1 = 0;
- _* H: @8 O8 r9 @, M - dma_addr_t dmaphysdest2 = 0;3 E: X5 C& c! u
; v- X. \# t: B* p, v$ n$ d& k3 m- char *dmabufsrc1 = NULL;
1 E' }6 F0 E" G8 f9 n - char *dmabufsrc2 = NULL;( N" s7 z/ [5 m, f, Z2 D
- char *dmabufdest1 = NULL;
) ^ W- @$ s0 K* v7 Z1 g - char *dmabufdest2 = NULL; Q# C1 R( T. {) O7 V/ y# O# o
& b* _; r: i2 I {- static int acnt = 512;
* ~# [* V- Y0 @& p1 g9 x. o - static int bcnt = 8;) y' w7 F; Z7 u3 f
- static int ccnt = 8;4 ?1 s% y1 O8 J2 T
* }& C1 ~* a7 y* m) ~+ ?- module_param(acnt, int, S_IRUGO);
* Y( |% [5 Z; e1 I% d - module_param(bcnt, int, S_IRUGO);+ w! J7 T% n; J, X2 t
- module_param(ccnt, int, S_IRUGO);
复制代码 ! k; ^2 m: }7 v
8 d, E. x m) `9 N) t7 f. A g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ {, u$ D$ |9 ?4 v* H# v
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. w) Z: V4 T( | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 ?% m1 E$ ]+ b% `" w* ^* @6 e+ X
8 R/ h5 E& A, @+ k2 c
f* N/ N1 R0 V; X) g/ {1 x! C' U2 h
|
|