|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 Y- R# `* x* t: _" o% I2 |- [code]EDMA sample test application
7 u& @7 P4 @" R - /*: L( v+ ]( o3 K6 X
- * edma_test.c
8 ]8 Y, O8 k i$ U( } - *: A. V1 b4 J" O7 n3 P$ P
- * brief EDMA3 Test Application5 s1 [) M+ T- c0 C' P2 ?8 y: j
- *
' G' y# c8 P& `1 j; ] - * This file contains EDMA3 Test code.
?- i* n3 }4 d: r$ ?$ Q8 Z - *
, D, \+ D) _+ w, _& F - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* W3 H' S4 j. k5 }5 B" g! @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- Q2 {2 _5 a; [9 Q - * TO CHANGE.
$ e7 N: R s y+ Z - *
( D. t7 R: p! ~7 L3 I: J/ Z$ J1 k& a- d - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
F+ ~$ T+ Y9 ~( n, G' d) ]9 q8 c% C5 f - *
; a8 U, o) d8 Y! g - * This program is free software; you can redistribute it and/or
7 K R" i" a2 d' M; s - * modify it under the terms of the GNU General Public License as/ Q5 A$ l4 c1 V. }' {
- * published by the Free Software Foundation version 2.1 e/ D# i& F# U0 E# Y! G
- *3 }. [' ]$ }2 n v* |
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* ^: |& p% s: K0 x( h
- * kind, whether express or implied; without even the implied warranty# K5 H4 i+ [4 }( r2 j% c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ D O+ Z/ i5 S: d0 { - * GNU General Public License for more details.
5 ^4 r5 C. [! ` - */4 J8 F# t! k8 M0 g: W$ D/ l) x: ~/ R
- 7 r" D# C" r+ L8 I, f- W% ~3 F
- #include <linux/module.h>- V0 H3 h& G- K$ K4 \0 s' U+ F
- #include <linux/init.h>- s* B9 t4 o, R6 }1 }
- #include <linux/errno.h>9 x& R5 {7 [* v: J* f- X! i0 N
- #include <linux/types.h>
+ W$ ]7 d, `6 Z$ w" e - #include <linux/interrupt.h> B1 A4 A9 h4 i, u- W- q$ a4 s
- #include <asm/io.h>
4 p4 _' _* a/ S4 R& T8 y/ @ - #include <linux/moduleparam.h>
8 A A! U7 p4 [0 H1 V8 r9 F - #include <linux/sysctl.h>- w( | C/ j' B+ e r J+ @
- #include <linux/mm.h>
/ x" X" V6 b# z1 {7 C! D - #include <linux/dma-mapping.h>
[& n! |9 b+ `
, }& |5 C7 s' u C, m' b- #include <mach/memory.h>9 g: ~+ g8 L' Z: V
- #include <mach/hardware.h>: u! D- e. w1 ^+ M
- #include <mach/irqs.h>
5 n. D) |- P8 w$ n3 s H - #include <asm/hardware/edma.h>
+ m' o# Q5 S) j& D! O/ K) [ - 6 l& r7 U" v/ c" k* `4 l3 g+ ^
- #undef EDMA3_DEBUG* q/ P5 }, V5 F* X" B/ p* V
- /*#define EDMA3_DEBUG*/
' x1 [/ N) A0 u$ R
8 I/ H. H$ n* n- #ifdef EDMA3_DEBUG7 v5 ^& a) d5 v( E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 z' V4 g( W; P8 z2 v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ d1 A+ r' J3 Y3 O+ U# A7 H8 U1 ?
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 D7 f% l: J7 z6 |( B$ A* {) S - #else
( N( S8 R9 k- S$ P - #define DMA_PRINTK( x... )
5 N0 R# Y; }- h. H% m; N( U - #define DMA_FN_IN
. r/ H8 d2 ?0 {% Y9 N/ x$ |. V% i/ J - #define DMA_FN_OUT
9 l9 Q+ A% Z6 D - #endif' z2 J2 p" O9 \* J. L; P
- g6 K0 N: v. q. n' s' f- #define MAX_DMA_TRANSFER_IN_BYTES (32768): [ n: y# [- F- `+ w
- #define STATIC_SHIFT 31 n$ R3 k. m5 O
- #define TCINTEN_SHIFT 20: @: d& t& y( l) m- f$ Q+ H% P
- #define ITCINTEN_SHIFT 21
- M: s m5 D9 P" S - #define TCCHEN_SHIFT 22
6 U1 p$ t: X4 I% {3 A - #define ITCCHEN_SHIFT 23
( y- a7 a5 O Q/ H$ c - . }- X: R5 [8 @) S8 d
- static volatile int irqraised1 = 0;
8 [9 t4 H# Z, Y. [! L - static volatile int irqraised2 = 0;4 I( k% R& u; @
3 k" C* [, ?+ A0 E/ o6 q1 {4 P/ X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 d6 n% r) y; w1 f/ @0 V" L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ R2 L7 d8 S2 U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); ?: N3 _* V1 _ j% R
2 C- m4 u+ R) X- a+ o- dma_addr_t dmaphyssrc1 = 0;( M* R. ]4 B0 V* U& ?+ x
- dma_addr_t dmaphyssrc2 = 0;
* g: S8 o) b9 B' b8 M4 N& r - dma_addr_t dmaphysdest1 = 0;
: W" s) l& i( q- c - dma_addr_t dmaphysdest2 = 0;( I: i! \1 z8 O9 W
- ; @9 B1 A# c' g6 {. H! J& S7 O
- char *dmabufsrc1 = NULL;
" f/ x! ~3 n9 m' K - char *dmabufsrc2 = NULL;( q( V' D: z! k$ k. R! z) h
- char *dmabufdest1 = NULL;
9 F: e" R: P. w# w, @# \, g% v - char *dmabufdest2 = NULL;% H9 y7 i/ Y; N- k3 Z- i
* J3 B. I \, R- u( b2 N2 {- static int acnt = 512;6 ], O. J* c& ~% F
- static int bcnt = 8;
5 ^7 N5 G9 o: S2 X7 ~3 j/ U% K# Y - static int ccnt = 8;
& c/ ~: u* g) B# z7 \( d- L! M
$ g% W/ T$ }: o# a1 C; _- module_param(acnt, int, S_IRUGO);
3 U/ Z# G8 w- N; D+ s - module_param(bcnt, int, S_IRUGO);
' v8 J$ ?' D: S1 W - module_param(ccnt, int, S_IRUGO);
复制代码
% Y8 J3 z g) U! i5 F' P/ q/ J6 R' S3 B0 @; g; v
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! X( v( q$ n2 r3 A3 C& W$ D4 jarm-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, R; p" i, U8 w- \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- |+ D7 G) G- f+ I `* `( Y- R3 I) y1 A2 q. J* N/ A- ^
! Q0 M! J* o2 Z$ V* |0 {7 {& `
|
|