|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. |6 t2 i u: S0 t1 R8 [- [code]EDMA sample test application
6 ]2 O0 z# M% t3 B5 V& K - /*' k7 c" B" J! d/ f z! E8 m+ ]
- * edma_test.c0 N6 B. t- G k5 E
- *
, X* B9 n {& @! Y7 m, H) @ - * brief EDMA3 Test Application! W3 o& G* d& c) J% y J; H" e& O
- *: r, K7 i3 R7 v/ L, P
- * This file contains EDMA3 Test code.7 ]1 r! z1 q/ g# p
- *5 @* w4 f# i) w* Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ U9 R0 o0 n/ x. `" ~' J4 D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 U) H4 C m! j5 o* O* u0 K( M
- * TO CHANGE.# C. s4 o6 F) }6 F
- *6 N( U& V/ Y0 u4 L2 W; \+ q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 s; |/ |7 M# v3 O6 q: D. x+ C7 n
- ** j$ q' c3 U+ r- `4 {7 [
- * This program is free software; you can redistribute it and/or: o' o6 q" i4 U
- * modify it under the terms of the GNU General Public License as
, y5 v' _- \: K: m6 D - * published by the Free Software Foundation version 2.1 v, I3 k3 x7 U! e& _0 E5 ]) e
- *2 A+ v5 k" l& {" `0 J% r" H. A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 H! ?! o* u3 [. d' A4 j* P - * kind, whether express or implied; without even the implied warranty/ g8 {% O/ K0 G! l% c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. g. O4 e. c+ p
- * GNU General Public License for more details.
7 R: j) p8 m# n2 e1 q; \2 E - */
% ~$ r5 l$ P$ e+ h+ ^+ J$ z0 W - + l3 r' b, R( S m- ~% U
- #include <linux/module.h>
$ s# h& l ` X) [$ B& m$ K, L - #include <linux/init.h>; R2 }& H! M7 a
- #include <linux/errno.h>
5 y) h% S, D0 I4 a8 x% ` - #include <linux/types.h>+ ?- |/ L' O) C+ m- j: z y$ n
- #include <linux/interrupt.h>
( H9 |0 @" f$ ]( F* x" _. f4 g - #include <asm/io.h>, q( k. ]: [ m6 M6 q
- #include <linux/moduleparam.h>
0 p9 u& A2 w4 Q% g5 t* q - #include <linux/sysctl.h>
* k: [! N, l: A4 F8 i - #include <linux/mm.h>" H! J4 u) Z0 a& _
- #include <linux/dma-mapping.h>
* w4 E& X* t* M
7 w ~; @( o0 d x+ u' u" L- #include <mach/memory.h>0 H4 \, i1 t7 g* x+ l
- #include <mach/hardware.h>$ G' @6 M& _( I! o7 e' K; m
- #include <mach/irqs.h>: ]) g4 _0 p0 J+ N
- #include <asm/hardware/edma.h>
& v# N& d# X2 y# }
# R, M+ b* Q) o) ?: `0 v- #undef EDMA3_DEBUG
( Y: u) ]* w/ a, t! ?% h- V: v - /*#define EDMA3_DEBUG*/8 D2 \* Q- s! D9 X: {
- ' `# }8 \' t: A+ W4 J1 U
- #ifdef EDMA3_DEBUG+ f7 h! `2 o. U7 ^3 j' H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 ]3 i7 | g9 ^' R& Q" r, f
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 S0 `4 S9 L& j( g7 g; f - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ F7 N7 D- N+ J, O$ e
- #else
# o& B5 c0 X1 f2 K% c - #define DMA_PRINTK( x... )+ I+ k4 J- y6 v3 P& L; m( [
- #define DMA_FN_IN$ A- u# H" m7 x: t) d
- #define DMA_FN_OUT
: R6 b n9 m) }( ]! [) s0 m - #endif
' w( T6 X. S% c3 v$ q8 b# p - 1 ?7 s$ M, m. c. B2 q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 e$ f1 Z/ C0 t6 j - #define STATIC_SHIFT 3
; i" U! t3 V4 f7 e/ o( I0 } - #define TCINTEN_SHIFT 204 r6 c, H% l' ]5 `
- #define ITCINTEN_SHIFT 21$ }6 l. n6 C% c, M6 n6 c1 t
- #define TCCHEN_SHIFT 22
, }2 w9 z6 G) I, g+ z. C# j - #define ITCCHEN_SHIFT 231 z! c& u9 q1 O1 E: e9 b2 _+ J0 R% H
1 o0 u" l) l+ `( t4 f- static volatile int irqraised1 = 0;
Z% ?3 a6 [. t3 c; m! L1 L9 ^ - static volatile int irqraised2 = 0;$ ?( \% g$ V% A2 }- }, K/ l' |( N
) v: g) u; C5 K: `0 Z! I- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( ^4 z P6 g7 S - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" [1 `0 q q- w6 E$ Y1 u, A& ~ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- O+ W1 o$ r3 L
- ( H" B" `+ e' R& x5 u* x" Y0 j
- dma_addr_t dmaphyssrc1 = 0;
) t2 z5 v& g. p* l) c4 ?" N: M - dma_addr_t dmaphyssrc2 = 0;
% ]5 x2 j3 z' z' [ - dma_addr_t dmaphysdest1 = 0;7 B+ |, C. d8 V$ R) m
- dma_addr_t dmaphysdest2 = 0;
w! s6 j& \8 ?
! A$ g3 ]2 A) @' g) u4 Z/ d+ _: m4 J- char *dmabufsrc1 = NULL;
?( j Z) M; S: F& W - char *dmabufsrc2 = NULL;2 T: ?' Y$ v' R; V% u
- char *dmabufdest1 = NULL;1 Y+ O) H Q% S0 i( R
- char *dmabufdest2 = NULL;
, X! Y1 r( j- S* }+ j/ j - ! q* ^& Y/ G4 R. J6 V, Z6 y( c
- static int acnt = 512;
$ Y# `0 E7 \0 r% j2 L/ c - static int bcnt = 8;- u9 h6 K3 }8 p3 M6 a5 Q D! \! J
- static int ccnt = 8;
% c! G, ~" d6 l' b+ g9 i$ ` - 4 u! k+ g/ `6 |+ z- z! I
- module_param(acnt, int, S_IRUGO);
5 h) I! \8 P) F5 B9 X% D4 g" d - module_param(bcnt, int, S_IRUGO);1 t1 p: P; Q3 c4 Y. G" \
- module_param(ccnt, int, S_IRUGO);
复制代码
- `: g/ K3 P0 ?2 ]
' g. Z9 b+ A# ?/ f 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& a6 J* ~" g2 i+ I) h- yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% k) B& G+ ?5 c" P$ f 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 u! ?9 ], w$ F* I7 J1 K/ \7 E
0 y: M& ^$ b# I2 i$ l* {' Q* A
2 j3 \. o1 j6 B5 @+ a |
|