|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 h, w/ L% o; \' `5 x- [code]EDMA sample test application. Q) V6 D# U B4 V) @& d. D3 ?; Y
- /*
3 ]- o1 p6 C" m: |; c9 ~3 M4 S6 B - * edma_test.c
6 b' p; F1 }% k$ t - *
# _- N) A& k& I* z$ d! Q/ m - * brief EDMA3 Test Application
- u O- C6 C4 w- t! s - *
& ^' W8 s. w: [# J/ w - * This file contains EDMA3 Test code.1 y8 f. ?* M% [. t3 `& ~
- *
4 [( ?6 u% P3 T5 W6 A% h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 ?+ m3 i5 O( S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT d9 F$ Y; e- [5 @" ]7 _* W$ @
- * TO CHANGE.
" r) ~1 t. [* A) R* P- `6 t - *
4 }' v# j. n" j. Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ M" O* l1 }8 n1 z, `1 o
- *
" _$ @: Q. ~3 D4 m& i, w ?% j - * This program is free software; you can redistribute it and/or
3 ~6 o2 m* d0 o1 J1 H$ Q; z - * modify it under the terms of the GNU General Public License as h6 u* o3 ~& I
- * published by the Free Software Foundation version 2.! b; K5 l2 Y. S. {( I1 g
- *
5 S: R- }" s! \+ s, O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( c" N, J7 ^2 L; j* Z j. T& O z - * kind, whether express or implied; without even the implied warranty Z) p( [4 k$ g) q U h
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" n4 S) ` M Y7 Q9 \7 r - * GNU General Public License for more details.9 T3 D9 H* U/ e7 I2 }
- */
/ K/ ?! x" d' S. f! j - # [" U9 {0 E4 N; w
- #include <linux/module.h>
( N" H" u# B) g) t: B - #include <linux/init.h>
0 ]; X( T2 D4 G/ N- ~# q L - #include <linux/errno.h>
0 W3 g" t1 G! f - #include <linux/types.h>
0 L& D7 ]3 ~1 }5 J' k5 ~ - #include <linux/interrupt.h>
0 G7 M' u6 z/ n8 E - #include <asm/io.h>! Q& V3 C2 [; i) z5 l; l
- #include <linux/moduleparam.h>( y0 }8 m) _: p9 L3 c5 Z. @
- #include <linux/sysctl.h>: r1 ]+ \- r9 r0 m0 {6 V
- #include <linux/mm.h>) W+ m) ?: I. G6 D+ I
- #include <linux/dma-mapping.h>* b! k( l3 i. T" [* U% ^- x
- }8 z5 z1 \- Z- #include <mach/memory.h> ]$ d! l" i+ l( {8 L) U% a4 p7 T8 D
- #include <mach/hardware.h>3 p# ]2 c% \8 {: V$ x# S' }
- #include <mach/irqs.h>/ d- f" o0 q# s5 ]5 g4 y8 Y/ g2 u
- #include <asm/hardware/edma.h>
6 K, S2 F% d1 H5 h
& f e: W% B$ ]# c+ r4 c0 i' u- #undef EDMA3_DEBUG3 c; T: g- p5 V$ @1 Y+ P r2 F0 @
- /*#define EDMA3_DEBUG*/, @" p. B( `/ v& G+ ?% N
- 0 i( @) p4 O/ N8 q
- #ifdef EDMA3_DEBUG% i% |- p6 T* G }4 o0 Y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. n5 r- }: h3 F1 g# i" x - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( k5 [* S% C5 b2 h* c$ I6 U: `/ A* Y. |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- y p' c5 H) v: F7 |! z, }
- #else
@$ P* A7 u# X' _ - #define DMA_PRINTK( x... )
- y9 }" w, Z. b- Z. C7 H - #define DMA_FN_IN4 z% u* r; r$ a/ M8 f, E
- #define DMA_FN_OUT% q' v8 X* j1 c! y6 ^
- #endif+ R4 A# {- ?8 {' b0 _+ e2 o
- 6 a9 ]! K) O$ L5 n4 N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 h0 b* u6 K2 `" V - #define STATIC_SHIFT 3; v! T1 Q* G: g- }4 I
- #define TCINTEN_SHIFT 20
5 T' c6 a9 ?! f% q" @ - #define ITCINTEN_SHIFT 21
( k# G( \; H' I4 v$ |1 H3 ` - #define TCCHEN_SHIFT 22
. C& x* b5 Q5 u- Y - #define ITCCHEN_SHIFT 23
$ B6 d9 X! g( ^1 _( E9 @: K - 6 y# I3 d5 z& N9 o. q( S& f: J( I
- static volatile int irqraised1 = 0;0 A. ~9 Y& w: c, S
- static volatile int irqraised2 = 0;
5 h* [6 x4 f7 @* t: }0 w - 8 Q6 e# H+ Z) O9 N# P J4 Q# M; v- C
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" L9 z u; `$ z2 s% n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 B- N3 w$ ] h; Z: X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" q# j0 a# O" J. Q! m2 k9 l5 B
1 H1 ^( a! y R# `) ~- M3 ^' Q- dma_addr_t dmaphyssrc1 = 0;
F, U0 M( H! m! A - dma_addr_t dmaphyssrc2 = 0;
* A: {' q# B1 V% M( s - dma_addr_t dmaphysdest1 = 0;* c& l6 x9 Q. D" h/ F i* Y
- dma_addr_t dmaphysdest2 = 0;8 N0 p$ V5 H% |' A, s
- I. {: L i$ ]& E9 _) V- char *dmabufsrc1 = NULL;
9 x4 K' [9 M2 w9 T9 O* P0 G - char *dmabufsrc2 = NULL;
' c* T4 j' d8 `2 S, b/ w' r - char *dmabufdest1 = NULL;3 x. N7 s ?1 `% |; N, @2 P, {
- char *dmabufdest2 = NULL;6 c/ M& g7 J1 r4 e C7 {9 ~; Q
/ |! p6 M; o5 W$ O9 v, \) H3 x. R- static int acnt = 512;
- T5 L% D+ ]7 K( E% ~; T f3 c0 k - static int bcnt = 8;
( m D a0 a9 d/ d' q0 `! p& z. v - static int ccnt = 8;& O, _- E; Z( p% d- ~ [* K
- # ^) q+ \! H1 ?: F: ?
- module_param(acnt, int, S_IRUGO);' H4 |/ w( l2 A: e7 k$ [
- module_param(bcnt, int, S_IRUGO);* u9 n/ [$ [' q6 e) c
- module_param(ccnt, int, S_IRUGO);
复制代码
2 r" l( d; r8 Q" h/ e' {% r& f y6 `8 `9 o# V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 J" }6 g4 {) B; ?" K, k- Aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. @. D' o& ?# U% ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% V! r. D$ h6 g+ N `
$ o7 |- F& Q% v" i
3 t0 t6 [' b+ D. w7 ` |
|