|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ L% l5 L% V- z O# Z- [code]EDMA sample test application! I7 M3 p0 c% {
- /*. y. w6 \9 B4 N
- * edma_test.c5 R$ n- s& {5 T
- *: Q! F1 y+ S/ l: v3 C8 C( ` Y; i
- * brief EDMA3 Test Application
' G( j7 s9 W& c7 Y O$ Y - *
+ m! i7 F3 E4 h# X/ w+ N4 `% s [ - * This file contains EDMA3 Test code.& v, k# q" K: D r
- *
( l2 v3 | J1 h3 U - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' j, n" ~* x. d; P3 i: A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# P' _* N0 n7 \. }! B - * TO CHANGE.
0 V9 N% E+ T5 H' S& V - *
s% D! u m6 S, R9 b0 h0 x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 K! w. m' a7 f, l# g0 c# X) q$ x
- *
) h1 I! Y9 n! ~. n - * This program is free software; you can redistribute it and/or
& M9 ?; {- s9 E6 V - * modify it under the terms of the GNU General Public License as
( U" E _0 T& R - * published by the Free Software Foundation version 2., s; f3 o1 j. ?0 H _' R
- *
/ e$ h# ]* @1 d$ N/ j) U- } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 r2 J7 m# X- U. j$ q9 [ - * kind, whether express or implied; without even the implied warranty
6 k+ M" \% _/ J% i9 t2 k, w& O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. j* c0 p; Z. K! h0 f5 Z - * GNU General Public License for more details.
/ i& e% @% P$ X8 i$ H, i5 s - */1 d6 [' u' ^' R; H
- / Z, k, m( H2 X* `
- #include <linux/module.h>4 o( g8 y% P: S: b1 N# r; K/ B
- #include <linux/init.h>
0 J$ Y& g% H. {% G5 B2 x1 B q- a( ] - #include <linux/errno.h>
6 S! p6 E8 e! V( c5 {" l. P - #include <linux/types.h>
5 O/ j7 Q5 Q* ` - #include <linux/interrupt.h>& [% Y5 Y- u+ ~- Y
- #include <asm/io.h>' B2 v0 @+ P* y0 x2 e0 J
- #include <linux/moduleparam.h>0 G) u7 A8 x4 g8 w6 S
- #include <linux/sysctl.h>
_. R. h7 ]! c* n/ \' d: @5 e - #include <linux/mm.h>) Y1 U: H: X5 o" }$ N* k
- #include <linux/dma-mapping.h>; A+ p5 y4 f, i! E) y% c
- 2 i0 w0 @- E; d+ l' e
- #include <mach/memory.h>* F7 f) e/ b% E" ?- u# Y' p
- #include <mach/hardware.h>
5 a4 D# y$ ]9 Y& @ - #include <mach/irqs.h>
9 z" I" n6 _# M - #include <asm/hardware/edma.h>
; Y2 K, W1 A% \5 d; ^* J) a$ b - 9 Q6 E( p& W: {/ `2 m: S0 ~
- #undef EDMA3_DEBUG. K9 w( ?/ O1 z- }3 V
- /*#define EDMA3_DEBUG*/. ?3 [; V9 j9 b
# Q; e# ]/ X9 J2 |# t9 X" I' |- #ifdef EDMA3_DEBUG
4 T6 C$ A: P0 t+ t/ B9 @1 E - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, |! J( F) @, c6 e - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, B: S% ?$ e' q" d" b' `' L6 U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" ^- U+ S( |5 W, _# c% x+ Y - #else
8 ^% _4 a5 |! J- R8 m - #define DMA_PRINTK( x... )
3 \5 g7 a& ?+ Z; z& E1 k! y - #define DMA_FN_IN
; H" H/ B, l0 R$ G4 |6 w# ?2 c - #define DMA_FN_OUT
: e6 y) P* o3 q2 L3 l! K: c - #endif9 Z# ~5 u. a/ w( ~
R& W5 y; y# T& Y6 W! |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- L- ~6 n. Z4 q2 ]/ N - #define STATIC_SHIFT 3
" R9 i- U* `: e - #define TCINTEN_SHIFT 20; H+ y4 M& y8 s z+ t
- #define ITCINTEN_SHIFT 21
* q6 ?( n+ L3 B" e E, l" N- x - #define TCCHEN_SHIFT 22
" r! [ f5 E2 [ | F - #define ITCCHEN_SHIFT 23
3 I) p% X1 G) F2 e1 ?
' N& f* S/ N- v( m4 d- static volatile int irqraised1 = 0;" g& e2 z3 t: ~) U3 Y/ ~5 j [- i
- static volatile int irqraised2 = 0;
4 ?! g( D3 c, [, s$ k8 D - 0 O/ ?$ H% `* m: s' G2 p9 G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. s. m- }" N# g, o: ?8 g( C( q# k9 ?
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 ^' J+ n, \/ A4 f
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; Z0 g" [' V7 Q0 G' s0 d) Y
- 9 l8 b7 C# b6 J# N+ v7 f
- dma_addr_t dmaphyssrc1 = 0;5 U. { p- X# r" N
- dma_addr_t dmaphyssrc2 = 0;
p: o3 i2 d* f - dma_addr_t dmaphysdest1 = 0;
" s3 V$ ^# A+ L/ i - dma_addr_t dmaphysdest2 = 0;# R# m- |( ?/ `- d& u
- + O' U s" A+ ]1 c# _
- char *dmabufsrc1 = NULL;4 x q, w) P, y: t
- char *dmabufsrc2 = NULL;# K1 y) j+ D6 k7 {) V1 e& W
- char *dmabufdest1 = NULL;9 R. d% R( |! x. \$ t
- char *dmabufdest2 = NULL;$ i8 P. t2 |7 J N$ Y
( F0 e0 L& j# d g g( @2 k- static int acnt = 512;. B7 |& U! p7 n# Y: G
- static int bcnt = 8;. _, W. `# N! j* b/ D0 N1 b; [8 U
- static int ccnt = 8;
# M$ ?4 c; f' n. Z0 F: j- f - & x* C5 B# y7 b: D
- module_param(acnt, int, S_IRUGO);
3 X) w6 ?( p9 n" G H% z( r% d - module_param(bcnt, int, S_IRUGO);: M; j+ c$ V7 W: \ B8 ~7 g: y' W
- module_param(ccnt, int, S_IRUGO);
复制代码 ( O$ C6 c5 ^; y5 e/ A' ^. ^- m
$ S$ m3 }. p& Q, K# O+ n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 z8 }6 }4 d% Y3 ]
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 G# V1 c% J0 c! c z" O7 U( X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ U* t1 [5 S& F2 z- \. [
" [' w$ u" d: h1 M4 E2 F
* L8 l5 m( w$ Y! F8 X8 `1 a |
|