|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * j. J, O. S7 i+ E$ w; y
- [code]EDMA sample test application
/ k; g5 o2 }; D" o1 z - /*5 m5 T- S: D5 Q3 d
- * edma_test.c
0 Z! V! ?2 M; e; C+ `1 v0 o - *
8 [6 j; t# q1 G' Z) l - * brief EDMA3 Test Application1 O& o5 A/ o2 I6 V
- *
* A4 K4 _" \" v) S; l% ~8 [5 D - * This file contains EDMA3 Test code.
4 U1 h$ q- a9 C C - *& ~$ R' b/ o( x) Z, P0 P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 g0 Q K4 D2 x0 R) h8 O9 t5 v$ m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ h" T1 }- P7 ?$ f& `$ j2 m - * TO CHANGE.8 S7 R; S" c, ]5 l
- *
$ }9 N/ I2 E; b/ |9 D - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ [8 {$ @8 a0 Y, P& ~# `6 l2 N# C
- *
6 o0 D! a/ u; ^9 w) q - * This program is free software; you can redistribute it and/or9 Q( \& Y; v5 N" [% d$ v
- * modify it under the terms of the GNU General Public License as
% f# D% z( N# x# y - * published by the Free Software Foundation version 2.
5 o8 r5 m) M; j; K - *
% I) k; F+ t, B! @' q- j m5 [) r - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& D1 G5 g% |4 q e) W" F
- * kind, whether express or implied; without even the implied warranty
1 D9 T1 m0 ~" i2 O: C - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 L5 V% p$ S1 r# ?, q
- * GNU General Public License for more details.6 |7 b8 e7 D9 T! g7 W
- */# l0 [8 q! b/ j. J5 @, k- j
: @0 H t; p) C7 [- #include <linux/module.h>
( G1 j3 O4 d6 ~1 G - #include <linux/init.h> c, G' d$ b" g0 S# a& y
- #include <linux/errno.h>
! Q- C0 H" k; B0 C1 r1 M Y - #include <linux/types.h>3 h$ n( r$ z( P: Y4 I
- #include <linux/interrupt.h>1 o! d) h3 x" W* }
- #include <asm/io.h>
. ?6 K" b; y7 { Y, h9 R - #include <linux/moduleparam.h>8 ^7 m# t( {% ]3 v) P+ L1 c9 k
- #include <linux/sysctl.h>
* ^" ]2 l2 F; M - #include <linux/mm.h>
" f6 }- V2 k% S4 R- c - #include <linux/dma-mapping.h>
, j O- n. ~1 T8 q0 X7 ?
( \/ r! {/ B- Z* @. J! u- #include <mach/memory.h>% z! [: z4 v! ?4 n4 T
- #include <mach/hardware.h>3 [% i- l7 Z" `6 \! V
- #include <mach/irqs.h>
) S+ c2 G; }* s k# K7 E - #include <asm/hardware/edma.h>) M8 F# V3 c" p" v0 K( b+ G
- $ l* e6 V: U. \% i4 i1 w9 n0 |- b
- #undef EDMA3_DEBUG, Q" M: D4 z3 R$ S" u8 q4 Y: x) A
- /*#define EDMA3_DEBUG*/) m: ^8 ^- a9 R$ k0 i; O* }# A
- 2 u3 }5 w5 D, P7 {7 i9 q
- #ifdef EDMA3_DEBUG, N' k+ ^/ h2 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 K# p) b6 b' _' m) y$ [ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* q T% M+ L5 `: t4 N - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) ? S# @' R* [% }) w {( }' x* z
- #else
6 D; F9 p6 i0 ^/ y) B - #define DMA_PRINTK( x... )0 K( U+ d! D: `/ k. ^: e; |
- #define DMA_FN_IN
: y, ^8 L* |2 t2 ~* l9 n* R - #define DMA_FN_OUT. l0 ?6 m+ B1 {5 ^0 L, Y5 t
- #endif
0 c+ r! p7 R( V$ v+ N
8 ?( U& v7 B F; B' m9 r8 o1 ?, J- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( S2 T' }9 p; x& H7 `: {; V( q
- #define STATIC_SHIFT 3
% k8 \; p# H) J. Q. d1 h - #define TCINTEN_SHIFT 203 a* r, _4 ~' Z( o- f. J% K
- #define ITCINTEN_SHIFT 21. Z- i( M/ x+ j3 `2 c3 }, }
- #define TCCHEN_SHIFT 22
- t. y8 R% z# x - #define ITCCHEN_SHIFT 239 b C" }" G, \! c7 z1 z: T, R
6 g' u' n7 k) m+ ^+ G a8 {- static volatile int irqraised1 = 0;
J9 S4 M2 P& ~( | - static volatile int irqraised2 = 0;! w/ L: j8 k0 {" X" b Z+ r
- , j0 k& A2 C$ T4 h# z" l0 q8 }/ V
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 y7 o2 i. z) z4 v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 H0 k+ q: ~5 f) ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 Y! X+ d5 @9 m& u' R& u, Q$ Q; k9 n3 G
0 z" D# h1 m- i- dma_addr_t dmaphyssrc1 = 0;
7 Y, j/ ~# W6 p S5 P - dma_addr_t dmaphyssrc2 = 0;
4 E! V8 k1 \2 R# f x, H& o. S - dma_addr_t dmaphysdest1 = 0;6 Q2 f) _8 R9 I+ X9 n9 x: ^
- dma_addr_t dmaphysdest2 = 0;
! G$ C+ o/ A& h! y
: |! M2 d& g0 K1 ]- char *dmabufsrc1 = NULL;) c& ]# @( x& B/ `; u$ E! p
- char *dmabufsrc2 = NULL;
- m* ?0 R# H9 e - char *dmabufdest1 = NULL; B. v! C4 Z: \- y
- char *dmabufdest2 = NULL;# `% Z' V( L4 @1 o2 \# y
- - E3 n3 W$ g2 P& {8 }. K4 I
- static int acnt = 512;
1 S, C: e( h0 x; j4 V# x - static int bcnt = 8;" M8 ~9 f' W) L9 F# l; F- b" x" |
- static int ccnt = 8;' f0 _1 u! u6 O9 U' Z
2 O# i% b6 C3 [' m, N& g: c- module_param(acnt, int, S_IRUGO);8 H. ?3 s5 f/ v/ \5 a
- module_param(bcnt, int, S_IRUGO);! d6 ~9 r& Z4 x1 x; s
- module_param(ccnt, int, S_IRUGO);
复制代码
- |; C& N" G0 L
; h; U) m, k& w7 d/ ` 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) ^/ [9 x8 C, H- e" ^$ Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 z' \9 H$ S0 @2 m L/ X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 F# h6 @, h8 g' }: F* Z
1 I2 ]. v, ?1 ]: O( @
) @) p- N5 D7 L7 ~% n% D, P |
|