|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ v' t! U1 J4 |" U; j- [code]EDMA sample test application
7 V, Q+ X+ Z) J% P5 l& ~ - /*
; ] v; G$ [" P# w' j* t - * edma_test.c
, p) X7 L+ n4 O. Z - *+ R8 c- h, I. f+ }2 u- x/ l# t
- * brief EDMA3 Test Application
# P E, X% p5 i" x- L" S; c - *0 M8 B" N9 g O# ]% { F) _
- * This file contains EDMA3 Test code., C/ y+ I- G( Q7 G8 P. d
- *1 F' r+ K0 f4 k
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' ]* U) k$ G. f' T5 ?+ L! ?: y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& M. v: p. u9 D. p8 H( ?1 Y$ R
- * TO CHANGE.
# X9 I1 z4 q4 Q% o" ^$ e - *" D0 d" c; B) `8 I7 j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) x: e& o, |: B4 Y' T1 |
- *: T; G) Z0 |" }% F# j) c, R$ G
- * This program is free software; you can redistribute it and/or% i' ~# z& P% H- L H/ ~
- * modify it under the terms of the GNU General Public License as
9 C+ X. r0 x3 a7 Q1 T. y4 X2 a - * published by the Free Software Foundation version 2.
! c1 a K6 n0 S0 ^ - *4 E( r/ ?0 X0 ?6 i1 X+ Z1 z( t b
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* z8 c" B. T( [/ a2 q
- * kind, whether express or implied; without even the implied warranty
! Q8 g6 I. z* K; J% W: D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( n3 T- s" R, |. j0 ]. X6 x" _) S - * GNU General Public License for more details.# D$ r7 S5 Z% }
- */
) t3 r1 l8 H* z8 I' |+ V9 z6 i - & B X- _6 M8 Z1 Z$ S
- #include <linux/module.h>1 [! x; x& u0 |; f# }, G
- #include <linux/init.h>8 u* v% [) G% j u
- #include <linux/errno.h>* X% S0 g. `+ p4 e
- #include <linux/types.h>
( z. j" G; M2 [& I+ I9 @ - #include <linux/interrupt.h>
3 M9 N3 q; M" N8 r5 y/ V4 R - #include <asm/io.h>
- V3 s$ j' M& G T) d - #include <linux/moduleparam.h>
7 ]& d2 T |8 [ - #include <linux/sysctl.h>/ Z; T% f3 o$ }: Q1 n
- #include <linux/mm.h>
3 T# y, E% q9 k0 C0 ]8 ?3 X* A - #include <linux/dma-mapping.h>% f" t$ j* m. [
. R: |9 x( |% a1 ?5 f% x7 r- #include <mach/memory.h>
, v! v- s; R. p7 u7 L( }0 M9 J - #include <mach/hardware.h>! j5 k+ e3 H$ n9 S8 r
- #include <mach/irqs.h>
0 Q5 `5 a" x9 t6 C* ?* T- V9 `# E# N - #include <asm/hardware/edma.h>; b) Q* m+ {- K5 j& r
- - g$ q! H$ I% \4 k/ |% z q
- #undef EDMA3_DEBUG
* ^1 ^: `* Z4 z5 G7 S: V6 S1 K - /*#define EDMA3_DEBUG*/! S3 k, n# x, [. k, |. b9 X. U1 g9 B
- . l; \6 i0 @2 Z2 x, ^
- #ifdef EDMA3_DEBUG
" s+ q; R" p/ b1 y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 A, r# l5 O. M5 T2 I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" }' x2 p$ _/ h. R q/ y |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# W0 w3 _4 _7 g: q2 d2 N
- #else K& ]6 O7 F0 a+ K* E4 K0 @
- #define DMA_PRINTK( x... )
+ c, `/ @% U' @+ c - #define DMA_FN_IN! T4 T, _0 A) ?/ _7 ?
- #define DMA_FN_OUT) }$ C+ |/ ?1 D) x' t
- #endif8 ~5 F: i* L) |, M4 C8 \
- ( d; L4 P/ B* t1 Y4 H! k4 U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 A2 `# Y a: O+ C - #define STATIC_SHIFT 3
6 Q7 j$ X% J7 U9 [& z' X3 H8 |, z3 k - #define TCINTEN_SHIFT 20
' i# T) L# I" v* m' W* _ - #define ITCINTEN_SHIFT 21
- O9 v& p% [8 q" e! B - #define TCCHEN_SHIFT 22% j+ ~( n$ `( s0 u9 Z7 r
- #define ITCCHEN_SHIFT 23
1 S" R4 U3 S L. z8 p# N- f - 7 q& v. Q. j8 t' e$ I
- static volatile int irqraised1 = 0;, a1 [4 C. G% q: W; _
- static volatile int irqraised2 = 0;4 `+ o8 R* y5 n& ~4 u
; y% f) e6 |& j. g- p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% J( e% k$ A& e' m6 N- _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 i( O. g. R! \" _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% D% d9 Y1 W" ]' p
- . L0 g: Z4 D, n: w
- dma_addr_t dmaphyssrc1 = 0;
h1 V$ }8 Y5 L" U6 l - dma_addr_t dmaphyssrc2 = 0;
1 ~; P+ X/ j- X. }) Y8 t- b - dma_addr_t dmaphysdest1 = 0;: }; c& o. ^. W
- dma_addr_t dmaphysdest2 = 0;' ~% L1 O0 s& n) @
- 5 E7 i% L x- @" c! A' y( B
- char *dmabufsrc1 = NULL;
. ?- G4 k" u6 Z5 j( p% R, [9 u - char *dmabufsrc2 = NULL;
1 v6 _4 A3 R9 F6 \, i - char *dmabufdest1 = NULL;
, H( ~' k8 i! o+ u* y, R - char *dmabufdest2 = NULL;6 c) ^# {2 d) h4 T3 ^5 T2 z @
- % m* B$ E# L+ o6 \4 _6 h. T, R$ q
- static int acnt = 512;
6 j& l9 m/ A9 c: Z. S - static int bcnt = 8;
4 \% b8 R% N, u# |% T! x - static int ccnt = 8;. e/ D* h) ^0 Z+ E. @4 W
+ e5 j* G- C& j; Q+ k& E& s- module_param(acnt, int, S_IRUGO);
& }& a2 k5 l6 H' R6 c: ?0 I - module_param(bcnt, int, S_IRUGO);) l6 s( G. ~+ d) u# G* x7 b$ V
- module_param(ccnt, int, S_IRUGO);
复制代码 9 [8 j$ Z) M3 Y6 ?
! ?! A- J9 J& N& l
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! t+ f! Z/ l6 h0 E8 warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& q# x9 |1 v+ H& j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 J6 Y/ { Y" O7 K8 [7 J
3 G5 W- w, X# X9 k, \
! F* v: L' @! q6 k1 F' y% J$ f. c. J
|
|