|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 K ~1 |* g6 d$ R- [code]EDMA sample test application
8 {1 D" \+ J/ @, H5 h r, y - /*, P) B5 a& K o- G$ B) Z8 |) j, d7 G) M
- * edma_test.c
* S$ @0 K4 t: M/ d - *
. U- V% O6 J* }5 m; Q; d; w - * brief EDMA3 Test Application
) F) }7 M, m _2 s4 Z+ l - *& f2 t* W* M" B5 z
- * This file contains EDMA3 Test code.
3 z# J0 x% U+ \6 p - *
# ~/ e9 h" Z1 l; `( b i8 d) R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 Y& N, l7 ~" c% \2 a' T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ h* c5 x& Q) o$ K% U
- * TO CHANGE., G+ j: d; V) c- [6 z' ]- T: L
- *6 z$ {3 ^4 }: v, u1 t, _' k/ t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# U0 s, M3 M4 l4 _( N2 z - *4 ?9 G v' e/ H; U2 q8 b: r
- * This program is free software; you can redistribute it and/or
& B) i, D8 ~2 Y3 K - * modify it under the terms of the GNU General Public License as" P) }8 l5 ]( B9 [
- * published by the Free Software Foundation version 2.1 B) e3 T- M# Z6 N6 W
- *' R! j1 M1 Z& Y; o, ]
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* y5 }1 h/ L T% c
- * kind, whether express or implied; without even the implied warranty: l E8 d/ Y9 L% ^0 o$ G
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 T# M, e U* S. Y$ x - * GNU General Public License for more details.
2 ^+ g. k4 |) m; m% ? - */. g) U$ N4 C8 g# i; k Q
- 9 G3 i; p% o) C# s6 W
- #include <linux/module.h>
3 [0 y0 m5 z! s0 r9 q5 k - #include <linux/init.h>
2 ^* x* f w1 v - #include <linux/errno.h>
# }; l' f# x& ~- f8 d9 x - #include <linux/types.h>9 N2 T0 h( k8 C' k% v
- #include <linux/interrupt.h>! d, e5 S5 U7 S" k5 e
- #include <asm/io.h>; W: `& }1 J3 ]7 S
- #include <linux/moduleparam.h>
- M; Z- e6 ?9 c- h' P) J6 n# R - #include <linux/sysctl.h> w: B# [5 ]% r/ k& j0 m k# M6 ~
- #include <linux/mm.h>
3 \$ [7 O6 Q5 s. ` R - #include <linux/dma-mapping.h>
$ g( e5 c. k: s7 V2 U1 j" i - & m2 P( @0 _* G, t0 I% q) b
- #include <mach/memory.h>3 b0 {8 f( O' G
- #include <mach/hardware.h>3 u! `# M( c2 P _/ H
- #include <mach/irqs.h>
" m& ^3 _8 M' o - #include <asm/hardware/edma.h>
9 R6 h* f K* h$ n$ c3 \) ?9 T" L - ! @0 U1 q% f; L8 h
- #undef EDMA3_DEBUG- n. o H9 q3 w H2 }$ q. W, g# W4 Y
- /*#define EDMA3_DEBUG*/' |/ M8 z* B9 L; l5 t
1 F, C- {) f" M! q) Z! j- #ifdef EDMA3_DEBUG1 ]% j+ f" U- x; A$ \2 H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 L8 |( a' l) S" }! [- V1 V# b, g% C
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); c) v! t/ j: C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
. q$ _4 K; }8 C" _ - #else+ G1 j4 U% L* F3 Q
- #define DMA_PRINTK( x... )
; O; D _: x, y y: A3 t% W$ ^. J - #define DMA_FN_IN, A$ S4 r$ f' X9 X( v" V) F: f$ h
- #define DMA_FN_OUT
( H8 k( l: [& d! [( e0 s" N( ~ - #endif: e1 {5 `! s& r1 w* g5 p
# A% `% A' U, E& R! I" N( r0 w- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ J5 y/ R1 V' _ K
- #define STATIC_SHIFT 3
* o( t7 g9 y6 Z# c - #define TCINTEN_SHIFT 20
. ~9 Y' |: s8 O - #define ITCINTEN_SHIFT 21
" }' `# r2 z& q2 a6 R- U - #define TCCHEN_SHIFT 22
1 B0 C$ A" D l7 ]6 V+ d - #define ITCCHEN_SHIFT 237 q5 `3 m/ s x6 W6 l8 s
- ; N h% j8 F/ k7 j: E# a/ K; u
- static volatile int irqraised1 = 0;
A8 H4 _0 |! L7 G6 |7 y - static volatile int irqraised2 = 0;7 x) @& X* H j
) d$ w0 l: w. w2 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 K6 A$ I! Y3 h6 V, ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% e A2 M/ d e2 r1 E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; |* f/ r2 r% U' i1 @; U+ y+ G9 k; ? - . m0 n9 O" Y" D# q
- dma_addr_t dmaphyssrc1 = 0;8 u4 f6 x0 _- ^( t& ?6 [
- dma_addr_t dmaphyssrc2 = 0;9 a; ]" e t" J' ^3 g: x
- dma_addr_t dmaphysdest1 = 0;2 T; k# k8 Q7 F: K% |
- dma_addr_t dmaphysdest2 = 0;( J6 d/ s% Z# ~0 [( Y, h' B
5 B d4 Z$ {+ r- char *dmabufsrc1 = NULL;" S; M- t3 G6 y3 @
- char *dmabufsrc2 = NULL;2 g- _7 t4 m3 |. A. a7 d+ }' _
- char *dmabufdest1 = NULL;. ^! X `& e3 ?; S
- char *dmabufdest2 = NULL;
- ~1 A7 I7 S" b0 D" i6 K7 k' f8 J3 h - / x1 V' X/ A: ?2 P
- static int acnt = 512;
0 W. \7 d! {7 n2 H$ I4 [ - static int bcnt = 8;
. W$ Z+ d7 ?" j; X' B - static int ccnt = 8;
5 r; {+ [" _# p% \. U! k( \ - % s, w, ~7 Z4 O. p5 q* b4 r/ H
- module_param(acnt, int, S_IRUGO);5 d+ ~' }& Y) X& ^0 V9 V9 `
- module_param(bcnt, int, S_IRUGO);
) y+ F4 j t3 K0 l - module_param(ccnt, int, S_IRUGO);
复制代码
# q* P; w1 n K5 T; F: `! S% c
' A/ z: B4 W5 ~ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 V2 j) J# [. E9 o! K& d( Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ O$ W: n0 _- i
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ G* L' h7 }& q
2 G) Q0 X8 Q! ~
) G/ B6 X! [7 o: g6 x7 H |
|