|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : ]* q$ ~2 H9 ^% a* Q+ e# z7 `8 s' Y
- [code]EDMA sample test application
& @2 e) c& e6 y2 U. C7 g% N - /*
( s* o' t; d$ M# h0 W F( V2 E - * edma_test.c1 `7 v: i$ [3 O. C% y u
- *
& }+ p4 i2 k. R, d* k. W - * brief EDMA3 Test Application( d6 y8 N( r2 D5 F; [. C
- *
, m: m9 u$ L# p# r - * This file contains EDMA3 Test code.
$ o; G0 S8 R5 N. z5 J/ ^ - *; ^. ]2 I+ Y& V- A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; \# l1 g T4 d7 u& Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# X4 v- u% Y) n: U2 r F
- * TO CHANGE.2 w5 X5 f0 n+ P: m% _
- *
. |% S% Y e' Q; r. o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: f* J q+ f( S* C - *
, o0 l$ q( i( j6 d( u - * This program is free software; you can redistribute it and/or! F8 | d! R7 V! q+ F
- * modify it under the terms of the GNU General Public License as
% P. @& f, W+ o4 r* v+ ^- D" e+ C - * published by the Free Software Foundation version 2.
+ k& A9 O9 F# P% t# X/ o - *
+ D" O) `4 S3 W/ u# Z4 b/ j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! L) F% x4 |7 v# w
- * kind, whether express or implied; without even the implied warranty( t9 P3 S$ Q$ Z' \* q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ K6 X0 `& R+ }! O
- * GNU General Public License for more details. _/ |; y" `3 B+ Y
- */
7 r2 S- v! R) f& O - 1 v: X- @$ V+ @3 G. x2 g! |4 Y+ g% e
- #include <linux/module.h>
2 `; W! V7 _& L1 O! A - #include <linux/init.h>- W. _9 N$ y5 o* M- f6 J
- #include <linux/errno.h>3 ~$ x5 N6 J7 y( M
- #include <linux/types.h>
2 ]( n# C) i' ^' S( Z' E - #include <linux/interrupt.h>
: p% G- A0 Z1 D0 m5 C+ F - #include <asm/io.h>
4 U( Y# B. H: r6 @9 c - #include <linux/moduleparam.h>
3 y% V- L/ w2 `) y+ @' r6 G - #include <linux/sysctl.h>; O: k3 x, }4 s; K
- #include <linux/mm.h>/ b3 @; R6 V& w0 k+ i8 R. H
- #include <linux/dma-mapping.h>
, [% b5 P9 c; d \
/ N! s8 ]! m' |- #include <mach/memory.h>
( J* q ]$ H% K" V - #include <mach/hardware.h>, b7 @: G3 o. A& P% e* o
- #include <mach/irqs.h>. P1 C$ l- [, A& G7 w" t% [ X
- #include <asm/hardware/edma.h>1 K5 f6 ] I e* q8 E: R
6 e ? o, B8 u- #undef EDMA3_DEBUG
- l- O' D: A7 A2 r4 W' J+ u% f - /*#define EDMA3_DEBUG*/
2 E! [7 R% [% r" V7 u y - * }) J% K" m$ V+ g8 @( ^2 T1 u
- #ifdef EDMA3_DEBUG5 Z7 X ]) R) u- Q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 Y; E! ^! s, H( M/ k- {: w6 o
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) U; i3 G0 I) c7 ^) J
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% ]6 c4 M; i7 e [4 F - #else" n' o" |9 m* z- w) f/ M* `
- #define DMA_PRINTK( x... )% C* P8 m0 M/ K0 ]6 C: O
- #define DMA_FN_IN2 F1 }/ W8 v# i. a B# B) _' J
- #define DMA_FN_OUT$ J6 g7 f$ v1 N) J
- #endif5 U8 d1 a$ B: n/ s4 t
- 9 D9 d) {, {& l5 Q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& x& _* V0 U6 R) m# I' w - #define STATIC_SHIFT 39 H. H* e' D' [8 R: ?
- #define TCINTEN_SHIFT 20 D, f' V) X7 o- `9 i: [' Y
- #define ITCINTEN_SHIFT 21
. K) S% M- w- i) ~. [ - #define TCCHEN_SHIFT 22
_! A, i# d; B* s1 ]! }1 G - #define ITCCHEN_SHIFT 23
9 K f x& ?- J/ @5 G% L
* B* p& b" |. ]" [( N* _- static volatile int irqraised1 = 0;
4 S4 f- d% i4 F# z2 Y5 J - static volatile int irqraised2 = 0;
& M/ i0 _9 R% p& ~4 t
% n: E$ r( _( X% Z8 G5 q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: @ W0 y* ?4 }) i: o - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ v( t0 T9 I, G2 X/ U' ~ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( L$ }8 w% u* _# V4 W3 D
- 3 i! G- Y9 F3 J4 f2 B, ~
- dma_addr_t dmaphyssrc1 = 0;
: @ M! v) T0 F0 t* W2 o B - dma_addr_t dmaphyssrc2 = 0;
5 C* C- C) r" ^% O- C7 | - dma_addr_t dmaphysdest1 = 0;
9 q% A; y) {9 P* J' Q6 H& t - dma_addr_t dmaphysdest2 = 0;! p* z4 a L: t8 Y, b( t% l, \
- : k% v3 { h# Y8 x% n
- char *dmabufsrc1 = NULL; n. O6 P ] L! z
- char *dmabufsrc2 = NULL;# R# d' g2 A3 [- m
- char *dmabufdest1 = NULL;
4 l& _2 }. X$ B$ d, O - char *dmabufdest2 = NULL;6 o _( X; S+ @0 W" b
8 H) b7 t6 J1 f: h+ L- static int acnt = 512;
& g: B( {# H4 k - static int bcnt = 8;
Z- J' K/ ~2 O$ \! w2 f" ~8 s: @) H - static int ccnt = 8;3 a4 P+ I, s# ?+ j3 b% w" y
- : \) Z* @6 o9 i9 {& L# H: l
- module_param(acnt, int, S_IRUGO);4 e# M C$ W. S: h! o7 J9 w
- module_param(bcnt, int, S_IRUGO);
; g$ a. p4 d; O% D3 g \0 K9 N - module_param(ccnt, int, S_IRUGO);
复制代码
6 i! N0 ?' q3 Z0 p. ^0 l4 G$ N) D1 G7 O0 d$ ?' a$ Y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ `9 w$ m" ?2 X+ Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! i1 u7 @% p5 ~. Q2 Q. F8 x- R) B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 y* m, z( }1 h* F+ K$ n$ |
4 {" \/ X% H% H l5 M
/ W4 n* Y; a4 [; A( w |
|