|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 y' |7 m1 X; [& S& R- [code]EDMA sample test application
/ R, p8 m ]9 a* k - /*
, a/ s- p3 H+ m( e' n; }. @ - * edma_test.c
* g, ]! T) d( o7 _ - *3 c. [" ^* i! r5 W" l7 M$ ]
- * brief EDMA3 Test Application
& B- N3 o' Z* J* @$ p9 t - *
( W9 I" c: w# K7 `+ l$ P. R - * This file contains EDMA3 Test code.
" C, w9 p( W* h: g - *
- [2 `, \7 m# x. T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( N% j9 V# j! Y3 m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 N, p8 g; M9 T - * TO CHANGE.
& P* G/ O; l! i# a - *, ~6 [, H1 x2 F& t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( w P' K. X/ L1 h# {
- *
$ [' {. q& @& ?7 {7 w - * This program is free software; you can redistribute it and/or
6 p0 f* V: k! C% o) q; ` - * modify it under the terms of the GNU General Public License as) s7 C7 }% G$ K
- * published by the Free Software Foundation version 2.2 K1 l4 _" s/ L" X
- *
2 ^/ C6 c" e7 [( z! P$ w% ] - * This program is distributed "as is" WITHOUT ANY WARRANTY of any& T8 [$ x9 R6 p) y9 o6 `9 `8 u
- * kind, whether express or implied; without even the implied warranty
7 B5 L' g$ z( z0 k. { - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: c/ ?" r6 ?% m7 m0 w `# G- k - * GNU General Public License for more details.4 S5 [+ y! K/ c7 l" J% K
- */
1 l" K0 M! }2 I- u - % l0 I& e5 ?- X! c, c# }: v% p0 y3 ~
- #include <linux/module.h>
5 M4 C# {7 o5 [& C - #include <linux/init.h>; B) t. I1 J# w, W) r+ [
- #include <linux/errno.h>
* s5 l: B9 i; L( z8 U - #include <linux/types.h>
3 H, Q& L: x3 G# }5 } - #include <linux/interrupt.h>" E+ h. k$ [( |9 A) ]( _( _
- #include <asm/io.h>" Q$ v* K; J# y: ?! a
- #include <linux/moduleparam.h>
2 q8 n' C6 \+ o, T1 ? n. q - #include <linux/sysctl.h>
9 _* F1 d+ m* U2 X0 B" x - #include <linux/mm.h>8 u( v$ Q$ t) f8 x
- #include <linux/dma-mapping.h>$ X2 y: Q' B F c
: Q( y( {$ K$ ]" ~4 b0 M$ L1 R; e- #include <mach/memory.h>2 c% p Z8 b; K$ w6 g. T
- #include <mach/hardware.h>- F2 Y3 t& h( c: p: z9 s/ O
- #include <mach/irqs.h>7 f9 J. K1 U) J7 y4 s# X `& s* e: V
- #include <asm/hardware/edma.h>
7 {! O p: n1 H% y7 e+ ~
1 j3 N9 Z- |* n; ?- #undef EDMA3_DEBUG
* @' c' \: c& b9 b: c- A; b! m - /*#define EDMA3_DEBUG*// t$ ?8 k" c, `. ]* o
4 R- ]- k" h" L# Z0 A- #ifdef EDMA3_DEBUG
$ e+ G! G. O0 X& W- S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( T* g, z* T% c0 J% A( k$ S
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 y1 n$ E% J c; I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# o7 {4 X4 U5 i; o! O9 n1 y
- #else: U1 V% I. K, \5 `$ v4 ^6 }3 A* v
- #define DMA_PRINTK( x... )
( X3 {: V3 B, e e/ P" O$ ~ - #define DMA_FN_IN3 ^ J# ]1 P2 ^( k% {5 J j$ N
- #define DMA_FN_OUT8 j4 h9 S) B, \9 w9 B: I/ H5 e
- #endif& a" B2 p9 x3 n4 T' v
- ) R: y- l0 D4 q! K. U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" A: z- W$ |# G, x5 ^
- #define STATIC_SHIFT 3
* x8 o) g1 }0 t# Q2 D - #define TCINTEN_SHIFT 20
( V: X. H& v3 D6 G+ W2 n C - #define ITCINTEN_SHIFT 21) P: P2 Q5 ^: R" a
- #define TCCHEN_SHIFT 22
/ i3 c! }0 j3 \9 R& y, [6 M - #define ITCCHEN_SHIFT 234 m( b5 G6 X3 x
- 2 w' J/ y3 n+ [# D; L
- static volatile int irqraised1 = 0;
! |9 ?6 [5 c( I0 O! d. T" H2 g - static volatile int irqraised2 = 0;' v4 o7 i) ^/ }( l
- * {* U8 m& F3 Z/ b, j3 `# l, T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# O4 a- w$ k" r7 x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 H; I2 S6 e: R- x6 h' C& ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. ?& M3 P$ B6 [! V, a& L/ t
% i! f2 f8 C$ I/ C- dma_addr_t dmaphyssrc1 = 0;$ d. I! @; w- a" \7 ]
- dma_addr_t dmaphyssrc2 = 0;
x% A8 v+ n$ D( D6 `0 x! R - dma_addr_t dmaphysdest1 = 0;, G. Z/ m" P" H- H
- dma_addr_t dmaphysdest2 = 0;0 Z9 T9 _; K1 O0 K
- 9 b, P, J2 u6 `/ O# \
- char *dmabufsrc1 = NULL;. b/ ^! \" T. m3 Q
- char *dmabufsrc2 = NULL;
. Z9 A& ~% E/ Z3 ?) o% V' L - char *dmabufdest1 = NULL;
+ \! W( o+ p6 Y: A - char *dmabufdest2 = NULL;2 e8 l# J. a0 Q g
- ) N, ?( s; o7 e) n/ v' X
- static int acnt = 512;
) v2 U: j8 G$ G3 d8 R" a7 H6 _0 _6 B1 [ - static int bcnt = 8;
- R# E: c3 H: p7 }( s8 Q9 \ - static int ccnt = 8;/ k, C4 X& } [7 }2 o. {$ `
- 5 E, r& P1 w/ w* R1 h0 u5 J
- module_param(acnt, int, S_IRUGO);* d( H3 Z( `& A( X! _6 ?
- module_param(bcnt, int, S_IRUGO);
) o2 @/ u# D3 p1 V! o' ] - module_param(ccnt, int, S_IRUGO);
复制代码
- m6 x" o3 u6 L+ c' \* N- z
3 V. u+ q9 i3 S 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. j" N: X- a; U6 varm-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 S$ p/ q2 B) V R! w 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* q3 N( a( j" _0 Z
) C8 c2 J X/ w; e( E- m! D& v) |1 k4 a
|
|