|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 _8 _' x& j* n: z) f- [code]EDMA sample test application2 T' h9 ?' D" l s0 K
- /*
( J1 t& Y$ \ o1 a( `: V - * edma_test.c
! E4 t8 d, ~( p4 j% @( s - *
) m& Y$ k% R% _+ o% P+ {1 ?; b) a V - * brief EDMA3 Test Application: u, q0 B+ s: U, c
- *0 o0 Q, W& T8 }& U B/ c" V
- * This file contains EDMA3 Test code.
$ d9 O0 g& r* G& X1 V - *: s2 _ \3 J) h; C+ j. m: G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 p# C6 ~; U) H. R, e9 \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
3 n" R( k2 n2 K3 J$ W - * TO CHANGE.* a' R, _) z( T5 u" S4 [3 T
- *4 `! X" a" @9 x- _" m/ o
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 o# h6 u8 R7 J4 q - *
5 s$ P. u' v2 E, q$ m6 x - * This program is free software; you can redistribute it and/or
; b7 k3 ~# q3 F, f( l - * modify it under the terms of the GNU General Public License as
+ W6 p6 s- Z) c4 N% i# f - * published by the Free Software Foundation version 2.
/ c* @: \: j ~8 i+ _( ?9 L9 I - *
* M. t+ S' T) C. Z. F( b( L) G' } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 ]+ [4 s8 I6 @9 m/ {
- * kind, whether express or implied; without even the implied warranty/ n! l3 p- T0 |$ r% ]
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 ]) a1 h8 A* w$ m+ y- {
- * GNU General Public License for more details. p1 V6 r+ ^% B2 P" A! | w
- */
u% m$ J$ ?/ B* a5 s/ l. P: r1 i
2 x# c# e! n4 C k- #include <linux/module.h>: c' k) J) F5 p
- #include <linux/init.h>
# p, `5 _- v$ w% F - #include <linux/errno.h>! |9 }9 V2 {: G; K$ o
- #include <linux/types.h>
) N3 s+ n) Y$ C* |4 G$ Y* _: V - #include <linux/interrupt.h>8 b5 k" K6 T# Z/ }
- #include <asm/io.h>( b5 u/ Y; a0 E5 Y" o$ E# A. {
- #include <linux/moduleparam.h># b& ~ ~2 f' e ?3 H
- #include <linux/sysctl.h>
4 B& K5 ~( u) t1 |( o- v2 q' ?3 f - #include <linux/mm.h>. ?; s5 H; }) @( e0 v- H
- #include <linux/dma-mapping.h>7 W, T2 x: j# n5 A# B4 ^
- 6 j( K& a, H/ O' t
- #include <mach/memory.h>- R/ ]+ N1 f \9 \5 B3 I- {
- #include <mach/hardware.h>+ g$ Y" z6 b3 U! p- D
- #include <mach/irqs.h>
5 j: {1 W2 K: h* s9 d0 U( d# Z - #include <asm/hardware/edma.h>5 g# Q A H% h* x o) L
2 c& z. U/ U8 q/ t" D' `# d x- #undef EDMA3_DEBUG7 b% m7 R, N! x, P$ c7 v
- /*#define EDMA3_DEBUG*/# k; O+ ]. |: t; x7 w. M* H( W
- , i& Y1 Z! J+ E' q4 g3 I
- #ifdef EDMA3_DEBUG
8 y5 h. V5 R$ h: a - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- t/ w% p6 ~6 ?+ t - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 `/ S W, r4 T$ g - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 R# R, l( m" u1 M. L
- #else
' \( s B, x/ K5 s/ x - #define DMA_PRINTK( x... )5 w) ?8 B5 a7 O0 C/ q
- #define DMA_FN_IN
- f, Q7 c) z+ @" g4 q0 Q' P - #define DMA_FN_OUT
- V8 l, [& c- B% t* P0 j - #endif
i6 G( @% h8 i; i - + H9 X/ }! ~0 L; G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). @' M+ L' \+ F1 ~% _/ s
- #define STATIC_SHIFT 36 g3 K3 ?5 L( ]$ s
- #define TCINTEN_SHIFT 207 p+ g5 b$ b1 N7 W" a4 |: M E+ e
- #define ITCINTEN_SHIFT 21: T, {, X$ r: ^0 N- [( S7 a5 o) M
- #define TCCHEN_SHIFT 22
& x# B; v1 X' s - #define ITCCHEN_SHIFT 23
5 u8 {6 o( Y! t: `4 p& J* X% V
8 f7 K$ d. B: X# o, y/ [5 R- static volatile int irqraised1 = 0;
3 Y, n2 ~) J: U/ @ - static volatile int irqraised2 = 0;( j' {1 v6 E/ t2 x& S; |
- 5 h. ?: D1 \! i- ~) g* D, D
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ W5 |6 o( U& I% x H
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; X; }9 f+ w7 ?- T! [. k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' j) y% w) V6 x7 v# C
/ \6 P$ n6 j' r: z1 Y! l, x) C- dma_addr_t dmaphyssrc1 = 0;
4 [8 k( P0 w) P" X4 p2 E7 A' L+ ]7 B - dma_addr_t dmaphyssrc2 = 0;
; B* r4 K- b0 s7 @ - dma_addr_t dmaphysdest1 = 0;
/ R$ V; _3 B9 j* D* n, N: t - dma_addr_t dmaphysdest2 = 0;! [& |0 y4 F* L) Z/ C& ?: i
- * g l1 b1 ?) R
- char *dmabufsrc1 = NULL;4 d% K+ W O4 a$ q" z
- char *dmabufsrc2 = NULL;
& ]) u+ Q' P$ M2 ?. g2 w - char *dmabufdest1 = NULL;& T9 h" T6 W- l. j9 @
- char *dmabufdest2 = NULL;( o( c" s, O) Q; _& M0 x6 z
- 9 }6 V* h0 ^& Q5 d |! \: r
- static int acnt = 512;
d1 v' m0 T" z4 [8 k3 c" ~+ \ - static int bcnt = 8;
7 c: p- q. G8 ~5 n - static int ccnt = 8;! j6 Q) T _3 A5 z
- 5 }( v( u4 q2 X% |* V* Z8 Z. `
- module_param(acnt, int, S_IRUGO);/ F9 _" e6 E1 F! s8 h$ C! ^
- module_param(bcnt, int, S_IRUGO);
' Q. k' T5 N4 h! X - module_param(ccnt, int, S_IRUGO);
复制代码 3 d2 _/ b0 u7 P- t; [5 H( J
5 z4 L( ]4 v5 n: p6 Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 L3 B- f: T; l1 z) Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% U+ \5 O- G% R8 C6 }* y4 m. L2 v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' f) v, _8 e$ g9 k# ?5 p( C# h- v
. [; h+ W( K# g3 |' ?
2 w( l' ~; `+ D, _6 u0 v |
|