|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 W# T) o# G) p7 i7 x& a/ X; B- [code]EDMA sample test application
" d: m: `. n6 G2 G' w - /*
u3 `9 K; C: m8 \ - * edma_test.c
' S; F ]4 `' L, I - *. w/ R; i6 l$ P
- * brief EDMA3 Test Application
% U3 B( K( J0 X, E7 l) a& i2 S0 D - *) n6 _4 a g+ w2 h y
- * This file contains EDMA3 Test code., s: O$ T8 B0 n6 R
- *5 L0 _- y4 w' [6 q* W1 J: d, m; d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ S5 M% I# K! ?& m: @ V# m" t
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ k! u6 v6 D8 t" x2 P
- * TO CHANGE.
% m# F1 n$ u0 c' T/ p; P - *; Y5 z& G8 ~8 m- ^* y' ~5 n( a% }
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 J6 W0 W3 O- G9 W: s- F - *0 Z7 P. S: G6 K+ t7 b
- * This program is free software; you can redistribute it and/or
( Y2 g& |, `5 K - * modify it under the terms of the GNU General Public License as
2 @! ?; m; j [3 ~ - * published by the Free Software Foundation version 2.. F5 L0 o. V. f, z8 z: ?
- *7 {; `0 f" @/ `5 z% Z" R& G; `. `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 B3 [# C: r, F5 H- x5 o9 r
- * kind, whether express or implied; without even the implied warranty
+ d1 u0 ^, l3 g. @ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 o( y* ?) w: t( S( K3 s: N7 \, ^ - * GNU General Public License for more details.
6 |: r) `7 K8 b3 Z - */
* f. I# o2 e% p& @- S
4 q* V) w, m. U6 V& `+ n- #include <linux/module.h>
+ A4 k7 j | F* A: c( f - #include <linux/init.h>
2 q+ {, M8 l% M7 ?. ~0 y - #include <linux/errno.h>. M: g8 g# N5 B! V& n# ]
- #include <linux/types.h>/ ]" g, X# k8 t0 d5 `& ]
- #include <linux/interrupt.h>3 G! ?% E6 H& ]* U3 @- y
- #include <asm/io.h>6 t8 ?9 D% n4 B. b2 i3 `6 N9 @$ \ M
- #include <linux/moduleparam.h>
! R8 G% U4 S; \ - #include <linux/sysctl.h>2 @2 e D/ M K4 F- B
- #include <linux/mm.h>
7 m) x0 [6 U" L' x0 G% z' Z; L - #include <linux/dma-mapping.h>. k+ V! y8 N& J* I; c% b
- : ?" J! F/ w" w! v
- #include <mach/memory.h>* M U2 {$ j5 A) ]* r
- #include <mach/hardware.h>) ~1 N1 {2 N7 H) B
- #include <mach/irqs.h>* H* K* k w/ [! k$ c( @% V
- #include <asm/hardware/edma.h>
; f8 M3 C6 X2 m4 A, L7 k3 _ v
8 Q; P c+ \6 Q- #undef EDMA3_DEBUG# g: ?8 S, y1 S3 i1 H; Z
- /*#define EDMA3_DEBUG*/: K: ~) G& l: Q$ X
- - m4 \( Z( H% z7 u
- #ifdef EDMA3_DEBUG
+ W8 R8 P! ]1 h8 a' [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( x0 e+ x; j9 D
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% x! ?& I Z e, q, g1 b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& Q2 p1 e+ h) T$ P+ v
- #else4 A3 b7 l- e" g {
- #define DMA_PRINTK( x... )
7 D8 P# I: G. {: @9 m4 C - #define DMA_FN_IN
% W$ b( g* F3 T" z: q - #define DMA_FN_OUT
' k/ q- z5 M+ ~, ]* U - #endif; Z- j" x" O( [8 m- Q6 p4 m' e1 ?
- ! f1 I& R% e( x6 N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% l1 r' [9 l8 A) [6 N! e/ f
- #define STATIC_SHIFT 3. z4 l. f, [* K& G
- #define TCINTEN_SHIFT 20. u6 w) b/ C* L2 H9 G
- #define ITCINTEN_SHIFT 21% d* C. Q( y# S N9 q5 {3 ~0 v
- #define TCCHEN_SHIFT 22' F3 N$ e0 |( ?2 Z* c5 i6 v
- #define ITCCHEN_SHIFT 23" ~/ Z8 b# G* C, L) K
- 0 N2 ~1 l$ q0 W
- static volatile int irqraised1 = 0;
( n3 |7 K( _0 V* I: n - static volatile int irqraised2 = 0;
2 |% H7 X: Q/ W: L0 J - 2 }8 A' X& ? H$ P; o2 k1 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' h; O* R- g1 Q$ ]% q/ `
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( Z9 ^* ^1 l( H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; e3 E9 \, H. F4 I' s
# L( L; y" K6 N- ^% Y- dma_addr_t dmaphyssrc1 = 0;0 q0 U; C# `" @9 p3 e+ @* Z$ e
- dma_addr_t dmaphyssrc2 = 0;3 O* g' O7 X6 w" q7 _
- dma_addr_t dmaphysdest1 = 0;
" d+ ^& t9 |+ I) y - dma_addr_t dmaphysdest2 = 0;1 r P7 l5 C' P& h0 u& \0 p
- 0 n& s, }9 ~0 w6 H
- char *dmabufsrc1 = NULL;
4 c- ^: y, _* S: G - char *dmabufsrc2 = NULL;
% K6 M: l2 R! ^2 e4 n8 B8 V - char *dmabufdest1 = NULL;
- Z, p$ G5 q7 W0 p1 ~- i - char *dmabufdest2 = NULL;7 T1 o9 E( c5 y+ X+ U
- $ D, i) z' }) X, U6 ~: Y
- static int acnt = 512;
1 q" v8 S% P) i2 |* e% @ _; t) M - static int bcnt = 8;8 m. e" s5 V3 l
- static int ccnt = 8;9 o$ k4 j+ i4 o0 h* Q! F9 [) F
4 w7 \4 f" S4 W3 M( D2 p8 z2 b/ L- module_param(acnt, int, S_IRUGO);
0 R/ Q, ~( Z4 Q d! p - module_param(bcnt, int, S_IRUGO);
0 N) n" y. C1 Y) h8 h m! [: a - module_param(ccnt, int, S_IRUGO);
复制代码 * d8 h6 ^6 {' P; f O" f
0 V5 X* s" E' ?7 n! @
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 k1 m4 E6 n: M) Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 v4 z3 l. x+ S. r
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* v! R. l. s0 r) o6 t5 V o# R S5 n( [6 [
5 r* v7 a1 H( M
2 X5 t% A+ Y; K0 r' f$ p. Y& R |
|