|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; M: |( B& C, D- [code]EDMA sample test application
' |; c1 |' b, X- f - /*
' W9 s1 p( d% v6 { - * edma_test.c
c1 ]. {4 W r P4 X - *
. W0 `( c! z9 {$ t' S - * brief EDMA3 Test Application* t4 J' q( A. ]1 _4 N3 N6 K& X
- *+ I* a# T8 A) U* P0 T; f
- * This file contains EDMA3 Test code.
$ J2 A9 p5 ?" g+ X+ S n, W9 h - *
. g# w. g: A* l" t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 {# t k+ W% {" S- ]# }; {* l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" l2 r, K( m& L3 t
- * TO CHANGE.3 n0 x# e# h+ @
- *3 S% }& G3 M3 b) S, m2 i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ ], H9 t- @; q) m
- *
( c9 h. i/ k' R: ~ U - * This program is free software; you can redistribute it and/or z' s* k" I A6 c/ o: A
- * modify it under the terms of the GNU General Public License as0 k% F0 u5 X5 w; s4 W7 E, ]! P, e
- * published by the Free Software Foundation version 2./ }) o* o9 j- I# c/ B. G* f( ` O+ p
- *# m7 _) g5 } ]; P: Y8 T) N# A# Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 `0 @' @- v* S& w: V: }/ j7 o* P
- * kind, whether express or implied; without even the implied warranty7 _1 D' i7 e. A9 K4 F& i* ]$ o7 u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& ]* r* b: K D3 A - * GNU General Public License for more details./ i+ [: ]& N3 s, G& J& o
- */
. y2 \* J1 P! m, j" x
& G5 C% w$ X+ `' Y- #include <linux/module.h>+ s' k+ P" i' a
- #include <linux/init.h>4 }3 k3 s: f( V e5 Q" L
- #include <linux/errno.h>
0 w$ ]6 a( T6 g: {; t d+ I, j - #include <linux/types.h>
T6 w" M6 V) J/ ` - #include <linux/interrupt.h>
* z1 E; C7 O' v% r - #include <asm/io.h>
: s: K+ \& W) B7 i4 ]2 t& p - #include <linux/moduleparam.h>( H& E# r. ]8 f! }) h' x
- #include <linux/sysctl.h>" N6 h. m+ p6 ]& o2 G6 x' u
- #include <linux/mm.h>
# y, p% Z6 q5 Z d$ V2 i - #include <linux/dma-mapping.h>6 q% R1 [9 C0 W3 P/ Y" @
- ) Y8 B0 b' B8 m) j# [
- #include <mach/memory.h>7 R; s! x6 V E {& K% r4 u2 y" Y
- #include <mach/hardware.h>5 u" i+ N5 Y0 c+ A' I3 r8 t
- #include <mach/irqs.h>, J& p1 C& Q" f- S9 S3 } G5 o/ A
- #include <asm/hardware/edma.h>
0 i- p0 `! f+ }4 v& K - 9 }5 ]! U$ k- x
- #undef EDMA3_DEBUG
+ A w& D$ B7 d: _& P; I - /*#define EDMA3_DEBUG*/
% P$ ` `/ H9 \7 U
- k/ P+ R5 P4 Y, N8 a- #ifdef EDMA3_DEBUG; K' d& z) E8 Y* ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 L( E+ g/ Q, R+ Y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; T) U; ` ]' i, ^: S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ c5 @5 x( M- [ - #else& L3 K/ F, p9 z3 ? W2 f
- #define DMA_PRINTK( x... )
9 q" f6 n! j1 X4 k2 ~5 m$ | - #define DMA_FN_IN( R% j1 N5 z% a/ S- K: ~1 J% j
- #define DMA_FN_OUT6 a! ]+ @2 }( W0 T9 O* `
- #endif
) T( d7 \4 m9 S _* S9 ` - + ~7 c' O, g% ^9 j8 q! y% [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 n! Z7 M6 l7 e: i8 P - #define STATIC_SHIFT 3! \) r3 n1 x* e. @; J( O
- #define TCINTEN_SHIFT 20' h* F: Q" P- w. _( H1 ]# F
- #define ITCINTEN_SHIFT 21
/ u V! q# V0 B. s/ V+ c% p - #define TCCHEN_SHIFT 22
6 T* r( k# a0 @2 s* b# Y4 W* |" g" B - #define ITCCHEN_SHIFT 23
1 ?6 X' j; \1 Y9 y2 a1 N - / c/ J! J( n1 p5 s
- static volatile int irqraised1 = 0;
+ E$ s/ I$ J- @( O. _ - static volatile int irqraised2 = 0;6 i) K0 c* L s% P7 w" q! i
# G1 |2 ~ G4 D* i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 |4 U/ ~( J3 k# q9 z9 y: C: L
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 v- r: ?7 G' I3 }4 t. i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' V. d5 U! B x- c2 M
2 v, p, T+ l0 M9 R- dma_addr_t dmaphyssrc1 = 0;
. f& o S9 x7 X% ] - dma_addr_t dmaphyssrc2 = 0; [6 v9 @8 C8 Q) X3 g
- dma_addr_t dmaphysdest1 = 0;7 A: e2 [& p1 R% K0 `) I
- dma_addr_t dmaphysdest2 = 0;6 z- h1 c/ B. H* l( G+ j3 b$ Y, q
& Y! R! Q4 G1 y; J+ O- char *dmabufsrc1 = NULL;' [7 }5 v. y% U% e' h
- char *dmabufsrc2 = NULL;
) q4 p6 o8 R( A# Q: g& M* V. H+ X. c - char *dmabufdest1 = NULL;
3 T1 y/ e; v/ R( K. X- @ - char *dmabufdest2 = NULL;1 Q$ K2 Y) b {4 I9 k' G9 X
- , Q% s7 A+ L' F, d3 H
- static int acnt = 512;" O, M: L! L; d0 |5 \9 g$ c) Z
- static int bcnt = 8;+ w8 b( N& Z ]9 |0 \
- static int ccnt = 8;3 `- ~$ x. V. l+ j
% |, x; x9 ^: v0 U9 r8 T: k) C- module_param(acnt, int, S_IRUGO);
2 u! |) N3 y+ Y2 e' x; W5 e - module_param(bcnt, int, S_IRUGO);
# d+ m3 O2 Z& Q4 q9 ] - module_param(ccnt, int, S_IRUGO);
复制代码 8 m- z" @- q; e9 [7 G) b" l8 n, ~
* O3 V$ Z1 L( l' K
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 M' ]3 o0 o1 x* ?# U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# I9 e6 x5 v P8 F4 P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ ]% J7 {) D0 @0 l0 o: i. N
; r' ^# K6 X6 s& m! S7 E" l
8 G( Y3 i* o/ t# z( f+ {5 R, B |
|