|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , i+ R' x" z; ^% k1 W% }. O
- [code]EDMA sample test application
S9 e0 n2 a* q6 i: B - /*/ a& u/ G( S9 Q5 _8 p" X2 p, [2 P
- * edma_test.c
1 {3 }7 \2 @6 k$ C1 @. X - *
: d4 D/ p' [3 r# O$ i! d - * brief EDMA3 Test Application. i5 D3 ?7 x& O& x
- *
, C* [$ l: n; ?- K. W# k$ w5 ^ - * This file contains EDMA3 Test code.: k9 Q l9 {- ~0 H0 t* N1 q
- * q: L }" T6 D7 j9 e2 h" B; w" q* p
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 n9 P# S3 C; {8 ] Q. V r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" ?: J* Q! ~6 e8 C - * TO CHANGE.
5 h! R) O2 f2 w - *" n& q/ k2 _5 O+ C
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! R( f- k# a$ q0 y9 Y# ~ - *
, ]% j$ ^9 k" Q6 _3 J - * This program is free software; you can redistribute it and/or
* s3 B9 U9 X1 M: T2 c6 h3 Y' g - * modify it under the terms of the GNU General Public License as% v# A6 m: ^9 m \0 z
- * published by the Free Software Foundation version 2.
' ^3 q0 t7 Q0 @* b/ K$ }) o* [! i& _: C - *
3 {7 O4 N3 h/ z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- f2 v0 L5 i( Z; s1 b/ v - * kind, whether express or implied; without even the implied warranty% Y, E# d* T2 T8 V; ^, c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' y* l8 Q# ]6 j* C% f+ W5 C S
- * GNU General Public License for more details.' l K' J6 O$ D+ B
- */
# G# v2 G3 U3 e& | - 3 J/ M" N/ ]% M2 h
- #include <linux/module.h>5 s/ o2 b$ `5 ]
- #include <linux/init.h>8 m ~' G2 }6 M* |. t1 @5 R7 F
- #include <linux/errno.h>1 |0 t4 i6 u& w0 W' U5 z
- #include <linux/types.h>
- C% ], [+ Z( L8 r" Z - #include <linux/interrupt.h>0 a" n- g ?5 M) W& b0 p0 |
- #include <asm/io.h>
; S& D6 u3 Y& R8 \* S - #include <linux/moduleparam.h>
! u" `4 Z4 @ t7 j1 @0 l - #include <linux/sysctl.h>
: M; g3 J# e( |: r4 ? - #include <linux/mm.h># J/ N5 x, y5 o3 V/ c8 V) l+ @
- #include <linux/dma-mapping.h>/ L: _+ m# \3 q- h
3 ~; d. t6 q ?: H* e" S9 q: F- #include <mach/memory.h>
- ~- I f# t. d8 \" U - #include <mach/hardware.h>
: r2 ]7 p) u9 t2 ~( Z U9 J/ \7 h - #include <mach/irqs.h>
. k e( e8 O7 f) ]7 p r6 e( f - #include <asm/hardware/edma.h>1 l8 M2 n4 U4 X$ |( T
' E, i6 V. G9 B. c- #undef EDMA3_DEBUG1 Q- m4 D `( a7 \3 ~# [
- /*#define EDMA3_DEBUG*/
) H" y+ w* a8 ?2 C - . |9 P, V5 V9 B8 m
- #ifdef EDMA3_DEBUG
/ U S3 z5 A$ c) r; s) E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 O- |2 W1 ?7 W l( o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" x) p i8 ?& {( D2 [" p4 U; J. f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 @* j( K7 e2 T" ^7 S% } - #else
+ _* @$ F! p$ E4 B6 B! F+ { - #define DMA_PRINTK( x... )4 G0 V0 k4 G1 u9 `& V
- #define DMA_FN_IN
- D8 ~1 E0 k7 e) _: s. V - #define DMA_FN_OUT
" h' X' x+ Q8 P/ w6 ?2 b- U# S" t- x - #endif, _/ h+ h9 q/ d& }6 I; {
- * O/ j& v4 x9 L3 O/ b7 T# ?+ W. O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768) Y+ H0 D+ W9 z8 K
- #define STATIC_SHIFT 3% m- \( z8 P% Q( g
- #define TCINTEN_SHIFT 20
) s& A& i3 {" i4 H - #define ITCINTEN_SHIFT 21
6 I6 \7 T8 U- e K. L n) F8 b5 @ - #define TCCHEN_SHIFT 222 m0 H* q2 ~3 c( g) ?, o
- #define ITCCHEN_SHIFT 23/ e5 n) ~; p* L' z
- / x# K- |8 d! Z# O# D1 o
- static volatile int irqraised1 = 0;! K1 G9 ~: n; w
- static volatile int irqraised2 = 0;2 j ~9 }2 u- g) M9 r
- 6 e& x& D5 Z* @( @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: c8 M! @- E1 v1 f5 K. Z; |
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; {0 t( U+ o- ^# S, _- ]& |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ y% ]6 ~7 f" Y2 M& _6 T
- 4 y2 d( J: B( R
- dma_addr_t dmaphyssrc1 = 0;
1 e4 X3 w& I3 V. l8 ] - dma_addr_t dmaphyssrc2 = 0;
% K. J: U+ F1 {0 n- P: H! c- t& E - dma_addr_t dmaphysdest1 = 0;
. A# w/ q, O0 f) w6 t - dma_addr_t dmaphysdest2 = 0;
; X% w& b: x/ }' V5 b% T+ u
7 R1 m: }, B% g% |$ |: C3 S2 k: P- char *dmabufsrc1 = NULL;1 D3 X1 E _8 k& B5 ^
- char *dmabufsrc2 = NULL;
" [# L- v/ @, Z: F - char *dmabufdest1 = NULL;
6 o1 W7 w7 r R9 P. z0 m" G - char *dmabufdest2 = NULL;( G' @; ]5 d5 {$ A8 ]: F
- 6 i, p0 k3 E3 `# F' t4 A1 o+ d- k6 v
- static int acnt = 512;3 s! y7 B7 @) J4 J! B8 _7 ?8 A
- static int bcnt = 8;1 M6 ~" l1 l) D
- static int ccnt = 8;" c1 t" I* w& J3 Y. p* ~8 ^
, _* G+ ^0 {) Q- module_param(acnt, int, S_IRUGO);
' z' \' Q$ M' w5 V5 V - module_param(bcnt, int, S_IRUGO);
$ q5 y5 m# o' b# g' p - module_param(ccnt, int, S_IRUGO);
复制代码
+ T: c; W6 g; Z5 g( ]) P! Y7 ^# H O
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' t% o" b$ ~ T/ y6 ^% ]; G, marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 |8 s1 g- V1 C" P3 A: Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ }& I. C6 X T1 l1 s* F
! b/ g; _5 J4 d5 ?5 x2 V5 |; l
9 k( o# O: l& Z6 H" p, t5 B |
|