|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 q& [. b, V0 {; @7 o8 L- [code]EDMA sample test application
# n% Q6 P+ A% t6 Z9 m - /*% c% D2 h* N( h9 r' O3 X* M
- * edma_test.c
/ N9 J0 j3 R& l# N - *" b# d9 e/ g, i: F$ w W0 ]6 [
- * brief EDMA3 Test Application
8 m$ F) y- p8 u: F& k - *, l, O" ~7 h1 p. w- Y
- * This file contains EDMA3 Test code.% e5 i3 m- W) s! U" Y) f$ k
- *
) x6 M3 r- C7 V0 z% g, | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& F1 \7 h( Q- [8 A/ S! j
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 z/ T; W+ [3 t9 e, c9 h. n - * TO CHANGE.7 T x4 E2 R2 t
- *
. h7 G; }' `1 T) F% w - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ M* T7 n# i4 {* B* _7 t' N" q
- *2 ]9 r' B$ ?$ U( l9 Z& q1 X. I9 p
- * This program is free software; you can redistribute it and/or( Y' I# x" J, v& Q. c7 n! S! \
- * modify it under the terms of the GNU General Public License as0 @- V9 F# a ^) I
- * published by the Free Software Foundation version 2.
1 D9 |9 V' ]# z. \2 v, f" Z+ s - *6 X- E- X6 L f% [; B* f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 w: n/ |4 k0 I8 n7 T - * kind, whether express or implied; without even the implied warranty
' W& j/ d9 m# T! r* s - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* Z6 Q6 ]' D6 w2 f+ ^
- * GNU General Public License for more details.( \( a* V- [' K% w, k; _
- */. n. J) l3 ]2 a, r$ V8 S
( s! {% w2 V7 H/ C; m; j- #include <linux/module.h>
5 g4 O1 d3 V& ~6 |, F - #include <linux/init.h>
* Q$ i4 w$ |- b; C) r% c - #include <linux/errno.h>
6 s6 T% P) d+ R5 y - #include <linux/types.h>
* {; v) V0 \& g: c - #include <linux/interrupt.h>
& d4 H* q, R! C4 @! t4 m/ z1 ^ - #include <asm/io.h>
+ y$ g: A9 H6 H: X. k4 j5 ?3 M - #include <linux/moduleparam.h>. h" w7 P' D7 q$ B9 p
- #include <linux/sysctl.h>: O1 C( j* R+ r# J) y
- #include <linux/mm.h>! ?6 w+ c" M( e. d( I% ~6 L
- #include <linux/dma-mapping.h>; j5 a% H: s a. \6 N9 ~8 z
- % W7 t: u5 M( v3 l( k- I5 Z
- #include <mach/memory.h>
; z* Z( i2 |+ s: X3 w - #include <mach/hardware.h>
. {- A& h/ o( E0 S) E: C% [ - #include <mach/irqs.h>
% [3 d' s d' B" B* N- U - #include <asm/hardware/edma.h>2 N) c' H6 O: Q9 _8 b9 t/ p4 p
- # y6 V: A# G8 H" ~: W6 c
- #undef EDMA3_DEBUG) P& J/ M& `/ Y1 n3 u
- /*#define EDMA3_DEBUG*/
" N; v6 N; r) Q; G3 |4 I' B8 N9 r) j3 P
4 Q2 B* l/ H5 j$ {( N0 u1 p8 J- #ifdef EDMA3_DEBUG
$ b$ j5 Q5 `. M% i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ m) Z [' a* L5 X0 }% \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" W9 y8 o$ D; D2 {. ~/ ` - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 f+ c$ {5 n8 b2 | - #else: A: I4 o% _8 n- L/ B3 R
- #define DMA_PRINTK( x... )
, B( W& W9 q$ F$ B" W) E* S* K9 r* Q - #define DMA_FN_IN
$ J) K* L6 I, g4 x# b. Q - #define DMA_FN_OUT) J" |1 ^, \& I F+ i
- #endif
, b0 N& @# v5 {- W6 K/ f' S - 0 t0 D/ q$ A, D' b6 i0 e, H) b* f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- w% |" c# v" a2 j8 L - #define STATIC_SHIFT 3; y3 @4 f8 d" _) V E* P
- #define TCINTEN_SHIFT 20
! P) K; E8 M8 Y* @ - #define ITCINTEN_SHIFT 21: X; _8 @& N9 ]) Z
- #define TCCHEN_SHIFT 22& `2 I6 _% _. y* K1 i# Y. r+ t, q
- #define ITCCHEN_SHIFT 23) |# g) t* @8 I5 K1 W( [' P% f
- 4 t- W6 J8 V4 w) \. P8 r. W
- static volatile int irqraised1 = 0;% v/ [ h+ c# W; i4 f' }$ p
- static volatile int irqraised2 = 0;
+ r" U1 n2 M4 l4 r6 Z4 h/ x
8 w+ J- ?+ g( a! O, s4 x2 O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- U- c/ \% g/ ^8 _ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, s3 d2 X; F1 |1 p S0 Q4 e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( y2 r7 m0 `0 Y$ S+ p. U
- ) t3 R& n" I2 M3 Q# S. H3 Y; k
- dma_addr_t dmaphyssrc1 = 0;; f7 H! a. e4 ]# }
- dma_addr_t dmaphyssrc2 = 0;$ R9 Z r% Y# i% G" m
- dma_addr_t dmaphysdest1 = 0;5 t2 a9 K; r0 {$ \# J$ ?
- dma_addr_t dmaphysdest2 = 0;
; E6 f, i7 ~+ E; y8 C4 [0 j
- G/ N# r8 a7 v. d- char *dmabufsrc1 = NULL;$ B4 C, G. p9 f' U$ j; O$ q
- char *dmabufsrc2 = NULL;
2 u# r* g- P! I. W u - char *dmabufdest1 = NULL;
0 Q& |" q& Y! T8 l - char *dmabufdest2 = NULL;+ N- ^- s! v9 X; ?' H: M
" p; r* n5 k- F3 j- static int acnt = 512; h6 w/ \6 W# z
- static int bcnt = 8;
# M- U- G k6 _: f9 k, k1 M - static int ccnt = 8;
5 S6 U W* Y7 l& `5 F
) t7 }/ J# y0 n4 x; i- module_param(acnt, int, S_IRUGO);) o" w. D1 g- x7 |+ ` H% q
- module_param(bcnt, int, S_IRUGO);7 ^' c0 j8 X d5 W; a$ n# [% r6 l
- module_param(ccnt, int, S_IRUGO);
复制代码
! f: j, e2 d) ?7 ~+ p, |
1 R- O% Z: }' @, u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, Z0 {* W2 h) {8 c5 @9 \- t# ?! [arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。2 n( w! [* o; j% c2 \: e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& k& B) `+ f3 F# T7 T
. q, ~% ?$ L8 I* _6 Q' E* n. J
# v' \9 S9 F( d, u8 C. E |
|