|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! r9 H# ~2 \+ `7 M) z0 P1 _2 F
- [code]EDMA sample test application) F- P- {/ S. s/ \6 x6 M: p
- /*# ~6 H, e. A( `
- * edma_test.c% ~$ C/ O0 B3 p- z8 R
- *
. v0 p6 |: ^7 w - * brief EDMA3 Test Application6 I- G- R s% f9 h% P0 {3 f
- *
8 {) c4 Y0 }. ^0 H+ T1 D& G - * This file contains EDMA3 Test code.
0 S4 E* g/ L! y; z, L* v - *
. B& U2 C4 e! r/ v! B) y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& t/ M4 R% P/ v) r$ K - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, T" K# _* a2 n9 @& w0 W5 G8 i! o1 j - * TO CHANGE.0 t. ?% f( }! K3 ?+ Z+ j& z) r
- *
( R: d( |6 `* _8 J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 p! K {8 p% n, Q
- *
- f* R( y X0 _ H2 }0 T( G! U {; R+ ? - * This program is free software; you can redistribute it and/or T* j5 q( y+ H/ G' H4 t
- * modify it under the terms of the GNU General Public License as" K: S: w( v! @0 A6 c
- * published by the Free Software Foundation version 2./ w& d- r6 @2 D/ W' y
- *) ~. U* X& G# A: l, q. l
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: I+ \4 F# ?+ d: R" `3 f3 ?
- * kind, whether express or implied; without even the implied warranty" v( c+ R! l. `+ P4 K) j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the a9 T. d1 ~9 ` ^+ p0 m( g
- * GNU General Public License for more details.& \6 o" U1 a8 m7 P+ \% D
- */: G/ a/ g; q3 h9 k
- ) w. P% c0 D/ P7 r
- #include <linux/module.h>( ~1 b% M; ~& d2 v: W1 x
- #include <linux/init.h>
+ i1 H# _9 r* C5 n G% ? - #include <linux/errno.h>
0 k/ P9 T1 s5 O - #include <linux/types.h>
9 Y; D+ o/ f6 U# Z6 s - #include <linux/interrupt.h>2 ]; o# W5 U T* X6 A8 a3 i
- #include <asm/io.h>
: u, f8 _2 Z; F2 G& s4 B7 _& N6 O - #include <linux/moduleparam.h> I( s# Q- j. h5 Z% v, F
- #include <linux/sysctl.h>' g0 g+ |& _8 t: q& [$ Z% H5 n
- #include <linux/mm.h>: o6 q/ ^; q/ N/ ?, S, }! E
- #include <linux/dma-mapping.h>& c: c8 N# |3 m$ @4 \: F
- ' ^/ B& `2 @! G& s ~8 i# e' m
- #include <mach/memory.h>
* |; L" q) j: M' Y - #include <mach/hardware.h>
! o9 l) g4 P1 V/ s3 [ - #include <mach/irqs.h>5 d# q; Y* D% G* x
- #include <asm/hardware/edma.h>
; H4 D/ E$ p2 p! J, u
) a M8 [2 T4 j) d: U' U- #undef EDMA3_DEBUG
' |$ @+ s0 ]+ \3 J0 ? - /*#define EDMA3_DEBUG*/
1 a3 M. n0 u( d - & n2 L1 |0 F, _) H8 x
- #ifdef EDMA3_DEBUG
5 R4 B0 L Z% n! l) `0 `* W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), t. x# q) K1 H
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), f" r( I; L5 y' k2 `4 C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) ^: T% w) R* ?2 P$ |
- #else
' Q/ N3 z6 E+ [3 }/ B' s1 W4 f - #define DMA_PRINTK( x... )
2 B0 j D; Y9 v - #define DMA_FN_IN6 f$ a6 M1 p4 X/ l: |# w' C: _8 w
- #define DMA_FN_OUT- D% u/ H: U2 } r$ K( j) H- Q
- #endif7 ~3 D! p$ m1 _5 G4 c
6 h! m( }) d# k @% U. s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, C5 y/ l5 X0 j6 m+ O - #define STATIC_SHIFT 3, E+ r: X8 p1 H- q3 o: [8 b! _2 I
- #define TCINTEN_SHIFT 20
- f3 H$ r- N9 x7 d. b - #define ITCINTEN_SHIFT 215 K' K! `9 d G! Z
- #define TCCHEN_SHIFT 22
2 t2 F/ Y$ L; r& A - #define ITCCHEN_SHIFT 23
) a% m N# n U5 l
, w( j: q/ F3 v% L6 k! H- static volatile int irqraised1 = 0;
( s, x& `" j, ]6 ^0 t' q - static volatile int irqraised2 = 0;7 p& D, E) `& C" o# ^
- 8 x. r5 y/ _7 b9 [0 H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& w/ C7 M) o+ K# j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; ^0 t$ |0 P) | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 k; v) b% ]( a x$ D+ v$ r5 m - $ ^) L2 D) X: B: q( O2 C0 _
- dma_addr_t dmaphyssrc1 = 0;; L6 f/ O) W( n: e6 ^
- dma_addr_t dmaphyssrc2 = 0;
' [3 j3 _+ _9 f& t& L% K6 z - dma_addr_t dmaphysdest1 = 0;
! e! ]2 L- p8 e8 O - dma_addr_t dmaphysdest2 = 0;
2 n M' e8 j; P8 z
; c! e" E( X# G1 M/ o! |, n- char *dmabufsrc1 = NULL;, f( z5 o* Q8 n( `" F# j6 p, B
- char *dmabufsrc2 = NULL;0 n8 U+ X' P$ j" t# m* C
- char *dmabufdest1 = NULL;
# P& m9 J0 L* Q" T- X - char *dmabufdest2 = NULL;* t* [4 j) _ m
- : W* v- U6 M* N
- static int acnt = 512;
% O$ L. c: A$ _ - static int bcnt = 8;
" E0 x0 E O6 Q! U8 f - static int ccnt = 8;
: a9 q7 p/ l% K- \
# }+ B- z2 l* g8 F7 s( z' L- module_param(acnt, int, S_IRUGO);" u% u$ o& o2 l* e2 H5 y; X
- module_param(bcnt, int, S_IRUGO);# @% z$ `$ j& [; M- W- u
- module_param(ccnt, int, S_IRUGO);
复制代码 9 E4 E l8 ^. z/ i! w& N
8 i' \- s# q8 i: Y- J# u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; }8 u& a4 Q) f0 x/ \+ |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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 l! m4 i/ `5 w& b& j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( D; Z0 r- W: y, i4 `
( J5 e" k/ k' p* a1 Q6 J
: g8 f* V# Z9 M3 e* \6 M
|
|