|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . e/ b( [6 J u8 c: @4 F
- [code]EDMA sample test application
3 J/ f( `3 c+ K9 g2 k/ e+ M - /** _- K6 }2 A5 [
- * edma_test.c; d" n1 T: C, w( b$ I# J
- *
5 h) K9 T5 @% {: f, L# q1 f - * brief EDMA3 Test Application
6 {2 D5 u/ U, ^6 C! H7 C - *
. g# N" F( t: O; K& T - * This file contains EDMA3 Test code.
* P1 a. A3 q/ e6 I! e' {3 J - *+ L* ]$ W d& Z3 G% H+ l
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: K) K5 B. U/ v3 b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
b! A9 U F: Z! k# q - * TO CHANGE.
: V" P- M5 J. Z" f |( s - *9 A6 o7 A. @+ ]2 b- Q# c. `' f5 L
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 u7 n4 v; P# V t& j
- *
H2 Y) Q. v$ N( R5 P8 O. o8 P3 } - * This program is free software; you can redistribute it and/or9 p* m) \0 R: R6 f& H
- * modify it under the terms of the GNU General Public License as8 S8 g8 G% m1 p' b$ u6 Z6 _* t/ i
- * published by the Free Software Foundation version 2.
6 E T |; v' s2 o8 r9 r: B7 b$ x* j - *
H5 [% c) X; r0 `+ }2 T - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 H. P- r8 E' S( J& B" ?4 l
- * kind, whether express or implied; without even the implied warranty
" O; @& q, ]5 r/ {) m7 a6 p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, s0 j7 _" x6 H' H/ k, P3 | `
- * GNU General Public License for more details.9 r+ B$ D0 k. |5 T3 u$ M5 r6 v
- */
6 E# g: z) { o0 s
7 z/ `6 W2 `, n8 N& g4 ?3 |7 b- #include <linux/module.h>2 _2 t' w! [. L Q1 A U$ p; [
- #include <linux/init.h>$ H c4 a0 v5 O* ~! A$ K- B+ O
- #include <linux/errno.h>, c0 \* n) o/ e) ?( I% l) A" q* A
- #include <linux/types.h>
/ B2 z5 \+ p# K9 V7 T - #include <linux/interrupt.h>
7 \# N d5 H% v0 Y - #include <asm/io.h>+ |' H# K. {' O
- #include <linux/moduleparam.h>
4 H# I; l8 U! Z; @9 {0 L8 B; R6 p) F5 l - #include <linux/sysctl.h>
/ Y' |. S9 h6 P8 [3 S0 x9 U* _ - #include <linux/mm.h>- `0 p, N1 _/ q2 j
- #include <linux/dma-mapping.h>' ?$ p8 x. t4 L6 Z
* Q, N) T' e- [, _3 b- #include <mach/memory.h>6 I3 D/ Q7 ]" @! _
- #include <mach/hardware.h>2 H/ R" b3 ~: n" J" w% j5 m% _
- #include <mach/irqs.h>) \% X6 f( L; t# _) D% J0 M$ E
- #include <asm/hardware/edma.h>- j+ G" s& X4 f2 Q
- ; e" ~* z* W, T- I# D ?' o8 h
- #undef EDMA3_DEBUG( D4 G W" {7 C7 s6 W
- /*#define EDMA3_DEBUG*/* `* Z. X2 w& g* s' \9 i! F6 C
- 6 d7 X( w2 e8 u+ {2 Q3 O
- #ifdef EDMA3_DEBUG
* y- F' E& ?2 Y. ?( M( w( y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) w" \" `! L) b ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 h6 Y4 n6 }/ j9 j5 Y+ A- Y8 }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ C2 B3 n! y) ?) x5 H& N1 l+ J
- #else+ w; a5 {/ u& ]: V" P4 d6 `& G: Q( p
- #define DMA_PRINTK( x... )
: {0 P( V* {5 l; w - #define DMA_FN_IN
& f k y& K) Z# m& f' S u - #define DMA_FN_OUT. z& ^0 T! o" R U1 X! u! w6 L
- #endif
0 N& U8 u s( W1 F) Z/ [
+ r9 z3 Y. X0 Z- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ X2 p' ~* h: n# p) w
- #define STATIC_SHIFT 3
5 ] h2 ^7 ]8 d2 Q% x( P$ y) G - #define TCINTEN_SHIFT 20
, S8 v1 N$ v0 {3 g0 R - #define ITCINTEN_SHIFT 21+ ^! l t& a% J
- #define TCCHEN_SHIFT 22
, j' c. S/ V+ K# ^ - #define ITCCHEN_SHIFT 23/ ]9 F" ?) F2 y$ r; S1 h- l+ y- c( P2 N
- / Y6 N7 L; I/ o1 {6 J% J) g
- static volatile int irqraised1 = 0;
) e2 w) E7 k% q( Z) P" i* h - static volatile int irqraised2 = 0;+ K# t% P6 p" C# E4 T
- ; T7 d2 a H% ^# r! X# b8 V3 P
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 s4 D' U& r3 m
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 y, `9 J r, V5 _ R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& @0 g: s# J. g* T
0 D# A G# H' p3 f! B& R5 b% G- dma_addr_t dmaphyssrc1 = 0;
. O6 x7 U- r6 M; a3 _& V - dma_addr_t dmaphyssrc2 = 0;
& |- H) m2 H. L) u: U+ T( u L, ] - dma_addr_t dmaphysdest1 = 0;7 v0 m& |# T1 l
- dma_addr_t dmaphysdest2 = 0;9 j' k2 E( W: F4 {+ ?6 \
- % \" E# y' s" S# _
- char *dmabufsrc1 = NULL;" e7 ^0 }/ X8 K- Q! ]. |% {! @: i" L. b
- char *dmabufsrc2 = NULL;2 G/ p; i6 I/ ], f" E3 `# J5 J V9 g
- char *dmabufdest1 = NULL;
^- d1 [. c1 y$ @; A% a0 a - char *dmabufdest2 = NULL; ?3 y( F6 ^+ t) Y8 E( d
- # @& y) h/ v! z# h4 w9 W5 F
- static int acnt = 512;% m" l Q* s" p
- static int bcnt = 8;- U" M5 d( ~( |5 ~' i8 Q6 y6 B4 L
- static int ccnt = 8;! ^- M! x/ f- ?& P( d) W# `. e
% J, [0 ?1 I- K+ U+ w- module_param(acnt, int, S_IRUGO);8 j8 y; E% ~! S7 d! f
- module_param(bcnt, int, S_IRUGO);+ f9 n2 l. _1 @
- module_param(ccnt, int, S_IRUGO);
复制代码
% ?; k2 s3 H, N+ [ _3 l7 f1 E/ l' B5 w" }- r7 ]/ r
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ N. w" @ e2 Z2 |3 [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 s/ K3 o8 L+ O
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 M7 W, f/ I% ~( a# @; O
_3 s$ X z" K5 C8 c
1 `/ M/ v6 A8 q }) V$ a( |3 p |
|