|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , W1 @: m/ W+ G% U( v- v, `
- [code]EDMA sample test application
: w* ]; ^! b7 r - /*' @/ d2 b- r) G
- * edma_test.c
" T0 J" O$ a# y9 R. l. S - *
) [5 V& ?. \4 ~+ f - * brief EDMA3 Test Application7 l5 Y }+ x- a% |# O) ~1 R( K
- *
; a( n" x7 ~0 L& S/ N: V - * This file contains EDMA3 Test code.
) y& T3 c- o! b0 }9 y - *
. X2 b1 i* v: k9 Q0 i - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" c( h+ Z# d; ~& H - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( B9 n$ l' j F# J3 B
- * TO CHANGE.8 s! k( a) m. a3 k. }: V/ K
- *0 }- O% f1 T: D1 r, W& A+ X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 f7 M+ j0 f! V2 w. u - *7 V* w$ W6 H0 @& S& |- t# i1 Y! }
- * This program is free software; you can redistribute it and/or5 H+ y4 t3 J: q
- * modify it under the terms of the GNU General Public License as k8 ~4 i( f. s" \2 d0 Z
- * published by the Free Software Foundation version 2.
' o- i2 x. u. k( t1 c; W - *8 ?) @& @5 q; ^/ _" _0 e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 }7 [2 ?( b% J$ ^
- * kind, whether express or implied; without even the implied warranty" z* R2 e' e3 |8 @6 N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) z [3 O) ?+ ~/ H* E3 e+ I- Z( k9 ~ - * GNU General Public License for more details.
8 U8 ?+ i. u$ F6 @ - */
: l6 ~* B+ ?/ p/ Q$ i; k! T
3 l0 a# D1 b5 l: O" d+ ]: h9 }1 ~- #include <linux/module.h>
- W ^. n8 n# x+ e5 [ - #include <linux/init.h>3 C- H7 B1 X1 L, P$ Q+ B" G7 q
- #include <linux/errno.h>
" [4 p6 U# V4 ?4 @ - #include <linux/types.h>! z& K" H \( A# h6 G0 r. Q
- #include <linux/interrupt.h>
" ~1 Q: G- `; \6 r- A% c - #include <asm/io.h>1 ]+ x. {- C- B# g) z3 ^
- #include <linux/moduleparam.h>
6 Z. \; y2 F' `5 X7 d1 ?0 i6 n - #include <linux/sysctl.h>: d c+ o7 e2 }6 A4 B* |2 m# ^1 M
- #include <linux/mm.h>
% N5 O: ~1 C" Q9 q1 m# @" H - #include <linux/dma-mapping.h>: T2 ~2 K% Z6 V0 Q
- % E- k4 j3 A" g# g
- #include <mach/memory.h>
! }, D- m; h' _! B3 P - #include <mach/hardware.h>
- \2 u7 C3 L3 F - #include <mach/irqs.h>% o9 d8 l! S( N6 m+ d8 L0 _
- #include <asm/hardware/edma.h>
) u& }- U7 s9 m; L8 W
; A3 w. q, u, v" p1 r- E- #undef EDMA3_DEBUG
& z0 y5 d* _" x; v& M; m - /*#define EDMA3_DEBUG*/
$ a0 Q& x L8 y# T
# |+ X5 n5 I3 O) I8 s- X! ]" r9 @- #ifdef EDMA3_DEBUG, J' y5 d5 k3 j! I
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 T, S* C0 W; g# Q! @; t: C
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( [! _* h) h0 p2 R* S! j# A+ N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- R5 L! d& E( Y7 r
- #else
) S% s4 g0 F' j) g9 z7 t+ W# d - #define DMA_PRINTK( x... )! [1 `8 Z+ X+ L/ }+ }) U
- #define DMA_FN_IN
! j. f+ i9 p2 M. R } - #define DMA_FN_OUT
5 J# F$ i; Y& f) K3 m) e% A& y - #endif
: q3 F& E: h4 k, } - # v0 u9 D( b* \4 r- | z( y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; V0 Y% S1 ~6 v - #define STATIC_SHIFT 3
9 y/ O& }, ~% ?: N& a - #define TCINTEN_SHIFT 20
; U& M/ V5 Y8 \ - #define ITCINTEN_SHIFT 21
8 ?6 |( K% f" ~$ N g m - #define TCCHEN_SHIFT 228 p e- m# e1 f: U9 B- S
- #define ITCCHEN_SHIFT 23! Z4 Z, _% q: O& _
- % q. w0 H% F- u( T6 V7 @
- static volatile int irqraised1 = 0;7 p x% w) j* u: G1 V) f
- static volatile int irqraised2 = 0;
4 B# }9 Z# I% K( a9 ?3 t% {( K$ H' q - 9 }( Z9 |' v+ D# [* Z6 h/ O
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% F( Q& R9 g% {
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 @- [: B: `% V; c& P! Y7 v' V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( |. J+ E( n3 Z1 w5 D
- 3 p; R$ P& z0 a
- dma_addr_t dmaphyssrc1 = 0;
; ]- O Q" J! q; V! q - dma_addr_t dmaphyssrc2 = 0;
$ b" E" P! f3 ^0 q' }# z - dma_addr_t dmaphysdest1 = 0;5 \# G3 k( Q( v6 n, K
- dma_addr_t dmaphysdest2 = 0;
! J, k" g4 K$ s8 c8 ]1 Q0 Y - 7 f2 W; l5 i: g; N4 |7 n# W, T3 ?; @% C
- char *dmabufsrc1 = NULL;* F9 p) q7 }2 Z' y z
- char *dmabufsrc2 = NULL;
0 F1 b* e! P) Q, h4 ?5 n3 K - char *dmabufdest1 = NULL;6 T5 ~( ]' ^0 U) y) S) A8 G
- char *dmabufdest2 = NULL;
0 }* L3 x$ A% T - : H" c7 X7 I s& t1 ~4 u k+ K
- static int acnt = 512;6 Y% t8 W) b7 G! @; J, _
- static int bcnt = 8;
9 G) f* m. s* X, f1 K+ `/ U - static int ccnt = 8;2 H4 E& U0 M: D
- , _* F% D @) m6 K4 S2 r4 N
- module_param(acnt, int, S_IRUGO);
7 l1 `# M$ _0 B# D3 P; d - module_param(bcnt, int, S_IRUGO);3 b. F, b3 G+ D! I- I; ?
- module_param(ccnt, int, S_IRUGO);
复制代码 6 b. E2 u" m& {% P% ^7 G
! P( q: s0 A: M- ^# T- G: @& s 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' z/ o8 b# Z% j o& q$ ~! t4 Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 a+ _ U" s0 W$ d
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; O( F4 B& c% S w+ {
6 x! ]! y1 ^7 `! ~
% i4 I3 F0 D( s) R7 g/ e |
|