|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; v6 k' B) {) Q3 l+ u
- [code]EDMA sample test application
# H' X! c8 ?* m& |5 I - /*
1 D$ q6 S3 G' d1 J. P% k - * edma_test.c
W7 ]! `1 i5 G8 ~) q) P* e - *
. k6 F/ M0 S: @( ?, x# g - * brief EDMA3 Test Application: n9 W/ W( U, c) E* ~6 a+ g. [
- *
# v2 @, Z' B6 ?+ t; M - * This file contains EDMA3 Test code.
3 |- p- W6 K0 c" a - *
* q& D" M7 [0 ]5 q+ B& \: `3 W - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 M% [ ]5 p" w3 U& T7 `1 ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 a3 G, W6 \8 D+ s
- * TO CHANGE.
0 B" @$ i3 u- ~4 d- k b2 \ - *8 V s* }9 y p
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( m% p- Y2 w) _; l7 R+ x8 m
- *
, j2 T4 j1 Y* K - * This program is free software; you can redistribute it and/or
1 J# i$ c( Y, x7 w - * modify it under the terms of the GNU General Public License as9 s' z+ E( W" P3 u8 u0 ]$ x2 g% ], U2 W
- * published by the Free Software Foundation version 2.% f+ S! Z: F4 X# V+ z7 E$ |. I
- *0 {# t& Q5 A$ k( |& G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" S0 h9 o: d3 u* X" C, U& J& N
- * kind, whether express or implied; without even the implied warranty
* n* B b# Q$ j0 G, C4 H1 J! N' b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 K$ g k+ f, t X - * GNU General Public License for more details.0 l7 m6 U ^9 V
- */: Q4 z5 t. p+ _8 {
# ]& V" O- M3 K8 j- #include <linux/module.h>0 `$ w, h+ y9 W& T! W; M
- #include <linux/init.h>3 |2 o" ?3 K$ G/ i
- #include <linux/errno.h>6 H0 H% L# f, q, e! Y& r
- #include <linux/types.h>
8 _6 _ `, O( E" w2 |8 H+ a0 i - #include <linux/interrupt.h>0 X# o9 L% j# q* J* {/ B
- #include <asm/io.h>! e$ A1 N% c2 P! s9 p/ H
- #include <linux/moduleparam.h>! F' e6 s1 y5 ^; c
- #include <linux/sysctl.h>8 f; p, J8 N& s2 i+ V+ A
- #include <linux/mm.h>
. g/ a) |4 z: ~2 P+ E - #include <linux/dma-mapping.h>" M0 w1 o. _- C; b) [! j) G. G6 ` `
/ q8 ]0 _ q% i) g! G+ x1 P- #include <mach/memory.h>% d5 s/ r+ E* n; S8 D
- #include <mach/hardware.h>: }! W) S$ `: ?3 E2 {1 C
- #include <mach/irqs.h> P' y; f3 x. j% a* N) g& ~
- #include <asm/hardware/edma.h>
8 Z2 w' [8 @% d" L! t3 O5 B - 8 E: U7 X3 J0 g0 b
- #undef EDMA3_DEBUG
2 S7 C* @" W" H' L5 i: n - /*#define EDMA3_DEBUG*/
9 m; L. ]0 G. V, V: I' t
7 n1 ]9 V; u, n- #ifdef EDMA3_DEBUG
9 {% ^" X4 H+ B& r6 A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* Q7 i' o, `/ |" g8 N% _! ?" ^, s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 `1 }0 |, k4 d- T4 ?
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ A7 ]" V8 v2 R+ H) P% \ e/ Z - #else
' ^) I9 `9 E% P" Y. A* F - #define DMA_PRINTK( x... )
- t* m4 U3 x ~ - #define DMA_FN_IN
" O1 M. i; P/ r; N* b - #define DMA_FN_OUT
2 W, n1 o1 P; _" ~6 |, c - #endif. q" x* c, g- p8 Y' J
& Y# ~# F# K" }2 e& X- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ ]( m8 U, n- C9 a: U
- #define STATIC_SHIFT 3
" A; @. b. y5 ~/ [* R5 \+ k - #define TCINTEN_SHIFT 20
" I3 R) }) X' h - #define ITCINTEN_SHIFT 21* X- ?! \; e. o! j9 X
- #define TCCHEN_SHIFT 22
0 C0 \0 a9 L0 ]- O' a* N0 k - #define ITCCHEN_SHIFT 23- C) W% W, N% ?4 @/ u
- 5 m% q$ y- G9 g1 m
- static volatile int irqraised1 = 0;
3 w2 K* k/ Y5 d. G0 \6 O - static volatile int irqraised2 = 0;
4 d: w& O7 n- d& C& Z0 ]7 L! y - 1 Q2 o2 L0 c& U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 z) P2 N4 J8 P' Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! e# l; C7 P, J% w7 M& r - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 V& s8 i# q. }& K W
- ' \. O; Q& ^4 ?7 Z. U# h
- dma_addr_t dmaphyssrc1 = 0;: Q) _+ y3 p' r: _: o$ u6 r3 |
- dma_addr_t dmaphyssrc2 = 0;
' z1 S0 V5 I1 ]7 _$ C/ e9 [ - dma_addr_t dmaphysdest1 = 0;' K: E3 @$ x' h, v& N1 u
- dma_addr_t dmaphysdest2 = 0;
/ Y8 t& E L+ {8 Y% k3 E K
6 `# H' N. ?7 D% x, v- char *dmabufsrc1 = NULL;" V0 C* q& Q+ ? h) C9 h a
- char *dmabufsrc2 = NULL;
1 j w+ b5 N6 f' `# A" J - char *dmabufdest1 = NULL;
( g2 m; Z" _1 y, b - char *dmabufdest2 = NULL;5 i+ R" ^/ Y9 U5 w7 E. w
1 [( ~+ r8 b, z' K; g: U- static int acnt = 512;) K6 M% I4 j' u, A1 m) K% }
- static int bcnt = 8;
, X* }6 [$ J+ w% c' X - static int ccnt = 8;
# s3 x" d& X& D M# S8 R - 2 b1 f- I+ \( s( e- ]9 x7 ~
- module_param(acnt, int, S_IRUGO);
) X* X* R. [% w3 w' T - module_param(bcnt, int, S_IRUGO);
' n1 E# ]) d/ U% w' [. K - module_param(ccnt, int, S_IRUGO);
复制代码
0 q8 w4 W k4 c- n( V, n0 T! ]3 X- R4 J/ n+ A6 O5 y6 d, c- N
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
X# D: k1 Q3 K( M' E8 zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 ^+ i* s& A; ^. d9 {: V/ ~+ D7 J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" i f" E! W9 Z* m
6 I0 r1 Q/ ~' J# ?- x, H
5 s) {& u- F4 G% W- h |
|