|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 {/ c: I% z; L# W- U5 u; o- [code]EDMA sample test application
$ t) q6 A0 E% c6 _ - /*
# |7 y3 ^% ~2 o7 t0 D I% Z - * edma_test.c! w- M* P/ E7 G; K4 L+ O2 e+ M
- *
, ?! r& C+ C) T9 k5 x" T - * brief EDMA3 Test Application% z2 M0 e, T" G+ G/ T% A* U1 w2 g
- *
9 J5 H2 C+ F; W! [5 l0 G8 E - * This file contains EDMA3 Test code.; j0 {& H/ b( w" n! o. N# }$ P! T! _$ o
- *' p$ ~3 p* r5 Z D9 S& X8 [& Q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- L4 n. b' J- [: V! a% o$ J; ^
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* P) H5 i' _% f, n6 y/ g2 Z5 o7 u7 A - * TO CHANGE.% r: U# X; h! q
- *6 I( W2 a5 n/ q6 `" Q4 j/ X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 J2 z3 W# H& a' T. f8 Z5 X - *% |2 z7 N) h* i, F( U
- * This program is free software; you can redistribute it and/or
( ?' L2 t0 P( l+ r( S$ C - * modify it under the terms of the GNU General Public License as
# ]& V/ d9 }0 H0 \0 c* X, D8 Y - * published by the Free Software Foundation version 2.% o ^8 s" I9 ]% }0 |: x% d' N
- ** }3 T2 Q2 r* |0 J
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* l# o4 P/ K7 A4 _4 _
- * kind, whether express or implied; without even the implied warranty8 `! Y( V' K0 l, Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% F) p6 d$ g$ _) U$ b
- * GNU General Public License for more details.
; e8 Z" c# e% u( v/ I( ` - */
; a, `* ~* X! `
0 ]5 a1 p' m+ h! [' s- #include <linux/module.h>
; I; P3 r5 i5 c# y6 l% a - #include <linux/init.h>1 S0 {; Z2 }; Z
- #include <linux/errno.h>
1 Z0 k8 x- M/ u4 | - #include <linux/types.h>- F* W! q* @; N( T& o6 M9 l, N
- #include <linux/interrupt.h>
. d' B: S# e: X - #include <asm/io.h>
8 d% p2 v3 ]* f% q4 d4 B( A - #include <linux/moduleparam.h>4 d! U6 h9 o# C" a# Z
- #include <linux/sysctl.h># _& j% x9 O/ v1 K. B( k, i) q
- #include <linux/mm.h>1 U* M, Y( _7 C. I T
- #include <linux/dma-mapping.h>6 @3 a7 E8 ~3 j$ K
. H7 X+ I/ c; |& M$ b- #include <mach/memory.h>9 J8 D6 X4 W5 c4 w+ E
- #include <mach/hardware.h>+ N7 x2 F! \2 O& r6 f- J
- #include <mach/irqs.h>( ~/ V6 Y" N$ D- m) y5 N
- #include <asm/hardware/edma.h>( a9 Q3 s" L( {5 j
# g$ k! H5 H) @5 p' ]5 ~( ?- #undef EDMA3_DEBUG
" @& x$ ^/ Z: ] - /*#define EDMA3_DEBUG*/* i; K4 V3 M% z+ f" }8 }5 a# |* ^
: F, n3 i) j6 y K/ @. Z- #ifdef EDMA3_DEBUG i( z" Y5 e& D: w* T0 [* D; E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 C' @' W: J/ s- m6 P - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) Z) l* i$ \* W B* g3 j5 F% r$ t" I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# }9 D3 \# ^; s! b - #else
( R/ y2 G% Y7 S! f - #define DMA_PRINTK( x... )$ h y" \; p: W Q8 ?# T# t
- #define DMA_FN_IN* W6 |/ ^8 y. P- m1 T9 z( _
- #define DMA_FN_OUT
, M6 _' x# e7 A - #endif
% ~) K, a# c* M' o - 6 n$ j% f" K# _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ d5 A! R9 J* i" d6 g s - #define STATIC_SHIFT 31 H% b/ Z7 I( e0 e) L
- #define TCINTEN_SHIFT 20- |. g9 l2 l: p3 z: e3 y( o" z
- #define ITCINTEN_SHIFT 21
- J' [( c- s) P; ]0 m' T - #define TCCHEN_SHIFT 22
( b' M. a1 @. D8 K0 C, K! J - #define ITCCHEN_SHIFT 23
$ `) d( _$ T) M1 `- j
5 U+ R, d0 p. w8 a- static volatile int irqraised1 = 0;) t, A2 _/ J& K% `' `* G
- static volatile int irqraised2 = 0;
5 b* M _; X9 @& T. @. u7 p, { - ! t4 B1 z& A& W8 j# b$ K
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( m/ \- C& x6 u& a0 \, w% g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% M: L3 E7 q7 y: z' E7 I8 R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; h7 {/ g9 Y @4 i# R6 P( a. \
' p) n; v1 X' |2 z, K/ m: h6 S- dma_addr_t dmaphyssrc1 = 0;
3 [9 f. \" \: p' X% y6 E' z* g2 |2 u - dma_addr_t dmaphyssrc2 = 0;( u4 H E- B1 L# f3 c* c9 S1 ?
- dma_addr_t dmaphysdest1 = 0;1 v% P0 |2 A: a0 u) n1 f9 \/ g
- dma_addr_t dmaphysdest2 = 0;* a) L4 B T% D( }9 B
) H% l1 N( J4 {- char *dmabufsrc1 = NULL;; Y" N0 k# C: t5 l
- char *dmabufsrc2 = NULL;
1 f) K2 u+ p9 H" v - char *dmabufdest1 = NULL;1 U! J. h1 x% _6 j7 N
- char *dmabufdest2 = NULL;
! Q; U4 b& `) Y - 6 r/ e- ^! Q6 V E3 x/ ~; M, k
- static int acnt = 512;1 `8 u: [7 b3 r- m$ U6 h* E( ^/ J s
- static int bcnt = 8; l! l7 V3 j W& }$ I8 @
- static int ccnt = 8;
6 C) i2 v: z" _
/ K& P) T& }! J2 I. G- module_param(acnt, int, S_IRUGO);
% `9 Q$ s% N6 f - module_param(bcnt, int, S_IRUGO);$ h+ L) D3 c2 g3 o; @7 d( ]
- module_param(ccnt, int, S_IRUGO);
复制代码
1 D$ H! ?' g/ ]4 @ w3 b7 s6 M+ l* B( C# p3 @ A H6 j
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ E/ Z6 D, {. c( K7 |% o( o
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 }7 ]$ y, @9 J) m8 C% E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! k3 `' n! F. ^! U" k
% A% d& ^- f3 t( i6 j4 X9 @
& d Z. f- F/ ~; Y7 [
|
|