|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( Q; d/ a$ F y* g# j3 |% B
- [code]EDMA sample test application
% D8 y5 M7 @$ P- f+ V* b# h5 d; S - /*
# ]( ~1 C8 @% Z - * edma_test.c
2 B8 ^2 U1 Q, ~" S; ]2 w7 u( w - *
0 ^0 y% J5 V' J1 W/ x% R - * brief EDMA3 Test Application' J2 ]; S# w' ?8 w+ X6 y, K2 T
- *7 h y' S" u5 K8 {
- * This file contains EDMA3 Test code.
; ]4 R2 D8 N* g - *+ x1 Z5 b' e, r% \6 I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 B, M$ Q3 V6 y8 a; g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" \/ z9 C3 S! x7 @) f
- * TO CHANGE.5 B9 c. H; b# f. g8 K: ?3 ^
- *6 K1 B7 X4 s( r% g. f1 B" C2 N/ c3 I5 @
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
P8 S) a5 y; }# |/ B2 j - *
0 X1 B9 }3 _- q/ Y4 I& u3 n" T - * This program is free software; you can redistribute it and/or5 c7 h0 N/ K& |
- * modify it under the terms of the GNU General Public License as
6 r! a) Z9 |2 j0 [( _- R - * published by the Free Software Foundation version 2.% C5 E1 f0 R# C. v' y" u' p
- *
2 ` x6 J9 h. d6 q: f1 ~' T - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* S, B8 Z" V! y: Y9 I6 ?$ e - * kind, whether express or implied; without even the implied warranty; I6 G+ |3 g! p2 ^" I) X6 f4 Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" M. B: P/ @+ Z2 D: C
- * GNU General Public License for more details.
) n! A+ _/ W2 u) g8 p5 B - */& [5 f8 w9 M9 J# V! j3 \ T- N
- % ~: Z4 p1 R' s% B6 K
- #include <linux/module.h>. K Q) n3 T" c$ a, w+ U
- #include <linux/init.h>
$ s6 [1 v6 g6 n* L - #include <linux/errno.h>. M0 \& \0 S* ^6 H' E/ J% H& Z
- #include <linux/types.h>
* H7 S/ U# o2 L - #include <linux/interrupt.h>
4 x7 T8 T1 w% R# H' C9 e- i0 b - #include <asm/io.h>/ n+ h6 ~4 L: @
- #include <linux/moduleparam.h>
1 ~( d' ?1 E9 | _, C* u% b - #include <linux/sysctl.h>' _# r2 o3 H3 A- K7 }
- #include <linux/mm.h>/ I, M* n6 n. c) U' W. F7 K$ @
- #include <linux/dma-mapping.h>5 V& X8 {# N: R+ G
0 O+ G3 Y% h+ k- #include <mach/memory.h>1 w4 r U0 t& A( l! J9 G: J4 h
- #include <mach/hardware.h>
% C, ` B/ u3 o! Q! Z; |6 F - #include <mach/irqs.h>
. w; Q& ?) P1 I - #include <asm/hardware/edma.h>, g( G8 R# n4 m, v. s$ o
- $ B0 B& y6 w. |2 ~- `
- #undef EDMA3_DEBUG
& u/ G; A& q& @9 r0 A - /*#define EDMA3_DEBUG*/
( a1 `$ s5 _7 N& n/ q - * N6 v' ~; f; k, m( x' A8 }0 d
- #ifdef EDMA3_DEBUG
2 H0 C- |# j w8 ?- z1 e; E& w - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. g8 }! c! {6 @3 C$ ]& E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, e6 \! R1 ?; U7 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ {+ ]- Y. o6 Y7 x5 Z' E% K8 D1 S
- #else
' B' ^; [& X+ w' |# X( n - #define DMA_PRINTK( x... )/ ^8 {) q! }$ v* J' w7 Z" Q( @
- #define DMA_FN_IN$ T. J! A( t: h: D
- #define DMA_FN_OUT
" x2 N2 Y0 [' B7 O9 I: l6 I2 O' l - #endif6 _3 V; \6 f" _+ G& R% j
( z: v) b% H- H+ r: T' x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
# J/ _4 |6 G$ ]+ `- L2 d - #define STATIC_SHIFT 3
" w# e- z$ j- o: G1 V& h8 z" s0 h - #define TCINTEN_SHIFT 20
3 R! D' @( N! q& h* H: H( A - #define ITCINTEN_SHIFT 21
' m2 @7 y& J& Y! x; J- C - #define TCCHEN_SHIFT 22 X! G# V, o, D6 q+ }* y2 ^6 w
- #define ITCCHEN_SHIFT 23
- \8 ]1 i( ]* G# i - 1 S' j2 B9 x( N3 b" X6 `
- static volatile int irqraised1 = 0;8 x2 c! t+ u) p! d! b4 h' n) U: e
- static volatile int irqraised2 = 0;1 _( b! i0 D, |3 H; j* t
- & x7 ^5 [5 e Z; R7 m8 ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# o, P! F- z1 d" p0 N6 y1 w( |" A9 d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) J( O# W8 q3 @7 p, F& D: D6 D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 A6 d) }0 N, n7 R- S - ! [1 @5 L) n' T9 ^6 `' J" q3 r `. q
- dma_addr_t dmaphyssrc1 = 0;) F' t! \0 V7 c) H% f! u( @
- dma_addr_t dmaphyssrc2 = 0;
7 N: C! N6 U9 P* b6 ~ - dma_addr_t dmaphysdest1 = 0;
3 w3 k3 ~" Y% L0 i) ` - dma_addr_t dmaphysdest2 = 0;5 f1 q4 |1 c# j" q
- * t6 z0 @' f8 y8 ~- |
- char *dmabufsrc1 = NULL;% H- R" n& M4 m- T* \
- char *dmabufsrc2 = NULL;5 k, D: I: ^, ~3 R4 M% P6 p
- char *dmabufdest1 = NULL;* U! @) F' T. s% _3 d
- char *dmabufdest2 = NULL;- D( G: s8 q) U K& _# t
' t2 [6 m6 _7 x+ k- static int acnt = 512;
+ c2 ?9 {$ |5 D - static int bcnt = 8;' V) V o' k5 a0 A, C4 X3 y
- static int ccnt = 8;
' z, L. F+ v; N) S* D' ^ - ' U! L/ X2 y5 G( r6 {
- module_param(acnt, int, S_IRUGO);' m8 n1 Q- ^5 o
- module_param(bcnt, int, S_IRUGO);
8 m/ V" @( m/ F2 D' B( t - module_param(ccnt, int, S_IRUGO);
复制代码 # o; Q9 K9 x# D6 z
7 [1 e. N& I& ^. W# A& {
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* T+ ?, ~7 }+ ]; Zarm-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* T5 m7 a" Q. l e2 d; L7 q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, [8 x6 T1 e; _6 s; K3 g7 B0 ~
+ n2 ~) m# w0 u" Q. h( k/ H
/ ~) e( j* X b, |3 D8 Q6 Z2 o |
|