|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( [$ \2 s% Q7 J' y- [code]EDMA sample test application
6 N; N+ X0 q7 e& ` - /*
- q0 ^, a4 f( x4 ~. z6 j& p: U - * edma_test.c
9 @% \$ I! @5 e/ h6 c( U# \! L - *; u8 h# }6 [* e8 C2 G& ^& o
- * brief EDMA3 Test Application
* h V1 z, g( g1 [+ ]) m" V/ r - *
: q; `5 N! L( R/ W( r+ s+ x- F - * This file contains EDMA3 Test code.( J: A& a3 w# X) s
- *
" A$ ?% E0 m& h' @. |; ~: Y" k" D - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; E5 R& F2 S5 R1 D$ ?5 F/ t9 D$ M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" S+ @( h" R8 y0 S6 [
- * TO CHANGE.
: v" z5 k9 s3 { - *
% }6 o: h: K# g" i; p8 l9 K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( ^; A1 ` [& C( s" t
- *. l% a$ [! T- V
- * This program is free software; you can redistribute it and/or
% \6 A. N- ]) @. V - * modify it under the terms of the GNU General Public License as9 ]7 x R4 F. a/ l8 O9 o- k# p `5 p% Q
- * published by the Free Software Foundation version 2.
- t; P# |4 x+ \& j" T - *5 l7 K$ u' p X' x
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: v# y# m: O# r - * kind, whether express or implied; without even the implied warranty
& { Z3 d- }& Q4 y; _+ c - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 q6 T; \4 M, [, a" @7 y
- * GNU General Public License for more details.
7 V# ?% e/ |" v- p - */ P* U" m+ ]) K, S- z' f
- - m- b/ G) p5 n: F; |
- #include <linux/module.h>
% T' y/ }( E1 C0 i& E2 s6 s& d$ S. @ - #include <linux/init.h>/ z. q2 P3 U1 h: y. z
- #include <linux/errno.h>/ |/ e6 B9 P+ X1 n1 z
- #include <linux/types.h>& {$ X2 d; C v/ ]
- #include <linux/interrupt.h>5 X) l6 K( `0 M- V/ S0 Q, L
- #include <asm/io.h>/ p) ^% D) R( Q; y4 F; L5 h0 z
- #include <linux/moduleparam.h>5 G' x+ C8 s! l8 N
- #include <linux/sysctl.h>
/ w8 ^! T, ]+ r4 o - #include <linux/mm.h>: d, z$ W7 R: S8 ^
- #include <linux/dma-mapping.h>9 }/ H$ ?7 ]5 S L
- 2 S6 I* L& ~/ h! t1 n9 o4 p8 a
- #include <mach/memory.h>
' F% z1 N8 u7 F- D/ @% N2 p# ~ - #include <mach/hardware.h>; k5 Z* L. r D) B; N9 t1 I& f
- #include <mach/irqs.h>
/ ^! M; g( @" C- R5 w# {6 r; W - #include <asm/hardware/edma.h>
% I# W! E1 O+ l$ g - 0 u9 u& [7 K: r
- #undef EDMA3_DEBUG
- E8 ], F2 K% L9 { - /*#define EDMA3_DEBUG*/
" F$ O1 o6 ^% n, m4 g7 F& \9 z - ! J" V6 i' X% D" Q _
- #ifdef EDMA3_DEBUG5 S# m& G6 e" D o& A" u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); M+ J: \2 U% p
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 j7 T& F: u- [4 P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 f7 \7 K. k4 z; S' Y - #else% e& l/ V# [" T4 p/ ]& }: ~( C
- #define DMA_PRINTK( x... )
. ^1 P2 A# A) @2 w& K3 p5 I( O6 M - #define DMA_FN_IN
' I$ X0 D' E$ p8 C @$ j7 y - #define DMA_FN_OUT
3 L' ~1 D- s y, t* ] - #endif
! H7 n) ^0 e/ {+ D - 1 G: C3 ]8 _2 E. W2 O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 X0 J7 o$ F* g% \. R
- #define STATIC_SHIFT 3% o6 V0 O# Q: H) h. I8 y$ ]
- #define TCINTEN_SHIFT 20
+ M# z: f- |. g; E3 G, A& ` - #define ITCINTEN_SHIFT 216 u! E/ W; `5 g4 w6 A
- #define TCCHEN_SHIFT 22
3 z4 I% j! t3 I- Y - #define ITCCHEN_SHIFT 23
6 w# v9 I( ?; j# { - ; I. _/ Z3 P( p! Z+ ~$ Z
- static volatile int irqraised1 = 0;" \5 Z+ h% G5 C% j1 N
- static volatile int irqraised2 = 0;0 A( c% k. f- g% F" H) r$ ~
7 k& Z; d1 Y1 o: n8 r5 P: W( U4 h: [- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; H% F( f. P% J& U/ H0 _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- {, G5 |. \& c* a+ j! o - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- ?0 o4 v n) n0 |0 j- A1 X
. r: b; @$ ?; G7 w% m! a/ k6 M9 S- dma_addr_t dmaphyssrc1 = 0;
' L" F3 r, M5 b - dma_addr_t dmaphyssrc2 = 0;
4 U, w! F/ U, o6 o: S: ? - dma_addr_t dmaphysdest1 = 0;, m4 x) G/ W' Q8 [) z' ?
- dma_addr_t dmaphysdest2 = 0; f2 v" A/ R" R( x
1 O. v% I( A8 J f6 h- char *dmabufsrc1 = NULL;
, p7 }5 u4 C8 Y - char *dmabufsrc2 = NULL;
8 f1 p& p% l" j+ h% E$ g5 r - char *dmabufdest1 = NULL;
& h# S: h) M/ E - char *dmabufdest2 = NULL;- M; R: c5 g, e
) I2 ]* D7 G3 Z. K7 e! M- static int acnt = 512;! }: Z( R# N' E/ R) d) F8 I! t
- static int bcnt = 8;7 ?$ P { p" H: C- q- Z
- static int ccnt = 8;' _* S M! m# b5 t
/ t# W! X7 E* O1 F0 x& k X# Z$ {+ ^- module_param(acnt, int, S_IRUGO);5 K6 T3 ^5 Z8 c: n
- module_param(bcnt, int, S_IRUGO);- |! G' r0 E! F+ s: f
- module_param(ccnt, int, S_IRUGO);
复制代码
: z9 v3 {& Z) V u
* J3 _7 G; i( V) z# {' Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 b) O' o% D& D B0 H/ Y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* Z+ N4 q: l' E- _/ r2 }& O; T& ?" s
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 [5 e$ n( a- Y7 x/ b
' V9 V8 t7 k. w; g+ A r- a) l9 J; [
2 O2 c% E" G+ n! X: u" G
|
|