|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + r+ v+ c( t" K
- [code]EDMA sample test application
" Q1 F2 a/ [6 ~8 J: K5 v l- K - /*
) V% P P; X! R2 j6 I1 z1 S. J - * edma_test.c
8 t1 f. n( x9 ?$ w - *
6 J3 ~5 c# p+ \ - * brief EDMA3 Test Application
5 t! H/ e, i1 P2 K. _) f6 J! w - *: m$ [3 T" N. b2 |4 u" ]
- * This file contains EDMA3 Test code.
& o% J9 C$ P U( X" L7 r - *; g9 f+ d+ o) w' J
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( H) }. c& V6 ~9 a1 c7 W/ _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- e5 _$ E7 |, N" F$ E9 R6 q. ^ - * TO CHANGE.# ~0 L& \: g a V$ ~ O
- *
# M" A' L+ s; P4 s1 ^( f: N - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// N Q3 x8 n& C' T0 ?
- *
2 `6 V6 O/ D7 Q+ o: l - * This program is free software; you can redistribute it and/or G# D: Z( b9 q- a
- * modify it under the terms of the GNU General Public License as* F1 g* A0 m |5 e. T; l
- * published by the Free Software Foundation version 2.& N$ ]3 S- q- V5 }4 }
- *
! _9 Z: A8 m- e" P! j% c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 t- y+ t4 e' q# l. |
- * kind, whether express or implied; without even the implied warranty
8 H7 ]! P ~& Y2 }; i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% W6 f+ Q: T# c- R
- * GNU General Public License for more details.
2 p8 }$ c$ C* L C7 J* r0 e9 W - */
: l0 w, ^2 p y0 R$ t1 j- N - ( Q; f: }9 l5 W2 Q6 a/ n* {- `) F
- #include <linux/module.h>
8 ], ^( i4 Z, y - #include <linux/init.h>! H+ y, v) @: p1 f
- #include <linux/errno.h>5 q# s& e5 }, s) B
- #include <linux/types.h>" t8 T& }8 s$ U& H1 f
- #include <linux/interrupt.h>
, h$ T9 }8 c+ w+ M% q - #include <asm/io.h>' z- a3 R9 h* X8 ]( {+ _
- #include <linux/moduleparam.h> _. _4 r. q9 [: H/ y
- #include <linux/sysctl.h>
1 N6 l) S& M1 [) O3 [ - #include <linux/mm.h>
+ h) C& i+ c- O2 X' E j9 g. M - #include <linux/dma-mapping.h>& J- l, X0 o1 W! ^# o4 A; l
& S7 B- R% n$ }+ x- #include <mach/memory.h>
, H5 q3 i) H: D3 W( r1 Q& ?( N2 x+ e - #include <mach/hardware.h>
3 T# s4 I8 @3 f - #include <mach/irqs.h>
6 Q: M$ F1 @! ~* S) f% X" } - #include <asm/hardware/edma.h>* I$ B0 P8 Y0 _, Q2 L& c& ?# r
- ( n& c. v9 }( V) q8 \, B3 _0 d
- #undef EDMA3_DEBUG
K- I) H( ]4 ?$ `9 t4 Z - /*#define EDMA3_DEBUG*/
: m+ {6 [* I* L/ Z% ^- {3 T$ @1 b3 C
7 e0 N2 G. x: j P" e2 T- #ifdef EDMA3_DEBUG
, D& I5 g* \7 m" f) p3 z' p z# M - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ c. g0 L' q6 d$ Q. e% ` - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 x# C+ R/ F+ K# Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( v, W& h+ o5 k. L, R' A
- #else
+ |4 J1 h( C' a( |2 k7 _; B - #define DMA_PRINTK( x... ): b) I; X o. w. g. c7 _
- #define DMA_FN_IN6 u2 K# m2 H# ?' v2 ^3 T
- #define DMA_FN_OUT- m2 L8 Z% c" D# Y' b: f
- #endif4 V$ t) b' X# T& {& r( d
$ C! C6 e* q* z& V9 l0 r( B- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ s2 x# E7 Z8 Y* l* }0 L) w% _
- #define STATIC_SHIFT 3/ ~: q1 W8 F3 O4 r6 Q- a- `6 b, C0 d* x
- #define TCINTEN_SHIFT 20
+ n" F+ l8 k9 m7 a" i - #define ITCINTEN_SHIFT 21
+ ?' D/ T( u2 y. Q - #define TCCHEN_SHIFT 22' b# G8 G* i4 r. Q% g* ~/ Q
- #define ITCCHEN_SHIFT 23
- ]: X! @. q. z9 p4 G) s9 f/ X
+ h" S3 k! J$ \- U: [) Q' Q4 m- static volatile int irqraised1 = 0;
6 K) l/ k; H4 Z9 n" q" Q6 v - static volatile int irqraised2 = 0;; J* a- ?" r" _% [
2 K( q0 F# Z# ~5 Q, ]- J7 c$ N- D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; B9 Z( H- e5 m9 A0 Y8 }
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. n4 q2 e8 q0 O7 y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& o. }& x" e6 A( R8 k6 m
- 1 X: ~9 l) s0 z# | `& ]* p
- dma_addr_t dmaphyssrc1 = 0;
: w* v; I7 U' o6 }$ q$ f( L/ l( F v - dma_addr_t dmaphyssrc2 = 0;
/ ~$ Y4 Y- I$ I& q# Z - dma_addr_t dmaphysdest1 = 0; x# x1 g1 k- M$ {) o* N4 ?/ n/ X
- dma_addr_t dmaphysdest2 = 0;
1 I+ s# R3 T5 c& G - `* I* q1 _3 X K2 g
- char *dmabufsrc1 = NULL;
; ?' m. R0 X) X& U6 r6 {2 O" } - char *dmabufsrc2 = NULL;
- I4 ]8 p4 w* g5 \, { - char *dmabufdest1 = NULL;6 n0 b& @6 M+ `# t9 V
- char *dmabufdest2 = NULL;: P; f9 u! {+ ~2 F" i( u% C
- p$ y0 H+ s# l) v4 ]
- static int acnt = 512;
# r* t9 d& c- M4 ^/ G1 c - static int bcnt = 8;) l5 C. z: b6 r& M2 l2 B( `
- static int ccnt = 8;
P/ a+ U' |' ?7 i3 J' X - 5 } P1 P/ L3 v3 a, M7 y
- module_param(acnt, int, S_IRUGO);
8 ]/ c5 u2 y& f& Q - module_param(bcnt, int, S_IRUGO);) Z" z7 M) v: \ s" r
- module_param(ccnt, int, S_IRUGO);
复制代码 ) [0 h( V& W3 S( A) a
; @$ d3 D; ^+ y; N: K' ~
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 n1 g8 A3 {6 r$ u* a" Y# o6 ^
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 c+ B9 [ y8 y/ {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. S) w9 r6 m1 Z5 L' }( x% p) W/ T" L# Y+ z7 k! H( I& G
) G( V/ p1 h2 ]' o, Y4 j0 C V |
|