|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
p' {- F( y3 k/ ?$ b9 C0 ]8 A9 b% o- [code]EDMA sample test application
9 Q) s2 C1 {1 L( I' i5 P; ] - /*, i8 m, K4 Q" F7 K* }2 |- q
- * edma_test.c6 }/ b$ {' I. u) O& ]- A
- *. M8 @/ I6 _$ `3 E5 U, y3 t
- * brief EDMA3 Test Application
1 x& Z& P4 Z$ c. b( ^% {) `$ F v - *
) }$ G7 I& \4 A! H, X2 N: ]% U% z - * This file contains EDMA3 Test code./ r/ P$ D# ^2 A- i* a5 Z& \9 f
- *: I1 d2 C q/ e7 _7 j2 Q6 a' \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: i6 v! \0 ~3 p/ g3 p
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% h1 ]6 s( ~8 z% k; w) y0 B a
- * TO CHANGE.
% O$ a2 X* ^9 L. a - *
G# A0 ]" Q& k" N; O: @) l+ {2 [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 e& G5 v& _9 }2 V
- *
$ `) b' F8 K, ^' @1 e - * This program is free software; you can redistribute it and/or. K6 _, T2 X3 l2 B
- * modify it under the terms of the GNU General Public License as; E V, ?/ u9 X K
- * published by the Free Software Foundation version 2.
+ w8 F W" W3 V8 u - *
; }) x9 a6 `3 P& i1 X( P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( v5 G+ b- M$ ~) A d$ G2 A, E
- * kind, whether express or implied; without even the implied warranty
3 B6 M# j% {( l+ v - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& V3 ^0 ?) Q# Q
- * GNU General Public License for more details.
m1 h: E9 ?! u7 ^ \8 Z - */' i, E- ]* R# N5 j
- ' |/ u A0 y- k5 I6 {
- #include <linux/module.h> f7 P/ x2 D- ]$ p
- #include <linux/init.h>/ L0 z' i! a+ G: q6 N/ G! F
- #include <linux/errno.h>3 f5 l8 Q: f" M1 J2 G* r& D
- #include <linux/types.h>
) x& K. X4 z/ L1 j; M0 o - #include <linux/interrupt.h>
0 _: k+ J' ?( P ?2 r4 w - #include <asm/io.h>
) w% F5 g, Z. [: a; _) g( X - #include <linux/moduleparam.h>
9 K3 @7 p, i7 M( y H4 i0 }# l - #include <linux/sysctl.h>6 F, t; r: O$ T
- #include <linux/mm.h>. r/ }+ d1 _6 ?0 [. Z# Z6 C1 O
- #include <linux/dma-mapping.h>4 A9 g0 v: U* i* W# J B
- ; v, J4 c- N4 ]& o. o( Y0 c; {
- #include <mach/memory.h>& b- a- X- D1 ]( p0 @% \, K5 V
- #include <mach/hardware.h>
* ^0 [' T. p f% W) F; b! T! L9 y6 \ [ - #include <mach/irqs.h>
( s6 a1 L. j) Y- G* T2 q, G, T9 N+ ]: C - #include <asm/hardware/edma.h>7 X' N$ y+ N8 Q" x8 Z% u
- + z# y1 \/ E b- r5 d1 Y3 j
- #undef EDMA3_DEBUG5 Z% _0 }* a' X5 ?! A. P
- /*#define EDMA3_DEBUG*/: y0 M9 C, ^. z c: y2 n
; Q, Y8 x( ~# }, x% q4 j" ^- #ifdef EDMA3_DEBUG
- g# K4 O+ w% e! M' [: g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 K s' H# M) Z1 C( A" ]' b/ V2 @
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 J1 n/ v( m4 B& y T% C( t: R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ J- Y+ D+ N( s+ f7 G% ^" v8 B- @& e - #else5 k4 H/ c" T- z# u1 @( E- V
- #define DMA_PRINTK( x... )
% Z* D% J0 O# g* _) l, R! r- o - #define DMA_FN_IN
$ d4 E! d/ G. |. v3 z/ S$ s - #define DMA_FN_OUT# A* ^" y. X- i+ |. D& j
- #endif
" T6 _5 Y6 s2 {
4 H1 e2 a% u7 w% t" i/ K) q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' ^7 A# x& R, j7 H1 r* p - #define STATIC_SHIFT 3% Q& i2 V9 i# }1 Q* b0 G
- #define TCINTEN_SHIFT 20
! W1 H1 e# t2 q& M6 Y5 z - #define ITCINTEN_SHIFT 21& P o1 V$ F& V' b
- #define TCCHEN_SHIFT 22
& E5 ~/ Z2 @1 m* {, A- b - #define ITCCHEN_SHIFT 23$ @& I/ m4 z. e: X
- - i1 H4 C! s; ?* i
- static volatile int irqraised1 = 0;. ]+ f$ z( Y( I
- static volatile int irqraised2 = 0;
# f( J; a7 [( [% N" _ - - |* m0 j5 B) f/ g4 j" a, q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, s5 y! ?9 i9 M- | - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 N0 h/ a9 E- V! d% o# ?' E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) {& m4 w% M* |0 ~0 y1 e
: h4 Q2 p, r$ F/ _' ?2 |- dma_addr_t dmaphyssrc1 = 0;4 ]; C& R' ^# x2 s! u D- B2 @
- dma_addr_t dmaphyssrc2 = 0;
2 g% O! f, O4 I- p - dma_addr_t dmaphysdest1 = 0;& `9 E- D6 z5 Q# K, ~& z+ N
- dma_addr_t dmaphysdest2 = 0;
6 i8 N) |8 v3 s) S; r+ Y
. K6 K9 f1 y6 b" S" s- char *dmabufsrc1 = NULL;2 D" U) p) S+ X! b; R
- char *dmabufsrc2 = NULL;9 l0 p. _9 H4 O, Z
- char *dmabufdest1 = NULL;, s/ u7 b% B- r$ |0 f! W U2 y* M
- char *dmabufdest2 = NULL; G$ n2 A1 o1 ^ i) l: N
- ' D6 A( q9 j' N2 v. j* H0 Y: [
- static int acnt = 512;, F" o9 ]+ c0 }% o
- static int bcnt = 8;' g1 E; x* ?+ B' G0 q9 }! x% E
- static int ccnt = 8;" P" u8 s% b U$ a9 `; ^8 @
- 6 t' o6 d6 l: c
- module_param(acnt, int, S_IRUGO);
' U* x Z) A; N) f - module_param(bcnt, int, S_IRUGO);
4 t+ l3 d7 X. Z0 T( f/ t - module_param(ccnt, int, S_IRUGO);
复制代码 # c3 v7 `0 |& b% ^7 y! e
$ y- Y& Q" @0 r3 P' D- J% D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& m9 O$ x: |; ?. b3 V, D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ S0 y; K7 F; T; G" u( ^8 u
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ V- f) F! h) \6 Y8 ]
$ ~4 z+ n( h) k
. i* P# W# W4 l4 Y) h* E
|
|