|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / f( Z+ G. q3 f A/ z; S8 ~
- [code]EDMA sample test application
. W; T/ h$ V/ Z Q8 i9 p - /*
% H; r: E4 u% ?; p - * edma_test.c
. F, m' V1 |8 F6 h3 w- p; o - *
) O* D7 Y: l) _ ?4 w+ A7 y% d6 p - * brief EDMA3 Test Application$ ~# y6 y4 j" z! h$ Y6 L
- *; |( S# E' K2 J) T+ {! ~. q
- * This file contains EDMA3 Test code.7 @" D m r8 O$ G
- *
7 k; Q5 e6 T- e$ v4 ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- O' b% d- V) ]# j* J: k2 A& t& t6 g7 c - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' f+ `. j; Z0 k+ E: h8 W
- * TO CHANGE.
- R$ Q, \, [# i# S- W# C' b - *" `3 k& C4 H7 G4 ^ w- n# U* V Y0 g) w
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( z! E/ f" G3 M) w
- *
) l% @. Q1 l' D& T - * This program is free software; you can redistribute it and/or
# L9 M" H# [5 P - * modify it under the terms of the GNU General Public License as
4 x7 ?$ w& S% U0 V - * published by the Free Software Foundation version 2.
% H7 @. G5 L" j" T1 m9 o6 C. a - */ G( A" B; Y$ X% {$ I$ F
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 `/ ?2 L' e# P3 Y1 u: c
- * kind, whether express or implied; without even the implied warranty0 B. z" u' E. O1 B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* l3 x: @& {0 D B/ c% S - * GNU General Public License for more details.
# p5 u9 a( B5 T1 K. H5 R2 {2 K1 X9 D* _ - */. I1 W3 V: P! d9 A& U5 x' M8 ], Q9 G, U2 U
- ' i! T+ B8 [) A9 M Y8 l& p0 \
- #include <linux/module.h>/ i" A$ F% s. Z9 q8 c5 s( N
- #include <linux/init.h>$ I6 _! r- D) Z% \$ ~
- #include <linux/errno.h>
9 F' J/ u! J; m4 d0 ?5 u& J8 L - #include <linux/types.h>/ J2 q! V/ @1 a8 ?6 V
- #include <linux/interrupt.h>: n1 L1 L( [/ U% D9 W \6 m
- #include <asm/io.h>8 D4 n6 C1 d$ I Q) P+ \( a* m
- #include <linux/moduleparam.h>
; g9 O1 b8 j) q% u% i - #include <linux/sysctl.h>. Z7 H6 [. ?) q5 O B- q3 ~' i
- #include <linux/mm.h>
" j. ~2 f, `* r' j) Z/ o4 _ - #include <linux/dma-mapping.h>+ s6 y0 J- ? Q. {4 W9 {8 r+ L/ P) k
- . b+ u" B. w+ C1 _3 r# a
- #include <mach/memory.h>5 \- i/ b M' {7 }' N2 x
- #include <mach/hardware.h>
3 B: G9 @, y @7 ] - #include <mach/irqs.h>
# p, | P; o2 Y) o8 P - #include <asm/hardware/edma.h>- V3 V; r! z, v2 c; L+ j1 G0 k
- ; J! Y0 F$ m( M4 n7 X
- #undef EDMA3_DEBUG% H e( d/ @ a
- /*#define EDMA3_DEBUG*/
8 ~& c7 U Y; t8 {
( \ N: ~+ X: W7 P- #ifdef EDMA3_DEBUG! E5 @( w. X6 F, M' j( b( G' |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( c# {' ]! x* Z) K, o! G - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% {3 x* Q' Y$ M2 X, V+ e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 A7 f H* C5 e3 k* R, ]* z
- #else
! y5 J# B" M! ]* M* C, ? - #define DMA_PRINTK( x... )# m! ?3 y" v! d7 ?, `$ p
- #define DMA_FN_IN
! z% _5 V# ~9 o; y3 J - #define DMA_FN_OUT6 m k9 R0 N: \% ]( {
- #endif8 p' H( k& o8 s' P9 R
- _/ H5 U" S0 N6 v0 P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* ?+ Y. V3 M2 a, O6 E5 x+ x
- #define STATIC_SHIFT 3
0 D [) e$ F c: v' K5 @6 b* W - #define TCINTEN_SHIFT 20
# l9 C1 z( ?+ J0 s - #define ITCINTEN_SHIFT 213 j# T9 h+ @" r; [) V- ~6 b8 X2 H$ Y* u
- #define TCCHEN_SHIFT 22* k* R: D0 m1 d1 o) Y8 F* v5 r
- #define ITCCHEN_SHIFT 23
2 ^/ t* [! m: m2 s8 f# z1 T
! F- [( z0 ^; }3 \! x. q- static volatile int irqraised1 = 0;
" y- @" n x# g3 g - static volatile int irqraised2 = 0;/ c- Y# J t' V4 w4 j
- 4 X7 ^7 x4 A) \' J' b* ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& M- X. T+ h5 l+ e; Q; w2 i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 }# Y, y+ Y! |3 C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ ]' O* W& D, m8 O
6 c, J" p' R! Z O0 Y" x/ c- dma_addr_t dmaphyssrc1 = 0; |( h" e' u/ R2 Q9 }% ~0 V/ M
- dma_addr_t dmaphyssrc2 = 0;/ }8 d' W& t: d( L- e: x* H
- dma_addr_t dmaphysdest1 = 0;
3 G. l5 ]1 U( k0 f - dma_addr_t dmaphysdest2 = 0;- [( i! o" B0 q3 l0 t( a' j
- 2 Z/ i; p4 Z, v) p
- char *dmabufsrc1 = NULL;
) b2 E3 d0 |! \" L o s - char *dmabufsrc2 = NULL;
( [4 _6 _) E# k" V; v/ ^- ` - char *dmabufdest1 = NULL;& m D B& }6 \: P
- char *dmabufdest2 = NULL;5 ]+ R- ?( M+ P; [8 c( C' W
- , Z6 [3 N6 W) N2 i) W! @6 Q$ l
- static int acnt = 512;1 p% b. N" Q1 p _4 I1 V s
- static int bcnt = 8;
8 [6 ?, q6 W) ^' @. {0 p# c/ P - static int ccnt = 8;
4 n+ n% Q( h2 | - ) G4 M# X. u! X; o& e
- module_param(acnt, int, S_IRUGO); s' e: ?, [' _ h! [: M
- module_param(bcnt, int, S_IRUGO);/ j* g6 e R# E) c
- module_param(ccnt, int, S_IRUGO);
复制代码
1 B% v$ Y2 C: Y! A4 f2 L3 R2 ]' C! o% K0 n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. ]$ K* T0 R: U O+ n+ E9 {! Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 p7 y8 d" d& i 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 L( L% U$ s7 T* U
S- ~! L+ B4 |3 ]. r3 M5 D3 v' O+ t: L, S3 u( l2 M/ w! V
|
|