|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. A* u, S6 a, p8 g/ E' _- [code]EDMA sample test application
9 Z' ]* J0 s/ w5 J - /*- G$ n5 X) ^6 {
- * edma_test.c
* K; U$ ~& L" u - *
3 k! D- L9 n0 f% A! K$ I# D - * brief EDMA3 Test Application
6 W8 r: `' N6 L9 c- K - *
: E3 [& K0 d3 ` - * This file contains EDMA3 Test code.
0 q* a. `7 E0 Q v$ V# C8 F, ? - *
- P$ ^( F5 R; D& \+ Q0 _* J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! f. s6 ]9 a( c% N6 @5 @ ^
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! c( o2 {* u2 f+ v3 I1 d7 o2 q! j - * TO CHANGE., P: X: K- R9 P0 W/ D0 t4 Z3 e c
- *
$ `$ Z" H+ z; ~# A/ u- b0 F* x: W - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 `; s+ e# V% ]# [ O+ a$ y9 {4 y( l% j4 R
- ** {' o; {2 J f2 a
- * This program is free software; you can redistribute it and/or
, I7 B2 C" |: m2 g1 ?7 R5 b - * modify it under the terms of the GNU General Public License as
6 m$ Q; _0 D: m+ R3 n* M: h* p9 ?1 m - * published by the Free Software Foundation version 2." I! y, Y0 A- Z2 r L
- *
8 k( w, X1 s: g+ J( T1 Q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ f# F9 T9 B g- C$ h+ o; @ - * kind, whether express or implied; without even the implied warranty7 z6 D7 E, V n
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* p* G- K! ?3 V/ ?6 \& N
- * GNU General Public License for more details./ e( H. B% ~8 C- P! T+ f; \$ X4 T- r
- */
1 v. l2 M* \& j' D/ [ - " r' y* b6 m7 \+ ]! e- ^. h
- #include <linux/module.h>5 h" s3 o6 [" Y" q
- #include <linux/init.h>
W+ R; i* m) V& W6 \ - #include <linux/errno.h>
6 s8 t5 r5 f8 l% l - #include <linux/types.h>
K: k( z# q( I0 b( e' W - #include <linux/interrupt.h>( O+ @5 I+ q: i0 ^( Z6 q# |
- #include <asm/io.h>
; F4 Z7 u! x, u! n( H$ Q - #include <linux/moduleparam.h>7 B1 ^% _) m& Y! z; U U
- #include <linux/sysctl.h>
. d) a {# k$ Y - #include <linux/mm.h>
' h8 E9 O. d$ \- [. \# \1 ] A: f+ D5 l; | - #include <linux/dma-mapping.h>) W- m- ~( m* j0 `- n n
- 7 T. q9 {) g5 z9 g
- #include <mach/memory.h>/ B# F7 m% o3 b5 `, y, ?
- #include <mach/hardware.h>
0 P/ B( W: g' a# f& @$ i" e9 Q$ T( E/ [ - #include <mach/irqs.h>
. Y1 w) N( {3 U8 N" p - #include <asm/hardware/edma.h>. a6 y; e4 H7 d& `* D0 H
- * l+ t7 y8 T' r7 C; k' q/ t: k
- #undef EDMA3_DEBUG! k8 y' \0 X$ C
- /*#define EDMA3_DEBUG*/
- E$ _8 |$ i1 E5 x4 S3 c, | - 7 K2 M N7 V1 s" g1 W& m8 w4 m
- #ifdef EDMA3_DEBUG
9 C) x* E6 E5 _8 A7 E, R7 W+ V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) l3 d* h$ }. U8 p+ H* }' ^# D - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 H/ l: Y3 P# B& K. C7 g9 c - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ B- O; U) J- T( h9 k" p! A- p
- #else* {' o+ n M" j9 P. H; |- ]# C
- #define DMA_PRINTK( x... )% i; T) F4 h- Q! \# W
- #define DMA_FN_IN
$ L' j+ ?6 S8 }7 K. }" o# Y* \7 U - #define DMA_FN_OUT. J- {1 o- s5 c5 g5 m
- #endif
6 _8 A8 J4 Q9 O
2 H, `: c Q! p# h7 m$ x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( M. b" I; ^! |. G0 `1 L% R
- #define STATIC_SHIFT 3+ T& @6 O7 O: V& d/ ?* ^
- #define TCINTEN_SHIFT 20$ S! h* Z9 E" h9 z4 G0 X! h
- #define ITCINTEN_SHIFT 21
: ^8 d6 [1 m" Y- h - #define TCCHEN_SHIFT 22, w5 O: Q0 ^& D) ?
- #define ITCCHEN_SHIFT 231 u3 Z5 r9 E$ J9 }3 b* S! x
- : Q+ }$ D* r. q; b. \
- static volatile int irqraised1 = 0;
8 R9 q) ]0 Q# z A) n" R0 u2 w' j7 d - static volatile int irqraised2 = 0;
* j: o% i& b5 {( c9 o
; b6 n# r3 o) v& ~) ^1 o3 a$ ~4 ^( m- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: k% f7 A w. H+ G& d6 J+ T. b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. a( F& S6 O% v s$ M6 q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! H7 J! L8 P- x
- 0 l; Q/ l& J* h, G: `
- dma_addr_t dmaphyssrc1 = 0;
/ g2 T' q" {3 \: V; I - dma_addr_t dmaphyssrc2 = 0;
. C' K! B1 L9 @' s9 N. v# V8 I8 {7 n - dma_addr_t dmaphysdest1 = 0;8 J5 D) w1 V' Q( v
- dma_addr_t dmaphysdest2 = 0;
7 S* {* C$ k# x) _: _$ J K4 B
( z& }/ \6 Q/ j0 P- char *dmabufsrc1 = NULL;, R/ Y2 d$ G0 u! L/ D7 }2 ^
- char *dmabufsrc2 = NULL;! X) Z5 Q* T+ s3 R. x
- char *dmabufdest1 = NULL;5 F' @' k& `# w! i
- char *dmabufdest2 = NULL;3 z3 p, b# M; O4 x# O
: P0 A$ m4 |- m* w+ {: \- static int acnt = 512;' U& l: _1 d: J( V0 `. S/ n7 v" ?3 p
- static int bcnt = 8;$ N% d- Z/ T3 g* y0 B) N e
- static int ccnt = 8;0 w# _* K% P5 n
4 w+ s4 w5 T7 K/ O- module_param(acnt, int, S_IRUGO);! L; H& j: c4 }0 ?+ _
- module_param(bcnt, int, S_IRUGO);; S' k$ l; ^5 [6 D0 B
- module_param(ccnt, int, S_IRUGO);
复制代码
8 {6 W: ~) ^' y3 ?, {( J# e/ m: t J
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# U9 I& m8 u$ x* p. d' aarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 ^1 v8 u' t; K. H% s4 s! @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* l; Y0 _4 n9 r: `' w9 a6 }
- H* o0 c \- e8 G2 a) p
/ u8 }& F9 \, `# Z: E |
|