|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + }( u; D$ Z) L8 J
- [code]EDMA sample test application
8 J/ _7 d$ K) r$ s - /*7 k; b. C- ~& p6 E% X A- J
- * edma_test.c$ Q9 k& D& Q" Y6 E- ?3 P
- *) ?9 T1 I5 [" s! a! [7 s( g1 [
- * brief EDMA3 Test Application/ Q7 w! d5 _. m) E
- *' q2 f3 g2 Z/ ` T
- * This file contains EDMA3 Test code.
9 V3 G# ~4 o# ?1 l7 P - *
, ?6 _ G" b) K4 q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 z+ v9 m" x& k" Q' P- o - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 I* P+ U" K6 ~, H5 s M
- * TO CHANGE.
" [: N" D3 `0 H; U1 Z - *
9 F) q7 S7 {$ u$ }+ [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
\9 ]8 h5 b# r e4 S0 w - ** ?* q: P/ d' j1 T
- * This program is free software; you can redistribute it and/or1 N1 D" R( f. ?( v% E% }6 H
- * modify it under the terms of the GNU General Public License as' p6 Y# B. B0 F" a* C- G q. h
- * published by the Free Software Foundation version 2.
- R7 @8 _$ e0 e0 { - *, \5 E3 F/ l& a6 c: D) P) l
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 o1 o' u$ D5 W
- * kind, whether express or implied; without even the implied warranty$ B, V$ {% \; W3 }
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) K* b( j: o! n' y. F% n9 j - * GNU General Public License for more details.
* R" I4 |( {- Z7 ^ - */
5 c# Q" q% d7 |/ o$ D - 5 v2 [8 S. [) h$ m
- #include <linux/module.h>
+ e# g2 i& X I; y: X - #include <linux/init.h>4 v2 H# N# n$ ]
- #include <linux/errno.h>* y7 F6 r) h! j% t& m
- #include <linux/types.h>
6 [ r6 i; P+ V - #include <linux/interrupt.h># l t& N6 c' w
- #include <asm/io.h>
1 |: ^3 _* i3 H! x - #include <linux/moduleparam.h>4 ?- [" g `& I
- #include <linux/sysctl.h>& k7 c4 N& e0 a; u
- #include <linux/mm.h>
3 ~7 s- n. Q. q8 } - #include <linux/dma-mapping.h>6 L9 ]6 x' A: s& t
4 m# X! W j5 f0 H- #include <mach/memory.h>
* k/ U2 X* O/ a- V - #include <mach/hardware.h>! y% ^/ `; Q; z+ A" J! j3 U5 q
- #include <mach/irqs.h>
, w L; ^" u) K- q" V6 A$ |: N' G# v* ~ - #include <asm/hardware/edma.h>
0 a7 s6 L4 {. h4 U+ n; ^: q
8 L! C! }0 I$ S- r6 | \- #undef EDMA3_DEBUG
" L+ B: V7 w$ `0 `- ]# G+ e4 h9 o; W - /*#define EDMA3_DEBUG*/# [7 d' ~- z ]
8 l5 ]& ?# L L( P- #ifdef EDMA3_DEBUG
: y1 r9 ^7 ^: L; U4 v - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 F" m& ?+ p* W4 D) N0 t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 B7 q y! F0 C4 |$ V - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). b9 c% J( R; ]! K
- #else8 b- k) Z! s* g% g
- #define DMA_PRINTK( x... )1 b" Q7 `+ g% p; u' { L
- #define DMA_FN_IN
% \7 r$ l- X- B, R1 l* K - #define DMA_FN_OUT
k2 }- Y; h- S- [+ n/ I; H- I - #endif
, @5 E0 V0 l" S - 8 i' q' y6 F* w4 `# t
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 [' Q6 }( e0 X: G9 P
- #define STATIC_SHIFT 3' m! ~$ n* K, U, @. W7 x
- #define TCINTEN_SHIFT 20& k* C4 Z4 S$ E5 K/ ?" K. r
- #define ITCINTEN_SHIFT 21
) v9 U0 A/ B7 ?% P7 ]0 a - #define TCCHEN_SHIFT 22
4 @; I4 S) w+ _7 T6 c% i - #define ITCCHEN_SHIFT 23' U( C* H6 n3 x/ L
- 6 d. e5 y4 e) ?
- static volatile int irqraised1 = 0;
, A$ Y: Q% x9 c - static volatile int irqraised2 = 0;
* K' q# d/ P5 ^6 s
, A, l% _# B- e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ ?. j2 I. p. O8 L0 b% u, s4 ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; d% m& e5 q; D! T - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ q- u( K' E" `* H- C" u" C6 [/ N - 6 D P% H C4 V
- dma_addr_t dmaphyssrc1 = 0;+ L8 j' W( D& K3 Z
- dma_addr_t dmaphyssrc2 = 0;
$ \0 Z7 B' [" w: o8 Z - dma_addr_t dmaphysdest1 = 0;
# l- l# d0 L$ U - dma_addr_t dmaphysdest2 = 0;; n6 a9 \2 }* u, H+ Z# z
- : V, I! z; ^; y' I2 h& W
- char *dmabufsrc1 = NULL;
' \8 L3 J; b" W( o - char *dmabufsrc2 = NULL;
+ W5 J4 b! A$ w% m k# s* l - char *dmabufdest1 = NULL;( \) b5 W* r5 v5 y
- char *dmabufdest2 = NULL;: F$ S9 v- s4 t$ S
+ e% l8 m' [5 J# T$ @" \! o- static int acnt = 512;
1 \5 Y/ q" l* I# L6 ~& ^! E1 O - static int bcnt = 8;. `' H9 A; O6 ~6 ^% n
- static int ccnt = 8;
( y- v# A- j- m: S$ _ - 6 \9 | }; a, K g) j
- module_param(acnt, int, S_IRUGO);
O* r/ w9 i9 f# k - module_param(bcnt, int, S_IRUGO);
7 e$ w6 d3 D7 c1 H/ x - module_param(ccnt, int, S_IRUGO);
复制代码 / H" S0 u. }4 {. G
/ G1 F5 Y, l* Q; m 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: k" ~+ |- W* I- darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# J8 ] L& @# g& r) |) ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" q/ T n: F- k5 t" e
4 `0 c3 Z F8 G& V* u' H& b# g
, U. V( U! R- j) M |
|