|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' Q M1 a" ?! ]7 w- [code]EDMA sample test application
4 |7 m5 B2 R Q2 H8 |* N# ? - /*
5 h1 s1 i* d3 s8 J0 b) C7 @4 q - * edma_test.c7 F$ t" b2 v3 B" H. F7 W$ P
- *
. N3 q2 P V! ?- ^* k' I/ s - * brief EDMA3 Test Application
1 Q w r- p3 z* _% g% r3 [6 j - * L% q7 B% I6 |! f0 B
- * This file contains EDMA3 Test code.9 k+ X3 K" k C2 u
- *
6 Q( r& ]- C! S) x1 t3 J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
. v6 G4 }; |/ p - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" U* L) b! M9 x% n H
- * TO CHANGE.( Z4 c( I# l9 g+ [% l6 y
- *: k# ~+ w9 W0 w, C; j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 Y' n- t/ O* k5 \7 J/ G2 J/ ?9 z - *
, w* H2 r% V3 _$ V8 h - * This program is free software; you can redistribute it and/or+ O8 t. w( u/ L/ q% h2 A
- * modify it under the terms of the GNU General Public License as
8 k1 X S" P, a" t - * published by the Free Software Foundation version 2." q; h+ I3 f7 M
- *
. c" ^$ l8 W! j- L' h. B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& T5 T: r( w9 S. P/ p& k6 Z
- * kind, whether express or implied; without even the implied warranty
6 z# m* G2 Z9 N) q H( ^: [" c8 d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 o0 l" t3 ~: a7 y6 g - * GNU General Public License for more details.
" K! j, b' S: F+ x6 u - */. J+ B* J. @4 _. f
- ( L" \% y1 ^% I6 C
- #include <linux/module.h>
& h6 M* r T, S8 v - #include <linux/init.h>
# X/ L r2 G% @1 l; E# [ - #include <linux/errno.h>
# U( @' P1 D2 R/ a4 h: ~4 @4 A - #include <linux/types.h>% z4 ?1 [( q+ `* h0 `; ]
- #include <linux/interrupt.h>
* t9 j( }9 A5 q# R- g; J - #include <asm/io.h>
: X6 A- v- A: }9 k0 V) a# J - #include <linux/moduleparam.h>% [. s: H0 E3 c
- #include <linux/sysctl.h>
. e0 Z j) d# X0 `. `4 P - #include <linux/mm.h>
7 S; s; M) A# e2 Y6 W) A! @ - #include <linux/dma-mapping.h>
# h7 _9 M$ V2 j6 }3 i
/ G4 n2 }+ ~% o' x% n- K- #include <mach/memory.h>
9 Z% c% [& ^; F! K; h. k9 C - #include <mach/hardware.h>! X% D. r5 r) C. z$ q I- x
- #include <mach/irqs.h>3 k" o9 m+ B8 x) u( e/ E3 ?$ B+ ]4 u
- #include <asm/hardware/edma.h>1 @- i2 y7 a9 [' x8 Q: C/ ]2 z
6 N: J1 K4 x0 M) b' v9 H+ d- #undef EDMA3_DEBUG2 c0 f+ U& E- [2 U
- /*#define EDMA3_DEBUG*/
! E( s$ j2 v9 }5 Z6 q - : s. J8 m, w, b; D, S) t" l
- #ifdef EDMA3_DEBUG
/ S) L B$ u8 R2 j - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" D8 U6 |* R% }! x1 j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 M+ R, @$ [! d: I: J
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# a V0 E9 w1 H1 X6 L& K$ b
- #else5 q a. m; s9 L3 `1 j$ }
- #define DMA_PRINTK( x... )3 l5 w5 S6 g. p2 k
- #define DMA_FN_IN
$ @( G% P& ?! d' I, { - #define DMA_FN_OUT
, v' f; B* U$ m3 Z# T/ `8 ]* Z - #endif
: l c( X2 o, q' t* M1 c( }3 d$ u- i
; {; ^5 Q6 ]; @. w( K2 U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% f) b: J/ w6 m, @ B1 F9 i- L
- #define STATIC_SHIFT 3
0 ]. E- h1 _* ~3 y - #define TCINTEN_SHIFT 20, D6 L, E2 M- p l \; P
- #define ITCINTEN_SHIFT 21: q2 A: L" v3 v" o
- #define TCCHEN_SHIFT 22/ x! S) _" x( r2 Z* _! @: H2 K" Q
- #define ITCCHEN_SHIFT 23" x0 k* k0 U6 m& Q2 _. K
% _8 x8 ^* |9 A1 m0 g; K+ o- static volatile int irqraised1 = 0;) L M+ {, _6 T2 v) G+ t) q! b
- static volatile int irqraised2 = 0;
5 U& N3 u& O8 q- ]! m - 3 U. P5 @/ s9 H* u; {9 ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 e2 [) T- T3 Y a$ n; ]" { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 T- j5 J1 G. q; @4 s9 y2 H/ j6 {1 `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 r% `- @1 O1 H) r2 m" W
- & J; Y1 C9 D3 j9 C: p n! E
- dma_addr_t dmaphyssrc1 = 0;
/ T; T2 V! p/ y$ ^ - dma_addr_t dmaphyssrc2 = 0;
/ B) j+ `8 k- s5 [ - dma_addr_t dmaphysdest1 = 0;$ Q. s+ M. @) I1 z
- dma_addr_t dmaphysdest2 = 0;+ r% W. x+ V$ W2 b6 L2 R
- - ?# Y2 Q/ A: u3 ^
- char *dmabufsrc1 = NULL;: \6 a* S6 o8 I/ B5 C" `% c3 I5 e
- char *dmabufsrc2 = NULL;
: m7 G% A8 A/ |( }8 x - char *dmabufdest1 = NULL;& \5 _* M- |3 d3 \, \ Q5 F
- char *dmabufdest2 = NULL;
! n3 C( a5 W8 i, i: }
" n& K# g; _) t$ r& Y- static int acnt = 512;
* @' T9 P: [; T7 ~- E2 S - static int bcnt = 8;/ f4 x9 a4 b2 W3 U6 q- r' S4 V
- static int ccnt = 8;1 O/ p3 S- _/ c, o( K
- ' M' S7 g( c! _' Q. a( U
- module_param(acnt, int, S_IRUGO);
# i) O: [) O, d1 h - module_param(bcnt, int, S_IRUGO);' `% \1 F# F4 P1 U; ~+ F! X3 |* [
- module_param(ccnt, int, S_IRUGO);
复制代码 , m/ h1 q- i0 ?1 `0 S c6 c8 c/ f* D
5 M1 W' q5 y3 H- }: z7 ~: v! g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) b$ O4 b1 ~: Y2 M% l! oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( a6 }8 Q6 p! e! z' Y9 Z1 b. h 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, Q: I. G6 |, B3 \
* A2 B$ \0 K' m$ W- E) K, k
. Q" f$ g1 M# R' X& _
|
|