|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 F; b2 O* `; `- [code]EDMA sample test application
+ I7 ?/ j6 J5 R/ ?* f - /*
0 l& V) Y& {9 d3 D5 _7 l - * edma_test.c
' S- Z( R$ N6 Y; A q* ]5 X4 [ - *
5 F6 M- L: p) W, ` - * brief EDMA3 Test Application
0 Y Z G5 B: q( W7 u. M+ f - *
4 i. Z% N4 a% c& _ N' L1 U - * This file contains EDMA3 Test code.
& s6 J7 P8 I& ^+ \+ B - *
# q/ u$ R# v9 Y/ G" A3 x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% ^7 F4 L% w, e' G" i
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- t# @8 Q! D1 I' \* s$ ?6 b' Q3 P
- * TO CHANGE.
" V: f& H! k$ t R1 ^7 u - *
) S! @, N- q6 ^- x0 t/ ]9 Z# t - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 ]& T) W3 c2 i; T
- */ x5 p" d; [7 |4 i: U/ I# W
- * This program is free software; you can redistribute it and/or
1 W* d# B2 q7 m* [% m: ]3 n - * modify it under the terms of the GNU General Public License as8 s% J2 F$ A( }0 ~/ Q; |/ Y" r
- * published by the Free Software Foundation version 2.$ L5 b1 }0 v/ n) a+ c0 H2 W" I$ o% t$ ^, R
- *
* Z2 H* z ^) {$ o7 G4 R. r9 j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- p7 Y1 I2 R2 N& h5 c - * kind, whether express or implied; without even the implied warranty* {8 }3 g7 Y- z1 c, Y: G9 r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the n7 y( m' y; P* \+ V+ ]' a
- * GNU General Public License for more details.& A. l0 w( I u. b+ P: I6 r- ]
- */$ }, R* I* i8 \! a4 [7 ?
3 S+ K& ~4 F0 `) A- #include <linux/module.h>/ {! d: C# k1 c6 d) [+ ^# o5 ]
- #include <linux/init.h>2 M' t0 q* ]8 j& J
- #include <linux/errno.h>8 _5 c( y3 O& E8 y# e( q
- #include <linux/types.h>
9 W. [2 _6 _% o+ j2 ^4 P - #include <linux/interrupt.h># u* Q! j; P* c1 u {% ]$ [8 _
- #include <asm/io.h>+ ?7 V9 c; M0 V' n
- #include <linux/moduleparam.h>- c& n) W% A% k! E
- #include <linux/sysctl.h>, l; W% S" S' l
- #include <linux/mm.h>3 ]+ A% p7 I: H& {
- #include <linux/dma-mapping.h>& \4 `% R9 j7 c2 u3 X+ o5 Q8 G2 e
: W$ E7 `( p& g; T6 X9 O$ ?( }- #include <mach/memory.h>! f" b' X1 k- G9 R) p( J( G. n+ K/ b
- #include <mach/hardware.h>, c; U/ l0 a7 T5 V3 K& [; s
- #include <mach/irqs.h>- U. ] k# j* z
- #include <asm/hardware/edma.h>
. [& S' P7 {. z- T$ ^
& F t9 c( l. w1 L4 v- #undef EDMA3_DEBUG$ u: [. @7 X- E1 l; t$ d) _3 z4 c
- /*#define EDMA3_DEBUG*/1 U N+ T5 n- B2 x
) k2 \% Q3 b4 [4 s' P" \- #ifdef EDMA3_DEBUG( ^9 h# P, z9 A* O5 B5 J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ m/ {: L8 U' f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# V3 J& K3 I; h3 y1 } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ y- U7 ~/ `- l8 D
- #else
F' Y' b' v% u& L" X$ @0 x - #define DMA_PRINTK( x... )
6 t# R$ B- ~! X - #define DMA_FN_IN
$ ^ B8 R* |& w0 b3 Z! ? - #define DMA_FN_OUT2 X# ?0 |# B% F4 l
- #endif4 t* W( e9 Q* }' h& E" t
$ R' W; D: p1 f5 s" H' ^6 N: v) L& D- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 Q6 F: p1 T6 Z4 o B/ p
- #define STATIC_SHIFT 3- E- X1 M2 j: p: H& U
- #define TCINTEN_SHIFT 20
# _0 ?, g# H; I* @5 } - #define ITCINTEN_SHIFT 215 O$ g* g: j: ]
- #define TCCHEN_SHIFT 22
/ u1 s* c$ I( \: z4 }+ c4 @ P - #define ITCCHEN_SHIFT 230 b: f( Y8 T2 w+ r. y. ]7 f- t
% G, j& Y. D# `2 g' K- static volatile int irqraised1 = 0;+ w2 e2 q( j' L0 b/ y
- static volatile int irqraised2 = 0;8 _0 q. p# s6 A& K4 E* y3 s* k
4 Y' n3 S8 ^% S' n: q# B: B- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 {1 x) L- I% _5 ~( y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 O/ [! v8 k. e# q! L3 @) k+ ] D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; \9 s/ [- Z+ U0 l+ j; T
) m- C) D: b. V0 D4 y% \+ o ^7 E- dma_addr_t dmaphyssrc1 = 0;
' ^5 F$ b6 p) \. b& m - dma_addr_t dmaphyssrc2 = 0;' O& E, ^+ R" R, g0 q
- dma_addr_t dmaphysdest1 = 0;! ^( g% L* _: X% H% f
- dma_addr_t dmaphysdest2 = 0;. G! j: n1 W- P, p& H7 a8 W4 S
- 6 M, Z& |- y2 a* t& P
- char *dmabufsrc1 = NULL;
* i2 A$ P" q' q- N: H& G - char *dmabufsrc2 = NULL;5 ]. w6 T C( _$ a" C) w
- char *dmabufdest1 = NULL;5 K* g9 R: q7 F6 H: H
- char *dmabufdest2 = NULL;; f4 N5 v) z$ Z
- ( Q0 m. U, a3 o( p/ J( C' ?
- static int acnt = 512;& o; I) _# k! H( m% J5 `
- static int bcnt = 8;7 q2 _9 x& e1 x
- static int ccnt = 8; h6 v7 f# Y# i0 C5 D( ?: [& E" D
; A$ R: ?$ |. K* e7 f$ n3 x- module_param(acnt, int, S_IRUGO);: a6 o$ d( c7 X; m
- module_param(bcnt, int, S_IRUGO);
( }) |8 s" |+ g0 y2 g6 d - module_param(ccnt, int, S_IRUGO);
复制代码 + K2 Q; s* _2 ?" Y5 t2 B5 A
/ K$ R! K5 L% c4 I 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 ] e' ~5 D+ H
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ g1 k* l8 w4 u9 P) ^% r+ Z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) \' j9 v: n ~8 V1 G) P$ [7 p
" f( \ Z' W5 o
1 u% l m: R( m1 v |
|