|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 m6 z# A( D% I0 s' ?4 b% B1 P7 N- [code]EDMA sample test application4 |1 x* a( Z; l: z5 Y
- /*9 q4 N; i7 o' [
- * edma_test.c+ r* a) U# V5 A0 H! R/ Q! U J/ }/ X
- *% H, o* f" U4 q* V* Q4 T6 M% z/ T
- * brief EDMA3 Test Application
1 T" m) g4 r- |' o: {" z - *
- V/ s) p& U2 k' ^; a5 ] - * This file contains EDMA3 Test code.
, a6 s7 J) W% o& z. ] j( V - *0 R+ Z1 a7 ]2 q& f, S j: Z8 C" R8 T
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) M0 }" w# C- _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 ?% D& E: r. ]' _! b3 N" n9 v
- * TO CHANGE.
0 f o$ ?- C% v* U4 t - *2 d4 D" X( [: [8 B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 V/ w/ U! c" V4 F
- *
" Y) k4 \% \) C$ [ - * This program is free software; you can redistribute it and/or
) [' _% r8 Q0 z% t - * modify it under the terms of the GNU General Public License as
; s' I# }& g, _" w% U* | - * published by the Free Software Foundation version 2.
0 {- M' j/ |! r - *$ X4 o; d, O( u" J+ H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ V2 b" e/ L8 w6 V, t - * kind, whether express or implied; without even the implied warranty( X1 }2 C2 \7 ]) q% D
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) e* ]- n7 s7 x- ~2 r5 l* k - * GNU General Public License for more details.
; j% f1 E( \. S4 X" r - */# T& W j, f, X/ o v" r/ N0 p$ H
6 A2 m6 t, `9 S% o. Y- #include <linux/module.h>+ ~" H6 b5 X4 \& k" \
- #include <linux/init.h>3 i2 H3 b% O" k4 C
- #include <linux/errno.h>
4 g3 n+ x' k( F - #include <linux/types.h>; C* [* @4 r( X% N+ w7 @
- #include <linux/interrupt.h>4 I% m ]1 D" U) S4 [% v9 R, _% l
- #include <asm/io.h>9 T' x$ X8 Z+ ~5 U5 v! |
- #include <linux/moduleparam.h>( p5 A+ w5 k* [
- #include <linux/sysctl.h>
2 E* l3 V" |* s1 f8 l7 X - #include <linux/mm.h>5 ^1 s2 U& I m' R* w p
- #include <linux/dma-mapping.h>
. G" H' H4 a1 D$ l5 |" |2 ` - 9 ]4 ]% l. ~- j4 Q" X5 J
- #include <mach/memory.h>
6 |7 [# Z/ t" t2 \! f( { - #include <mach/hardware.h>
3 \2 t3 T5 ?. `/ { - #include <mach/irqs.h> r9 w# W( I% V; A0 D
- #include <asm/hardware/edma.h>
; m/ J6 F2 K! u, s, E: @/ S
5 }$ \# P9 |/ d1 J; U- #undef EDMA3_DEBUG
( n2 c) ~ ]& ^0 E; G: {3 g# P Z, y - /*#define EDMA3_DEBUG*/
4 W4 T, M7 c+ Q# V
+ B* o, S, [+ ~- r. `0 f- #ifdef EDMA3_DEBUG
+ ~( r& z3 J3 }0 q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- M2 N' h! N* f f L4 `8 B8 e
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 U$ W: ]; g/ _( s, b3 X0 i' Y' `1 V" f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 A* s: g: j% y$ s! l6 j
- #else
4 p' y4 @* |5 Y: c+ k* X9 ]& w) M - #define DMA_PRINTK( x... )3 E+ h5 _- f: w
- #define DMA_FN_IN
* d% ~0 |5 e/ D( u' k* W - #define DMA_FN_OUT
" {, a2 C. }8 h - #endif) Z7 e* P; \" N( D- C0 X7 o' a
3 H& U I$ B8 ~$ B! T7 H- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ M& c" U; w, R. v# g
- #define STATIC_SHIFT 3
x2 H7 ]7 h6 ~" k - #define TCINTEN_SHIFT 20
) f% N# L4 N$ _ B/ u5 \6 O+ G# v - #define ITCINTEN_SHIFT 21
& \6 q7 K2 N" q+ E5 W7 A* c8 L8 J! Y - #define TCCHEN_SHIFT 22' U( R* `' A' r) n8 Z, `5 p
- #define ITCCHEN_SHIFT 23
4 d# L8 R u& x, R0 x6 r - * y6 r1 a" n7 Y. b) ~ M
- static volatile int irqraised1 = 0;
# C' H# @, {% W- Z6 n* h4 X8 v- I5 T - static volatile int irqraised2 = 0;: K( T; u4 r6 @! D
- . l% x5 l5 I# V. e* Z3 B& p
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 J! B( h% W9 d# A; W* x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, }% p+ ?# B! t7 M: K - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: S9 a, j: W, w. a6 _
4 S' F- t, I( W7 j# g6 e5 W- dma_addr_t dmaphyssrc1 = 0;! R7 S/ t1 A2 K+ I' m7 u- z7 C' Z
- dma_addr_t dmaphyssrc2 = 0;. @4 \+ s# }* k' y" m& {
- dma_addr_t dmaphysdest1 = 0;
D& b* I% H) j9 n$ l5 B/ X/ G - dma_addr_t dmaphysdest2 = 0; _: z7 o$ M% ?* c
- " s& H6 @. J2 m2 a
- char *dmabufsrc1 = NULL;
. { f" q, X) v, d, \. k& \* d0 v - char *dmabufsrc2 = NULL;4 H$ {2 C5 a7 A$ ~0 E& X
- char *dmabufdest1 = NULL;8 K" f, N2 ^" @1 i0 Q) f
- char *dmabufdest2 = NULL;: N, U/ K7 U6 |/ Y$ @6 z& f
- . Z7 N: }: m" Q
- static int acnt = 512;2 z }, l6 U" M$ t
- static int bcnt = 8;% }7 R, v% [ U w
- static int ccnt = 8;
1 F/ x0 d( b. ~9 h) n% F S5 K - - n5 r+ N2 P- O4 N
- module_param(acnt, int, S_IRUGO);% ]0 h% ]% Z. O* Q9 P& y2 e
- module_param(bcnt, int, S_IRUGO);" [% c/ c: y& T, d9 R+ V+ \
- module_param(ccnt, int, S_IRUGO);
复制代码 % ]# B5 v0 ]8 i# t, t
7 `1 h4 r) |$ M- r5 W( N: s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# q! D+ A* P% ~! Y1 Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 Z/ q' f; _5 X& O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ j4 N: k, V* G# |: ~! I1 a
% v f3 a! m0 ?1 M- i' v
$ X5 _ a# G; I |
|