|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 z$ A' f/ e6 i1 R2 Z8 X- [code]EDMA sample test application& I b- i( j8 X) C p
- /* K5 O8 ^% Q1 c6 ~) U/ p: l) P: n
- * edma_test.c
4 v0 d6 r2 X. v: E; Q+ P - *
1 j3 ?% U/ ~" f+ `# M" {+ E* @4 V - * brief EDMA3 Test Application. q- r- M4 r9 a( R$ Z% Q0 N3 j
- *0 M; h+ T% d5 X% m5 s, @9 X# K
- * This file contains EDMA3 Test code.6 a2 I1 C. P/ \1 \% V
- *
; _ y+ c4 u: w/ {$ Z6 e# v - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ f6 Y& L' ~$ k; g7 d( n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ Q) m6 u ^6 } X- u6 W8 f7 t- l7 t3 K - * TO CHANGE.. b N# M. Z1 A7 v2 O
- *
- ^: E4 @( Z% j# }( T. x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 _" t: x6 M1 D9 m0 O3 O' c7 a0 N - *
: ~2 g; h. v f+ b - * This program is free software; you can redistribute it and/or! I4 k& z* x# x3 @1 H; H
- * modify it under the terms of the GNU General Public License as& q) Z0 r9 G6 @
- * published by the Free Software Foundation version 2." g) n, {, [" L1 m3 c' u, p
- *. ^) U1 S1 M" I4 i7 [+ {) a% Y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any# e' [* i. z* e6 W1 v' r8 A
- * kind, whether express or implied; without even the implied warranty
8 P7 ~) h7 Y/ _4 d/ F/ A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' i! Y# Z" S" j# C7 t
- * GNU General Public License for more details.
' R+ @4 k! |9 t$ F$ G3 q - */# A0 `1 v$ x; q
- 7 h$ U8 X: a6 @5 @- e+ L6 e+ V" F, A" X
- #include <linux/module.h>
# Q8 H0 v8 \( y# H9 |3 y8 i - #include <linux/init.h>) f$ B! D1 R) L. n
- #include <linux/errno.h>& j7 |- x+ `& {1 ^+ }; ~ ]
- #include <linux/types.h>+ I6 ^$ F( d8 A$ H c: _! }
- #include <linux/interrupt.h>
$ Q' ^) i3 h7 X$ i$ ^ - #include <asm/io.h>, P! A& A A5 M$ c0 s# H
- #include <linux/moduleparam.h>
5 O/ y' N, w+ ^2 b) X4 l - #include <linux/sysctl.h>
/ H- y/ L2 ^$ J+ B, F - #include <linux/mm.h>
: R0 A0 A; d" }, K& ? - #include <linux/dma-mapping.h>
0 s5 b7 {2 Q+ \2 O2 o# Y9 U
. N( ^" R4 V/ U& O# n% f, o0 H0 v- #include <mach/memory.h>* j; q. ]6 C1 i0 A: i/ }4 g* q/ O$ ?7 U) q0 \
- #include <mach/hardware.h>
" B* e) J% \9 }; p8 p5 ^0 W - #include <mach/irqs.h># ^# i! ^ r$ p
- #include <asm/hardware/edma.h>
7 F5 Z( Q, u" h. q, H+ W - 0 J1 y- U& Z! V7 f8 e! n3 s
- #undef EDMA3_DEBUG7 F+ M! L( H9 I3 w( f8 D9 E
- /*#define EDMA3_DEBUG*/ | v0 r8 Y2 _& b7 z
- 3 S/ W$ |" @/ V9 F4 W0 T! _
- #ifdef EDMA3_DEBUG
& v U5 l. d; i8 W/ | - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& b3 H4 F. C2 J2 ~) S: X - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 C. N. i) s0 q( J9 |" U' c2 `
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* x* V x+ B3 A1 i# ~. ~! b - #else3 G- X& n2 f1 b; M: N; @
- #define DMA_PRINTK( x... )' r' w7 C r$ w- p# U
- #define DMA_FN_IN
. E' e/ n1 @- J. A2 u - #define DMA_FN_OUT
3 y% i$ {1 S( E' o/ `8 q- ]0 m - #endif% x5 o( @: J% W! W0 z+ P' x( W
- % G/ q' |! g2 o9 H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ Y& r& ^$ ?) e6 H
- #define STATIC_SHIFT 3
- C* m6 i: }* [* d& _( ?& _! H - #define TCINTEN_SHIFT 20 b3 h% T' k" ~
- #define ITCINTEN_SHIFT 21
# K/ S% J7 ]0 H, {0 d# i: e" y2 V0 B - #define TCCHEN_SHIFT 22+ F: f$ u- b3 x) o
- #define ITCCHEN_SHIFT 23) a' G2 q4 c5 F& ~' g9 @5 k$ q2 R! H
" `7 k3 e0 L+ q3 T8 Z2 Y- static volatile int irqraised1 = 0;! s! R L5 U' F/ u4 g! F
- static volatile int irqraised2 = 0;5 k2 r2 j6 R, ~3 `% z" W) l+ v2 `
( X* Z/ v0 N+ }0 @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); c" y) ?* ]/ c3 z2 O) x5 ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# x% o: V' m7 c" T6 Z X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- G) N! \7 \/ C$ ? - / l& j& p6 G- W% p" Q* e8 t
- dma_addr_t dmaphyssrc1 = 0;( F9 L0 d! s# D Y8 ^6 h
- dma_addr_t dmaphyssrc2 = 0;; A6 Y" }' L! M/ q* G$ G0 `
- dma_addr_t dmaphysdest1 = 0;
3 H9 I! p" Z2 W& ~ w! | - dma_addr_t dmaphysdest2 = 0;
% V" d0 M4 Z* L' ?6 A& b& G8 F# N
" c: D# D& o% o- char *dmabufsrc1 = NULL;
5 t2 S& h" l1 r2 D+ H+ ~2 F3 Z - char *dmabufsrc2 = NULL;, r5 p8 {3 J) R% Z1 ?% g
- char *dmabufdest1 = NULL;
# `* M4 C0 A" r/ s1 r - char *dmabufdest2 = NULL;
' E' v* G5 \, \. N$ N s
* U/ H0 q+ X; J$ _; n+ n, B- q- static int acnt = 512;
1 V2 a/ F) D' q" x - static int bcnt = 8;$ N) S! H. b2 _7 H8 L
- static int ccnt = 8;3 n( b \; y' K" _7 X
y* r; K% J" r% V' a) h/ F- module_param(acnt, int, S_IRUGO);; u1 H4 G" R' `: S# {6 O( V
- module_param(bcnt, int, S_IRUGO);$ h5 L# Z/ u6 }% _$ p0 o: ^9 k
- module_param(ccnt, int, S_IRUGO);
复制代码
6 }/ I' T6 L, x. Y$ e; e
& n6 ^$ s. u! |4 b) ` 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& i. D) v2 V3 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ g2 f0 |' N6 {: R2 W
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) @5 \9 N" g X) G2 f( v
$ @7 R' P4 C* u8 D5 y9 U+ ~" p x: m4 f2 K0 b9 G, |
|
|