|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. l( Z6 {. a8 o- |7 F- [code]EDMA sample test application" }! W) c0 j @. ^# _
- /*
! k8 D! s5 i7 W' A - * edma_test.c
5 x! h/ P( m3 r - *: }7 h1 X$ i/ [+ m& R
- * brief EDMA3 Test Application
) L) ^" W& g8 U - *
9 R2 L9 O) l* f+ n4 b- r) i3 v - * This file contains EDMA3 Test code.0 U- M& p8 ]& j8 B
- *: i2 s! u+ _$ x3 f+ Y0 x$ U! f& i
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 k5 C- f; @ R% p! c# _9 b2 k - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 b2 y! u8 o& s: `- \' ]# d$ M5 W4 G
- * TO CHANGE.
8 y/ M. f5 S, [' Q$ c" M* c - *- j; ]( F+ _* t) M6 y- T: Y1 q+ z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% Y" e% x* `; j" ]/ }
- *& t& ]) U: \( K; _
- * This program is free software; you can redistribute it and/or
* E- k3 o5 z2 x# ?9 G - * modify it under the terms of the GNU General Public License as
: g+ ?; g6 }, a! A# L - * published by the Free Software Foundation version 2.
9 R) I9 f" Z) r- w3 i - *
9 z/ o# g! u8 ~1 C% o8 D5 Z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 E6 C6 e" p, O( q - * kind, whether express or implied; without even the implied warranty
+ ?' Z5 M! {, M4 o, t - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. ]3 F( H+ Y v" J) U - * GNU General Public License for more details.
% p' C# C) R6 R. w$ ]' ` - */
1 T a- O/ O& u( D9 s* [6 G - 9 D! L( b; ~& U, K: H4 F" G
- #include <linux/module.h>
# @0 ?* I; l: m d - #include <linux/init.h>; R" ` ~7 Q9 @( j @( p
- #include <linux/errno.h>+ I3 x1 `: q: }3 W
- #include <linux/types.h>' Y+ Z# G+ n1 J" @; ~. L
- #include <linux/interrupt.h>
, u6 ~! T$ q/ w6 s1 K/ f# O1 p) f - #include <asm/io.h>1 X5 Z0 k8 Y$ L: T. b2 }5 O
- #include <linux/moduleparam.h>
6 S9 A2 g$ d. K - #include <linux/sysctl.h>0 N7 C5 `- D/ f% z- R2 x! ]
- #include <linux/mm.h>& D8 T# b: Q9 F# i* E3 \
- #include <linux/dma-mapping.h>/ ~* l' S/ a& p& r9 n9 `
- : H9 k. m7 b/ x
- #include <mach/memory.h>
- h7 `7 S% C9 |. e! U. z - #include <mach/hardware.h># w( I' H7 x$ R: E4 y7 C! d
- #include <mach/irqs.h>1 J' h: a& Q4 d& b: b! V3 k
- #include <asm/hardware/edma.h>
* l5 g/ C) Q, ^ - : |5 s' o/ I- f$ k- b2 A
- #undef EDMA3_DEBUG
+ \5 ?; N/ H+ M9 @% ^6 T6 ? - /*#define EDMA3_DEBUG*/1 h5 c {" ~* t4 v7 E0 Y
5 Q: ]5 m! _& n/ b- #ifdef EDMA3_DEBUG, C4 ~% {+ ]- ?" R& ?; o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& q6 h& n d9 `8 V2 i3 S
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ q: G9 {+ t6 A' Z2 n9 o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
: z! J) e1 A; U+ [) z2 U - #else4 U* k5 x) d' A4 ]5 O6 b% t
- #define DMA_PRINTK( x... )
! w6 A3 L% M- S2 _+ t P - #define DMA_FN_IN
+ x; B+ N: T Q, U1 I - #define DMA_FN_OUT8 P8 k& L" Y" T. Q$ f+ K7 O& a- {, G
- #endif
3 U, ~& R2 S. @7 B* u) U
/ n" g& f& ~$ p$ z, a5 p- #define MAX_DMA_TRANSFER_IN_BYTES (32768): i1 R- K9 r) Q8 Y) B9 u# ^
- #define STATIC_SHIFT 34 t9 ]8 _; o+ c( H( T5 j
- #define TCINTEN_SHIFT 20
! @' [6 @. ~/ V' @# f5 l. @- l" t - #define ITCINTEN_SHIFT 21
+ c; H. e* h- {) m - #define TCCHEN_SHIFT 22) o" |- V" W1 h) q6 I
- #define ITCCHEN_SHIFT 23
8 L* G/ H; u8 s4 o) b) f" ^( P u6 K
9 R9 ?1 S4 A1 i( n6 ]- static volatile int irqraised1 = 0;" Q' _# ]! [& d; } a
- static volatile int irqraised2 = 0;
6 s8 S1 N$ A" L2 c
% ~% I" }! X) I0 g, p0 |3 J- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) P/ |5 c' J6 \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) \* p9 i8 c5 K% {. v - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 _* V' ]# e8 Z6 K
4 H* [+ o: {7 s7 s4 s* e/ y) `- dma_addr_t dmaphyssrc1 = 0;
* j+ H! M+ c- s( _( E - dma_addr_t dmaphyssrc2 = 0;% [7 |9 q6 ]9 c1 _. s% c/ Z
- dma_addr_t dmaphysdest1 = 0;
' {2 G6 @- j8 N5 K% _ - dma_addr_t dmaphysdest2 = 0;. X3 ]2 ?! n4 f& H3 |. g0 S
2 U$ |8 ^4 m6 V( t- char *dmabufsrc1 = NULL;3 c8 g' d0 k( m. u3 P. K: G
- char *dmabufsrc2 = NULL;
/ ]3 K3 m0 q( G i) T3 c b - char *dmabufdest1 = NULL;* X9 V( j/ _* J2 v0 V
- char *dmabufdest2 = NULL;) }9 P# `. }3 }
- 6 ~3 V' C" {- W* z/ W& d- O
- static int acnt = 512;
5 K+ ]7 _/ u. e6 U* n1 s/ n( f - static int bcnt = 8;
1 T7 H( c6 W" J- f6 I - static int ccnt = 8;
6 |; k6 r+ a3 g6 E
0 u* J P7 ?, {0 n t/ B- module_param(acnt, int, S_IRUGO);
' Y- ~3 M! W! l& Z3 W - module_param(bcnt, int, S_IRUGO);- ^" S+ A0 I6 b9 O- p& F. G! Z; }
- module_param(ccnt, int, S_IRUGO);
复制代码
% g% W9 X5 c" Z1 s* E: G) }
* J; m& Z4 r, W( x) ~0 \ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 ^4 h+ t! ]* p& x, T8 f( g/ P3 x
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% Z8 d) r6 U/ b+ [: r( I" J" f 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 H, i! c2 Z. G( ^7 N7 K# E
' y1 ]* n! x) s: _$ k6 T. S$ L% ?( K
|
|