|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 F5 {7 v0 }& h3 x2 m- [code]EDMA sample test application
, ?7 {( {! t2 S - /*+ Z9 ?; C8 p5 @# r0 J& u
- * edma_test.c5 q2 Q7 W4 B( I1 a, }, \% @
- *) h9 c. ^4 }+ i4 [; I# ^$ Z" Y" H
- * brief EDMA3 Test Application
& X1 l8 x0 _( j1 ` C - *" i, |1 n6 b) z9 z
- * This file contains EDMA3 Test code.
: ^2 [* y3 a/ [! r V - *9 w4 i" ~( n, E4 M1 [ m4 D4 c
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ Y; m1 d( {9 k6 l: z# } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 a- ? {! h* Z
- * TO CHANGE.
; Y' G, v, Y) _ - ** \, r' U3 q7 S+ h5 {$ y! B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ c) h( ?/ b4 |! r* q$ E
- *1 i* r1 p, j' [* A5 Z, k; \% f
- * This program is free software; you can redistribute it and/or+ M, Z1 K9 x* \1 ]3 }
- * modify it under the terms of the GNU General Public License as
8 `6 R$ W9 Z% u - * published by the Free Software Foundation version 2.
8 q1 p8 u- w, @8 ]0 A' X1 I - *( @% U: H: k& D6 o# d, T! m" `
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; k& d8 t/ m9 k - * kind, whether express or implied; without even the implied warranty( b% U" J4 i7 K4 a' Z6 r) ^
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* N$ R8 f( ^! G - * GNU General Public License for more details.
0 h2 v9 p( Y! i. E5 H - */
! c. X& c* x/ O8 q1 l4 O - 3 f6 u8 z' O; x# F1 r
- #include <linux/module.h>" Y7 u2 i1 k6 f8 I: q
- #include <linux/init.h>' C4 x7 h, g; {( X/ y# c' {
- #include <linux/errno.h>" _ N3 e" v( b! ~. e7 T
- #include <linux/types.h>
& g3 g9 Q1 G6 Q- @8 M. t - #include <linux/interrupt.h>* f& X8 u6 }2 m6 W) }& r
- #include <asm/io.h>
4 `' k% W0 T9 ^- Y1 E3 D - #include <linux/moduleparam.h>" t8 _. ?5 }1 G; J# h" x3 ^3 D
- #include <linux/sysctl.h>" ~1 K/ v1 l Z
- #include <linux/mm.h>
! p. n& h* I( O4 ~ - #include <linux/dma-mapping.h>
7 T' J7 G( }* L& N7 O
) F" N) m% N" `2 m% q- #include <mach/memory.h>
) d6 t I: k: Y% a0 C# Q - #include <mach/hardware.h>
9 O6 Q% {+ s0 b4 S5 J - #include <mach/irqs.h>0 {. ]- A. y) ^/ r2 H
- #include <asm/hardware/edma.h>
8 J* p) `1 U" g
* z2 M% R) V' G0 Q. t. r- #undef EDMA3_DEBUG+ f/ w2 }# D: B2 [
- /*#define EDMA3_DEBUG*/
4 \# K& ?4 O1 c0 F4 V - 4 h+ r* p" ^& z; i
- #ifdef EDMA3_DEBUG
# @3 L& j* r- B, q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 S% M2 Z% N. d# Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- r8 ~- C+ ~7 b& }8 V& M - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 E# @1 o' X/ Z# h
- #else
c% e1 [% f5 k; |# t% Y8 @ - #define DMA_PRINTK( x... )
% d6 y/ O6 ?: O7 u D - #define DMA_FN_IN8 u& e9 W# z5 j9 @
- #define DMA_FN_OUT
/ y0 Y% B/ P4 V/ D" ]) g" i - #endif
2 I1 }- T! x- a
! P5 q$ L- G( { q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. g0 D# B2 o+ \+ ^/ p - #define STATIC_SHIFT 3
) ~7 r2 x& R. X) d5 U - #define TCINTEN_SHIFT 20
" z; ~+ X6 ~$ J, l0 d5 i - #define ITCINTEN_SHIFT 21
0 g* N! h5 c: }9 w% s4 o0 F - #define TCCHEN_SHIFT 22" m2 Y+ I) S) m k, D2 j9 S
- #define ITCCHEN_SHIFT 23
& s# d3 W, M, Z; J
+ u. N) ^9 t+ {; t G# C/ r n- static volatile int irqraised1 = 0;0 t6 S) U" o, g: Z6 D0 Z3 R
- static volatile int irqraised2 = 0;- E% U0 }7 o7 Q0 r* U
1 @6 F* U0 k. t# I! \! a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 O' Z: g" ]! G: h8 e3 l" t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ X# p) m8 u/ D. j. u9 h
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, {6 ?1 {' T3 h h# m1 x1 }' T0 a
- # ]# X% Q1 n; {2 m8 p9 ^( V5 U
- dma_addr_t dmaphyssrc1 = 0;+ l: O6 G, M6 y/ C: \5 i3 z5 _
- dma_addr_t dmaphyssrc2 = 0;
$ f2 u& {; M) i2 w - dma_addr_t dmaphysdest1 = 0;
4 H8 ~& [8 h* a# T' o( Q7 J - dma_addr_t dmaphysdest2 = 0;' q3 l' _+ t' ?' G! T4 Y
* c8 Y9 ?& F' {- char *dmabufsrc1 = NULL;8 e! Q, U4 q" _: Z; ^ u7 X# J2 Z
- char *dmabufsrc2 = NULL;, S, h% H9 f7 y) X* F" A
- char *dmabufdest1 = NULL;
" O; k& B7 Z+ S$ M" [. Y. d9 q - char *dmabufdest2 = NULL;; _' y$ A' C6 V; L6 G! P. E
- 3 j9 I0 d4 P/ _3 c4 |$ U
- static int acnt = 512;" }' @" ~- j; @8 ?/ m" |
- static int bcnt = 8;
( M* a' ?( z$ ]- b. H - static int ccnt = 8;3 F6 N) o. t y) I5 v3 l
- - M/ E" b. T9 ?( Z& K0 N
- module_param(acnt, int, S_IRUGO);
2 H; V% I. [1 D - module_param(bcnt, int, S_IRUGO);; ]) @3 c: q. Y" e
- module_param(ccnt, int, S_IRUGO);
复制代码 + {% L& a! O% ~( \9 A
# {) ?3 F, m. N& m, ?' Q; Z, S v9 a
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" i# R0 o' H& u4 l. o# G# 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ Z( I. K/ U/ d 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 Q2 h" N, T! k) i6 B
* t2 ^! u! f$ b) I, e2 n8 A# J, @% K6 v# C% l
|
|