|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 N" \6 h; |; ^- [code]EDMA sample test application% @' O& A6 I7 P" n0 K
- /*, q) [" G$ ?0 i* u
- * edma_test.c
$ v1 h+ C |" z& l$ m' }6 ]' A - *
0 g9 f1 H# j Y& P; { - * brief EDMA3 Test Application8 \# s( [% z0 h, Y# D# f# y
- *) ^' Q6 W7 a9 K& P% r
- * This file contains EDMA3 Test code.
0 K; T! \3 ]/ }# s1 O6 l - *
1 q# g% {8 _- L$ O' `# @; z- L6 u - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
; {+ Z, f9 U' a, g9 }, T9 F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( i- o0 m8 D/ @
- * TO CHANGE.
' V8 Z% D4 t5 ^& K - *. _8 s V" N1 A/ N! j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* a5 Y: \3 s t) V
- *: [) Q- [; P( b3 B& Z6 v7 H) a
- * This program is free software; you can redistribute it and/or
# h9 K. [4 x% M1 b `6 O* z I1 s - * modify it under the terms of the GNU General Public License as
. @. b/ a# K" h' |+ r7 `" H9 [4 b3 k - * published by the Free Software Foundation version 2.
/ H4 e& Z" A; q/ M' M5 P - *
& \5 j+ E- m) {/ ^- X' L: H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) a. F3 }5 c7 b) d, K; u, C5 ` - * kind, whether express or implied; without even the implied warranty1 T4 c* m/ W' i; J* l+ e; e7 F
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ w# B: e3 H) Z! A+ Q/ E - * GNU General Public License for more details.
( @. F8 V( ^5 u* t) V - */
* v* ^0 p1 d6 } - ' |3 k) l5 u" C- C( l
- #include <linux/module.h>
1 k' L. f% S0 w& U2 ` - #include <linux/init.h>
; b! q! u: j$ x: c& M, X - #include <linux/errno.h>
. ^- _5 }2 ^6 D; [% P4 O - #include <linux/types.h>
, ?$ d" o! Q7 L% X- w( v1 A - #include <linux/interrupt.h>
' n9 \( e* T' h9 N- f* q - #include <asm/io.h>/ R& Q) H7 P& I* V
- #include <linux/moduleparam.h>8 F4 L: N& z8 t3 S _
- #include <linux/sysctl.h>: n! y+ d( [9 M4 T
- #include <linux/mm.h>
0 ]2 [; j$ H5 P( K - #include <linux/dma-mapping.h>
8 K; C2 v0 W+ D( a6 C: L8 t& Y - ( I- V3 K2 M$ X: D' x$ Q- L9 r B$ T
- #include <mach/memory.h>; ?+ V. d" _) |3 l) D
- #include <mach/hardware.h>
- c2 D. Z9 c* O- s9 n( B7 d - #include <mach/irqs.h>! d5 y* _9 R& G( w
- #include <asm/hardware/edma.h>' h, g7 W: f9 M L% `0 |* S
- # c0 [* K2 f2 h$ s1 Z; M+ r7 d
- #undef EDMA3_DEBUG
+ M# A6 i# ^$ X* `/ I* k - /*#define EDMA3_DEBUG*/+ w* Y6 v# D" f( D' y
- + x3 z& J9 d5 n" ]
- #ifdef EDMA3_DEBUG I4 C0 ]0 @; D; |7 b& u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% k" _! W: J$ J( t9 K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* L1 p3 P# Q8 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( j. L3 }6 `4 u" y5 i7 J- n& D' b; r! [ - #else& j* M* X; }) @, `5 w. w# g8 T
- #define DMA_PRINTK( x... )
6 ]# @* d4 r, b9 y; b, { - #define DMA_FN_IN8 p2 A+ G J7 O+ B+ U6 \9 A3 F. A
- #define DMA_FN_OUT3 Z! h ]/ p/ F& c/ G
- #endif2 _. O! F. a. {* W0 A
- . o8 ~. H+ h. L m+ `
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) {0 z% }1 x* Z' n) R
- #define STATIC_SHIFT 3
* b7 A+ s' G* ?4 W/ M2 ? - #define TCINTEN_SHIFT 20' }4 d" Q& l8 b* Q
- #define ITCINTEN_SHIFT 21
2 w* r) [" [% ?# B; Z& w - #define TCCHEN_SHIFT 22: I1 a i* I+ M/ ~, i9 Q. E
- #define ITCCHEN_SHIFT 239 T" a. v" z' ?. Z
- 2 r V1 h7 F) S5 i! z6 M" @
- static volatile int irqraised1 = 0;
$ }4 R6 l& P) }1 S0 N/ K - static volatile int irqraised2 = 0;$ x- P, H1 r$ W* m# G$ J
& d' J+ B% S& \* ?) g- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ S$ H* B1 y6 x6 N) G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% `/ T0 \, H( w( X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ Q0 O S5 {/ R
- 3 M; g. I( r4 D7 Y
- dma_addr_t dmaphyssrc1 = 0;
9 V" G3 ^& K3 K: | - dma_addr_t dmaphyssrc2 = 0;; H! M6 t0 u4 ^% L1 p* B# c
- dma_addr_t dmaphysdest1 = 0;. h+ ?8 |& D1 R8 x
- dma_addr_t dmaphysdest2 = 0; q5 c. f5 [$ n
- 1 _: a0 H3 S1 R) |. g ?2 L8 K
- char *dmabufsrc1 = NULL;! V, A( I, Q4 {
- char *dmabufsrc2 = NULL;5 g* i2 u0 _" @) S5 u
- char *dmabufdest1 = NULL;
% W- W8 l" X# s3 D- g/ y3 M' q. ?4 \' t( F - char *dmabufdest2 = NULL;/ S+ {* ~; F# i6 ?( s K1 W& [9 g2 L
- % J, z5 R8 v" ?3 r1 O' X
- static int acnt = 512;4 w( ^) A' H5 g+ r
- static int bcnt = 8;
: X9 v) P% J( i1 f ^* J$ I y - static int ccnt = 8;1 p, T' U2 R3 |+ N% F
% \0 z) [' o5 K- module_param(acnt, int, S_IRUGO);/ u+ I: D8 f5 y3 Z6 F
- module_param(bcnt, int, S_IRUGO);) E# P. S% D2 K U$ i& F
- module_param(ccnt, int, S_IRUGO);
复制代码 6 N4 _# w& M5 w K* ^1 }# C
' H5 I$ P5 s# T1 x: [3 W2 {+ `) g! c8 N/ a8 J
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: o1 _6 e7 J# |! n* xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ L9 U" `! w* i. {; Y: Z! W& I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 w3 p2 L: h% k7 i
# b3 s6 \0 k7 ?+ k' S- T2 [+ f: L! q
|
|