|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 m! g1 k' |$ K; |5 e9 B7 ?- [code]EDMA sample test application
6 `3 g/ Y# |0 n& ?- F/ x - /*
* Z6 Y$ q" n& | J' @( q# h - * edma_test.c
3 U4 D! @6 G3 y8 ?2 \6 J$ j - *4 P+ F* g; y% E ~5 D& n) x- z
- * brief EDMA3 Test Application
5 @ {+ O+ Z% u% K* ^- ~5 j0 l1 c - *' d6 b% Z% F& o+ q' x
- * This file contains EDMA3 Test code.
! ]+ Y' Z5 W( E. C* ~ - *
; x4 q! j! q a* n9 A - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* P# Y) s4 n. m/ ^" m - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ J. o# o1 R e1 q( K$ [
- * TO CHANGE.$ k% X9 t4 \/ V% B
- *! o' ]: C2 u& }" r* }
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 c: u, ^' f. X2 [9 W4 o$ l - *
* c) }( z4 Z% |0 E9 X8 F/ p - * This program is free software; you can redistribute it and/or$ b0 U; f- y [2 y2 k3 o
- * modify it under the terms of the GNU General Public License as# F9 Z6 f5 F9 X, \
- * published by the Free Software Foundation version 2.
! v- L" v9 Y- p - *5 I9 e4 e% g% X2 c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any d$ ^- N, P# T" T
- * kind, whether express or implied; without even the implied warranty$ A2 K1 Z) s3 N7 m' ]" h
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% Z$ I. L: z+ A2 ` - * GNU General Public License for more details.
4 q4 }* p( _- ?' m2 c2 A - */- v9 ~; y! i& v9 t
: E& `* {7 b9 d- #include <linux/module.h>
: Q w3 F1 b3 e" w$ E6 e4 S - #include <linux/init.h>
) x: B, X! z0 d/ y. w - #include <linux/errno.h>+ m2 r& g$ Q( i+ m$ q
- #include <linux/types.h>
. r5 R8 m% k. v' z8 f, { - #include <linux/interrupt.h>' y) a* d7 {8 l2 N }9 \, A$ y: v
- #include <asm/io.h>/ P& I& I3 o' W' L7 u8 W+ \% a
- #include <linux/moduleparam.h>1 t8 Q+ \* ~$ N- g8 F f7 f
- #include <linux/sysctl.h>
* C6 _7 X' o2 M6 y! F1 W - #include <linux/mm.h>
2 ]' B/ @2 n2 @* c' A. V% y/ ` - #include <linux/dma-mapping.h>' [" c4 _- S- \+ _
9 C# I7 }) M& q( N+ |- #include <mach/memory.h>
! b6 q+ ]' Y X4 W! E3 H+ z1 T - #include <mach/hardware.h>/ v) ^' Q! K8 U% w5 X; f; f
- #include <mach/irqs.h>* A" x( K0 _8 H3 W% z; K6 Q
- #include <asm/hardware/edma.h>
8 v S6 e0 ^4 u) @
: v+ p/ U' u$ H2 x- #undef EDMA3_DEBUG
. b( z3 O1 a3 l8 }2 Y& L - /*#define EDMA3_DEBUG*/4 P' b) f5 L% ~$ ?$ _5 V, y4 b
7 L1 F3 ?- g" k! b5 Z. h8 ?9 C- #ifdef EDMA3_DEBUG
8 W0 Q& q( w3 M. y% b Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 b$ H+ f5 P; V- y$ X. q* ?3 P
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): [( |' r, ` N! [ i% E" B+ E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
E& ?1 ?3 v$ ^4 P - #else0 B1 j6 I# C! H4 ?: @
- #define DMA_PRINTK( x... )* k) z( L6 ?+ B& ~# O( w# R
- #define DMA_FN_IN
4 W4 l: w# [: a2 g! w8 s - #define DMA_FN_OUT- k/ Z& C% n& l5 F% H3 \, B
- #endif
9 Q! u' z+ ~2 W6 _, x: E1 Z3 \
+ E& @# G' s7 _3 d$ [' l6 \- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 N8 k7 D; ?* E- `- V3 j; Y; ]8 u - #define STATIC_SHIFT 3
1 l# W3 i& \$ {" Q; v: u+ l7 `) R - #define TCINTEN_SHIFT 20. N; u( C- Z; }" V6 q7 ^6 ?) k4 p
- #define ITCINTEN_SHIFT 21
3 [/ @& ~* f7 J0 O - #define TCCHEN_SHIFT 22% u; J/ D, _! _- x- u+ s
- #define ITCCHEN_SHIFT 239 E8 Z6 n" K* A
- l! |$ h2 l! B( A4 E
- static volatile int irqraised1 = 0;
- H, s. m6 \$ a7 ] - static volatile int irqraised2 = 0;% o8 P* W) E3 a) j0 ?
1 @( h0 ]3 P3 i7 X+ D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& z( O4 R- g# j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 o! n6 q/ `8 t S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% o2 J+ m, X2 Y4 z
' @( ]+ u% O% A. d- dma_addr_t dmaphyssrc1 = 0;
: k; X/ c7 H, L' ?; Q - dma_addr_t dmaphyssrc2 = 0;
5 `4 c1 Y. M" ` - dma_addr_t dmaphysdest1 = 0;
0 x! t% y* t$ F8 y$ l# ?# x - dma_addr_t dmaphysdest2 = 0;
+ a7 Z3 s* s- Q+ B8 U1 x - 3 I* N( P9 k) a: }( C- i
- char *dmabufsrc1 = NULL;
8 q+ m9 G2 p, y1 z: s - char *dmabufsrc2 = NULL;" u H. T0 K0 N! c% e/ F# z
- char *dmabufdest1 = NULL;
- X4 ]) S: g: y, [+ P& t - char *dmabufdest2 = NULL;
; Q: R' N( @6 p! U, r
t4 q# f2 D- C& h; E# r% C3 a o. z- static int acnt = 512;3 w; [8 j# G! G! B$ D1 `) V, x2 z
- static int bcnt = 8;
% v- }: A$ M' ^6 H/ `. U - static int ccnt = 8;1 d& y3 O B, E6 ~
* M' B+ n0 @: I+ O2 o& _- module_param(acnt, int, S_IRUGO);
' X+ `: ^* _' P4 p! ? - module_param(bcnt, int, S_IRUGO);; Q& ^6 o9 h: X7 R5 w
- module_param(ccnt, int, S_IRUGO);
复制代码
2 P' j& p1 a* |# c+ V% [
& B5 T" K4 Q3 ?+ A 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 S! M' t/ l. w. Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, r. k9 H+ a' M$ I3 k# k, j) i& u
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 w, Q9 p- N( o n
! Q- x+ v5 ?# {% D0 w& {
: D5 S4 U+ `( C( v( u* O! _ |
|