|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% r* w. M$ P; g2 d3 g7 o: z( l- [code]EDMA sample test application
R& @5 E( {7 v4 K - /*& l3 ^4 S: s5 w( @
- * edma_test.c
r' ? o: \2 \ @% S7 X; T6 J - *
$ V4 B- ?- y5 _) E' ~5 n) ^ - * brief EDMA3 Test Application
5 r$ ?6 z3 M# e) L6 l - *1 D$ v. ^, {% ~8 c+ r6 P! r8 R
- * This file contains EDMA3 Test code.9 V) L; w; a r( |4 n6 G- N
- *
9 k. l) Y, v8 \0 O0 e/ O I - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" |$ E! x) a. h* {4 N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 X+ V' B, P5 S* @( R" I# B: {/ _ - * TO CHANGE.
: B$ p! q7 s0 ~ - *
9 O3 r0 t. F4 ]$ y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' y# Y K# J7 s0 Y6 l
- *
5 ^2 q) Q. d+ ]" a @* Z4 ]) h - * This program is free software; you can redistribute it and/or0 R R7 _6 N' g3 i4 R
- * modify it under the terms of the GNU General Public License as
' O1 d$ v) T/ v0 I, ]$ O S# S - * published by the Free Software Foundation version 2.
/ F% L2 M- i ]6 u3 a - *9 H8 ?" i2 o( F3 x
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any M% q9 `3 z$ i7 T" W
- * kind, whether express or implied; without even the implied warranty' o2 D' _# I$ x) ~
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. L2 E1 L: Y+ y8 {; @5 | - * GNU General Public License for more details.
+ ]- s( t# X N( m. ~( `5 n - */1 |3 m5 m" P$ f4 E& c: p5 e0 u: m
- + r8 `/ r t4 O g/ t3 D- p
- #include <linux/module.h>' W) J" D3 T' H# P, [
- #include <linux/init.h>
% T/ U1 D+ F' [ - #include <linux/errno.h>" V( O9 K* e. u8 L% N( J- [0 @
- #include <linux/types.h>
& V. n- D, S' ]+ p - #include <linux/interrupt.h>
1 g9 J# e3 J) C# J8 [ - #include <asm/io.h>+ s5 g) J3 O- j' T
- #include <linux/moduleparam.h>
- E4 u+ L4 `* G6 b9 w - #include <linux/sysctl.h>
+ n5 A% c2 P! \- P- g - #include <linux/mm.h>- o$ `1 H7 z9 a' {1 r
- #include <linux/dma-mapping.h>
9 Z( T- P/ }7 B C _) G# k" v! g - , Y, n x1 l. F! Q
- #include <mach/memory.h>8 o" i" d* T0 D2 w! T! |; D/ g, y
- #include <mach/hardware.h>
% a# Y- J5 f9 }, c- {8 C - #include <mach/irqs.h>
/ D! l) l8 ~: B7 l - #include <asm/hardware/edma.h>1 j1 u* }4 W1 V/ ~( e$ c
5 S6 n* u& i: K4 S- #undef EDMA3_DEBUG+ h" m4 O' a" G* l) C! c
- /*#define EDMA3_DEBUG*/
& j% n) ^4 v1 a) M5 ? |+ Z8 ? - 5 k5 `+ Q) J- K4 l
- #ifdef EDMA3_DEBUG$ @ v O0 F* c A1 g7 A8 T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) V; t) e* P6 |; k
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- ?& V4 X6 w" N. e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# Q6 v0 u" _# G+ N( g" z( q
- #else0 C, n/ V [ f. q
- #define DMA_PRINTK( x... )
6 [: }6 I& q1 ]7 `5 `, S - #define DMA_FN_IN
$ R* e5 Q- D2 ~ r; B" E" { - #define DMA_FN_OUT
5 u; x. W# o) k - #endif. p' Y( u5 @9 x: B3 w& ?( y
+ ^3 D6 F1 s3 c7 `$ U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 S1 a8 J: v D
- #define STATIC_SHIFT 3; Y- W b \9 y1 J! G8 a5 M! i
- #define TCINTEN_SHIFT 20
9 F- Q8 y6 e/ V) `1 i4 s - #define ITCINTEN_SHIFT 218 [# ^) R* P) j/ u3 o5 S: C7 K6 R
- #define TCCHEN_SHIFT 220 N! P h5 B3 [$ c3 |
- #define ITCCHEN_SHIFT 23. @0 f- `+ D7 |3 ?! U! N
- 4 \. k$ K/ _7 ?1 O0 I; @! D
- static volatile int irqraised1 = 0;7 C' \- [+ K4 k: Z6 d" o
- static volatile int irqraised2 = 0; i- x* p% T8 X) m% P
- 8 a: o) U/ o r9 X: e
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# S0 I5 p3 t9 l
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 d! W/ L$ c0 O" s+ B) D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 n' w8 o) \2 W. W1 n5 ~
; n6 z: f) L: ^/ G$ D0 M- dma_addr_t dmaphyssrc1 = 0;$ p$ d) c; N% x( `0 r
- dma_addr_t dmaphyssrc2 = 0;1 D' ]. D( i" J4 e- ~- P
- dma_addr_t dmaphysdest1 = 0;
$ Z" @3 r8 K7 u* o - dma_addr_t dmaphysdest2 = 0;
0 q& i2 w0 K% ?- x" v7 ~/ e
9 X2 l$ Q- K! u l# E Y) I: P- char *dmabufsrc1 = NULL;
$ v; u5 M8 o) D Y* U - char *dmabufsrc2 = NULL;9 w& J5 a- C0 W+ f0 a
- char *dmabufdest1 = NULL;
* Z6 @- w# R# c5 x - char *dmabufdest2 = NULL;
1 y/ q+ w1 R2 ]5 j0 I
1 `) t3 k4 f# | S4 {- static int acnt = 512;, V$ B! X% |, w( ^( i
- static int bcnt = 8;
1 y- _, X% W; ?+ t+ v - static int ccnt = 8;
# B1 \' D% ^; G" I6 F. y9 W
/ j* o# ^; G9 \- module_param(acnt, int, S_IRUGO);: f- B* D }; ^' a
- module_param(bcnt, int, S_IRUGO);
8 {# B0 m/ S4 V* C - module_param(ccnt, int, S_IRUGO);
复制代码 * z$ ?' u( ^- B8 [! `5 I
, S* e) Y2 T% A9 v* n5 X 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 f4 o. |- T. b6 @- ~$ A
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% P8 Q* x' C' T8 w Q$ c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 l: L+ g6 S3 N6 s" _# r
( D# _8 `$ W: w; G9 j6 z' v
{ ~5 D" w1 {9 u5 u/ R |
|