|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 q5 R8 E) l4 G/ i. p; ^/ o
- [code]EDMA sample test application
/ s: ^2 t# W* d - /*
i$ @ Z( X; ? - * edma_test.c
/ g2 K0 a( E( w# w0 m - *8 L6 k+ a! E1 Y o$ D# N
- * brief EDMA3 Test Application
8 o* S3 p w, A; [ - *
" [0 I: [2 `/ N. K, e" Z - * This file contains EDMA3 Test code.
T" H- w# y4 V4 K - *( V' f6 g) |, }) M9 l
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) ~. R1 Z6 J0 r, ]4 G
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* n3 A; s* `% M3 B
- * TO CHANGE.
5 }" p0 u# }' S W/ G6 _$ V$ E - *
. }5 G! c$ z: n' e( y# i- y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 E5 e& l: X+ s, r2 X) l - *6 G) h5 n' w# W) m4 V4 }' i
- * This program is free software; you can redistribute it and/or
( I* J2 D Y/ h - * modify it under the terms of the GNU General Public License as
: H. I v% i# e1 P5 N( B: A1 G - * published by the Free Software Foundation version 2.
- J* e1 {5 i8 |7 R3 z) \ - *8 i( S- |& U, o; E1 M
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ j" P2 }6 ?+ h9 }; H
- * kind, whether express or implied; without even the implied warranty
: N4 B0 G0 V- a" Y+ U - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" ]- {$ o" G j: j - * GNU General Public License for more details.1 O( `# g# y/ b/ ]0 F
- */
$ N3 ~& O7 t$ q+ P, V4 E+ f - 7 U' E% g( n" }: ^
- #include <linux/module.h>, p" Y( F j0 Y9 d; g
- #include <linux/init.h>! O7 K! L' j7 T# l' q0 P( e
- #include <linux/errno.h>
7 ^; W& @, c/ I; Z0 u9 f - #include <linux/types.h>2 h# {- D: T% b# M7 e
- #include <linux/interrupt.h>" p" Y/ z: m5 }2 ~$ k" B0 g
- #include <asm/io.h>% _0 n) i/ n0 K' n7 J3 S
- #include <linux/moduleparam.h>
v- o" n5 D: c( J8 @' I - #include <linux/sysctl.h>7 T9 _5 h2 N# i( F. p
- #include <linux/mm.h>/ s y( ]9 H. @% S9 R
- #include <linux/dma-mapping.h>7 `$ T9 Q1 i9 O8 z' h$ _: r5 V7 D
. }3 t( q) c; k9 o5 y- #include <mach/memory.h>
6 O- ?# S3 t. ?% k* g, X% r7 y& w - #include <mach/hardware.h>
) g: |. O& a0 H/ W4 U - #include <mach/irqs.h>$ n( j$ _! [2 M" p. G% I7 Z: ~" x
- #include <asm/hardware/edma.h># y0 y' @+ @+ L5 ~1 y
" ?. u. y, K- I& J# G. e6 D- #undef EDMA3_DEBUG
% s# p9 P( n( C8 v0 k - /*#define EDMA3_DEBUG*/ }# i. G2 m- ~. E7 R% Y X& G
- ! C9 ?% S8 ?* x' X
- #ifdef EDMA3_DEBUG
% o! [2 T5 O4 Z$ g) v k+ n9 A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ L- t/ J' Y2 ], g, { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
V: ?) d, q# n; N5 `, w8 f6 n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): W/ O! n& n ~: D) D# `9 }+ e
- #else
2 @- y1 z9 a/ w: d - #define DMA_PRINTK( x... )
4 Q" F0 M& m/ h$ _/ y - #define DMA_FN_IN
5 ~9 w! Z3 @0 w& Y - #define DMA_FN_OUT# p9 F9 L! K# [1 O& L! P7 L
- #endif
0 m$ {+ v! P) K8 T# _$ @
4 Y8 J# K# X5 g" f |# D- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! L' S/ D* R2 ^) o/ B
- #define STATIC_SHIFT 3
$ _; a9 ^6 q: H - #define TCINTEN_SHIFT 20+ `) Q/ o* P2 W, S8 o% N
- #define ITCINTEN_SHIFT 212 X% x8 q. P( @
- #define TCCHEN_SHIFT 22
4 P0 ^' o' k t% }# Q - #define ITCCHEN_SHIFT 23
& }$ @& p. O3 |
5 n/ r: a8 d& k$ o0 ^- static volatile int irqraised1 = 0;
. e* Z8 g" B$ ~7 f5 V% C. ?3 J - static volatile int irqraised2 = 0;
$ w7 i& j. M- O% V( T
" R, r) A: a8 H& p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; E. U% [8 t0 c; P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" Y- U' ]6 C0 T
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" |) k% ?3 n! z6 C" P( ^/ H
! E7 b- _4 B3 @( l5 t! ]' c- dma_addr_t dmaphyssrc1 = 0;6 S$ Q* L5 ?/ t1 i9 G
- dma_addr_t dmaphyssrc2 = 0;8 P* {( g3 s2 |1 h7 U
- dma_addr_t dmaphysdest1 = 0;8 W5 Y" I8 H9 d- W" P# K3 R/ d6 S
- dma_addr_t dmaphysdest2 = 0;9 z% Z& \8 O2 ?( F3 c K
- % L3 ~" `3 S! U, I- l5 z
- char *dmabufsrc1 = NULL;
& ]& ]& R) H6 {9 `# P) u# M - char *dmabufsrc2 = NULL;
' R6 U6 x( o: k - char *dmabufdest1 = NULL;
1 A7 x ^+ G) p: ` - char *dmabufdest2 = NULL;
: |* F+ g: t0 P/ E - ; l9 s: O3 _' E8 q0 m- H
- static int acnt = 512;
4 G U; B. z% I; A' h' q - static int bcnt = 8;% e; b4 L) D+ ^2 m6 O
- static int ccnt = 8;
- Q/ y8 y) a4 k) @2 V - : R; c- l* }9 q6 u( P
- module_param(acnt, int, S_IRUGO);
, s5 I; r6 F p - module_param(bcnt, int, S_IRUGO);
) s, _3 e" J4 z( Y2 M" L - module_param(ccnt, int, S_IRUGO);
复制代码 ( E0 \& Q. w$ ~' [
7 J2 Z7 W1 n3 }+ x$ e* v 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 W. e8 o9 s# O7 L& a. t% Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" S( B4 f- V k3 d, S
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 }% n" ?, u; y- {4 @/ O: V [! P" i# y! U& Z$ a" x8 D
4 L' m2 E9 C8 G+ h! _/ C9 u |
|