|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; R' W$ Z" e" W% Z' P4 O' C* S
- [code]EDMA sample test application
/ C+ M9 M$ w# F u5 \! s - /*% l) @ X0 J" B3 `! U% ]: i! z6 K
- * edma_test.c
6 k1 J( ?. U! ~. Z" w - *# m: O& L$ A- B9 A
- * brief EDMA3 Test Application b. s4 u$ i8 D1 q& ?" q! S
- *& N0 i$ _' A# E9 c) I# ? D" o% O
- * This file contains EDMA3 Test code.
/ O$ b; Y" F/ h4 g' T. g8 @- ~ - *: O# }( K5 S0 I* N: |) \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ ^3 L2 _/ A; X. g L& f3 M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( D: i3 N% |3 [) D/ K. H
- * TO CHANGE.
" Z/ V7 i- p* b9 w& q1 q - *- h! i& i) Z: [2 b$ l/ t# ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. O$ P: @+ _/ U+ a8 j - */ l; D3 k* X2 t: S5 ~- ?0 f
- * This program is free software; you can redistribute it and/or
( {& ?& _5 U; i- ?" M8 O! p - * modify it under the terms of the GNU General Public License as
3 [+ C$ V3 h0 y8 m$ i - * published by the Free Software Foundation version 2.
9 \5 {- S# ]2 R/ Y* p2 E$ f) r1 a5 f/ T - *7 K* k1 T4 k2 c7 _ s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- |7 s: ?) o" T1 U: V0 k
- * kind, whether express or implied; without even the implied warranty
* ~# |1 i" E4 ~2 Z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) n. v" s/ N* Q! `0 K
- * GNU General Public License for more details.- v) p |7 T4 g v% c9 j3 [
- */
) ~# z% U+ M7 P1 T' I" J5 H2 j: h7 c - ; a$ H9 E" m( z
- #include <linux/module.h>
/ L- K t6 I- U% x% C* G' L - #include <linux/init.h>: K4 C8 o* h, h Q) d" d
- #include <linux/errno.h>" B: u5 y4 l) y3 O; x) c; a7 x d
- #include <linux/types.h>
% A* Z& ^, t( m. }" D5 E, v - #include <linux/interrupt.h>
! y6 n- ?# g2 k$ K% D( _/ }" E - #include <asm/io.h>
8 w! ~$ b3 }9 u, H* y3 T! Q - #include <linux/moduleparam.h>
7 p/ L" i9 f9 E8 O8 Y+ [, u: Z - #include <linux/sysctl.h>
4 z" Q7 u; B2 c4 R - #include <linux/mm.h>
4 ?: z1 g* k% O( n8 T - #include <linux/dma-mapping.h>9 x# F7 \) s% D$ r' \ T ^
- A; \8 X% Y4 N. e, c. A- #include <mach/memory.h>+ g8 u3 J2 ~% _5 ~; `
- #include <mach/hardware.h>' t0 O4 _! d H: `( v" H# Q
- #include <mach/irqs.h>
5 m S1 p, J7 d- W - #include <asm/hardware/edma.h>( a4 T$ S3 P* m$ v& Z8 s
# E4 y! p7 R4 i5 T! ~" W- #undef EDMA3_DEBUG
g0 k# |$ E0 i9 \6 A/ F4 ]" S* R - /*#define EDMA3_DEBUG*/
`5 H0 {) }& R1 a - + M1 K: I/ k/ A7 T
- #ifdef EDMA3_DEBUG
. G3 p6 Y7 ?: }& g) { - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 b! K6 t$ w- L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 h% a3 \9 Y- C: w# G: ?+ O
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
K" C. J6 ?. ], p) x% u4 l& y - #else1 ~8 _' }: Y* a' S3 s9 K! V. a
- #define DMA_PRINTK( x... )
) F1 c* N# W9 N: x* R$ [/ u - #define DMA_FN_IN) U4 b9 i* c& Y. O
- #define DMA_FN_OUT- X7 e/ H1 ]6 a2 R$ R
- #endif. v7 U8 @ V& X' h# |9 u
, G5 ?; H3 d! W- ^: f: O- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, _4 j; E5 v* W - #define STATIC_SHIFT 3' v% Z' ?9 i S
- #define TCINTEN_SHIFT 20
( ?; _# i1 w! j# }1 ~. ]! C' M/ p - #define ITCINTEN_SHIFT 21% z! M* F3 O. B/ K
- #define TCCHEN_SHIFT 229 h3 O) B' |8 z6 \( J8 \- i
- #define ITCCHEN_SHIFT 23
- m0 L* J- g1 I. Z% _5 c# |" W - 9 T" ~0 N# Q5 E6 [* w( e* c
- static volatile int irqraised1 = 0;
) @' H. k. M* d$ W0 v2 ~ - static volatile int irqraised2 = 0;
, L4 N" n5 P6 X1 W/ {3 ^
( C4 |) o/ Z5 S. Q! q0 e, M* r' Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. e$ M0 }8 e# e1 T; f3 B - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ n0 Q6 R& A* {# D5 ]! k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* z7 D0 O' ` C - 7 q1 x/ a# T6 L, \1 K. `" ~
- dma_addr_t dmaphyssrc1 = 0;, Z0 R0 G% l0 N8 O3 Z, X$ J
- dma_addr_t dmaphyssrc2 = 0;
2 D0 y. o# `4 W% K - dma_addr_t dmaphysdest1 = 0;: L) z0 i# S% U, d
- dma_addr_t dmaphysdest2 = 0;2 K# f- e- I; L, @
- + F# U8 d8 P' i3 o' f1 J$ m- d- F
- char *dmabufsrc1 = NULL;2 [$ A5 f! K \ z8 V0 C6 ?
- char *dmabufsrc2 = NULL;6 R- Z" v4 f9 o8 |
- char *dmabufdest1 = NULL;
+ h% x8 e5 ~9 m6 D/ x. c M1 i - char *dmabufdest2 = NULL;
( ] @6 ?: }$ K. ~# A) k6 \5 r - 7 ^; N' T; v, q5 h) I" |/ U
- static int acnt = 512;* R0 _, i7 l* K7 [% W
- static int bcnt = 8;
4 B j; O: ~9 l! w" @2 i - static int ccnt = 8;
8 T& S' s( u7 ]( k9 M) F0 U
! @1 {3 U9 e1 C9 _- module_param(acnt, int, S_IRUGO);- O6 m5 t/ G% s8 c1 c, B
- module_param(bcnt, int, S_IRUGO);$ w8 Q- Z+ t- L) R
- module_param(ccnt, int, S_IRUGO);
复制代码
# c9 }4 S1 n+ x, S6 s6 f/ s$ w8 i0 p2 ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ ~! z' @1 [0 l1 H
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# y! k. O1 m- W/ U! }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 r5 |/ Y1 `8 y! P6 e& ?& E
0 X$ p9 Q& z- q. R5 \* F
( H2 B5 S6 z5 h$ g. m |
|