|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , x$ r( _) h1 n6 h
- [code]EDMA sample test application
2 k; i; s7 j+ n* I# g i, N, I6 s - /*
A) D# c) o& T& S% z" F, p p - * edma_test.c
- ^( j" U0 e; F* }8 [; Z9 i3 K. a - *4 t# K! f2 v; S
- * brief EDMA3 Test Application' F- k" S5 d8 _/ s! _- V/ t3 u
- *
9 D/ M) h; h! P# n- e; B - * This file contains EDMA3 Test code.
7 C" L% G2 p& M' J - *
8 @7 _5 Z+ R1 U; l# l4 J/ t1 k - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& i/ B2 E% x3 r8 d - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' s. e( N i: k( _, N" a - * TO CHANGE., F, E H* d) c2 b1 i& z6 J
- *
% x) w9 Z: z- G2 |4 }8 b - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. _9 F) h9 i) }) s7 y) W2 I
- *! k& a5 R% z& t, _
- * This program is free software; you can redistribute it and/or; \9 E3 v/ B& H C9 W q
- * modify it under the terms of the GNU General Public License as
( M& ~8 d* N; [$ s - * published by the Free Software Foundation version 2.
' B5 @9 h% \! O9 S/ u) d - *
' r( E0 U( d. W0 } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; x% C! P- ]* l- c# [8 w- s l
- * kind, whether express or implied; without even the implied warranty
% v v( e1 z, G H - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ q% G8 K) N; ?: ?! u" d, r: j - * GNU General Public License for more details.
7 Y/ u5 C5 u3 F8 Q9 l - *// r* ^$ ~9 p: ?0 J Y
% e$ K: T# }% Z" _& r4 |- #include <linux/module.h>$ H5 e# q) X, E
- #include <linux/init.h>
5 v3 \/ e1 H. G' L! q4 n( z& i& B - #include <linux/errno.h>
) q6 D- Z* t) ?' K/ v - #include <linux/types.h># ?5 N2 t1 t4 @- i" n
- #include <linux/interrupt.h>
7 O+ N/ z ?6 }9 @8 \7 Z0 D - #include <asm/io.h>
6 {9 f* w, `& {0 u- F - #include <linux/moduleparam.h>
9 r$ j K5 q! c7 M! w) S! o& Y - #include <linux/sysctl.h>- S$ K O6 x" u1 g' v0 T
- #include <linux/mm.h>
' X% P& d7 Q, P. w - #include <linux/dma-mapping.h>( _$ q# b% C9 h" l
- 6 d$ \/ P' Z% Y4 M5 b! }
- #include <mach/memory.h>
7 q- m/ |+ c9 z1 K - #include <mach/hardware.h>
( P) C A& D3 R1 U - #include <mach/irqs.h>
1 `3 _6 {6 R1 r5 W - #include <asm/hardware/edma.h>9 }( L6 q1 ]: r3 Y: W
- # y8 |" R* i4 {% s
- #undef EDMA3_DEBUG1 B0 ~; {1 z/ a. K) h' k# N4 l& ^
- /*#define EDMA3_DEBUG*/4 }# j2 U2 d8 y+ a
- % N8 V3 _4 v- B: G" S# c
- #ifdef EDMA3_DEBUG
: I; b* s5 h3 F3 S9 `9 C# ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ }4 V2 w9 o3 g5 Q6 k4 m/ g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ ?* u% {/ E: F# H& l" x( _2 q$ n- C
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 r8 G% s! x/ B0 ~ - #else7 J/ e$ `1 h8 r: n) N% m* S
- #define DMA_PRINTK( x... )0 [3 o# h( U% F0 N/ I5 q) v
- #define DMA_FN_IN
& R3 T6 u, `- x9 R0 ] - #define DMA_FN_OUT$ o( U7 \7 p( q( w6 |) m% ~
- #endif
3 i8 X2 D' x) X9 R' |) z
; Z( u+ A; f& T) {/ Z3 G: k- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: \7 i3 D* T" P3 c3 M" {0 v5 p0 ?, U - #define STATIC_SHIFT 3& A5 [1 c, y, l3 ~
- #define TCINTEN_SHIFT 20
( i2 v' _+ H: F- A: a. F - #define ITCINTEN_SHIFT 21, d. |6 C$ a/ x5 G% ~
- #define TCCHEN_SHIFT 227 X& ^& w) j2 R+ W1 Q4 X" y
- #define ITCCHEN_SHIFT 23
7 _+ u2 X {; e: _7 J& L - + {6 R9 m [- k% o: k
- static volatile int irqraised1 = 0; N+ K- `3 j9 ?' V6 b
- static volatile int irqraised2 = 0;
" L: N$ j' A& F7 q- o# {2 ]
& W3 A5 @7 Q- j$ [% M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 C; Z- T( Z9 }8 [$ i W
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
}+ {; ?( u" r% C! `* K; L7 E# f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ S) q4 L" `5 g - 9 s x/ X% N$ `6 l
- dma_addr_t dmaphyssrc1 = 0;
) G4 Q- G B0 L$ I; l9 J/ O - dma_addr_t dmaphyssrc2 = 0;/ e0 s4 d) A) t' o
- dma_addr_t dmaphysdest1 = 0;, O8 E8 l( [* s s; i+ G
- dma_addr_t dmaphysdest2 = 0;+ x0 C2 J( K2 Z; O7 I! B
- 0 p( x7 h0 ^2 |7 G
- char *dmabufsrc1 = NULL;
4 Z6 k3 e9 Q6 l - char *dmabufsrc2 = NULL;
* J0 o; v& ]' @, `+ a - char *dmabufdest1 = NULL;5 R/ o0 E1 I- ^" ?
- char *dmabufdest2 = NULL;0 v: z. ]& z; k* p1 m1 i
' a/ Z- W+ h! ~9 j5 o- static int acnt = 512;
% i: `3 x6 |8 Z: p - static int bcnt = 8;
- x( A2 `: {. u - static int ccnt = 8;( N% K& A) F& h
/ @" @6 A1 C/ i; N9 q- module_param(acnt, int, S_IRUGO);
0 F! I* l7 G$ X - module_param(bcnt, int, S_IRUGO);/ w% ~/ o! O" F m" n/ u& X2 n4 b
- module_param(ccnt, int, S_IRUGO);
复制代码
) J# J5 D- K5 X) l- A5 k. F
) k% o2 f. A! g7 u3 j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, S7 V- N/ x" U- h( qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! |; h4 a+ s: q; [9 {5 o
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 ^$ U/ D0 w+ k) x
1 A/ ~- ~* L8 L2 J5 q
' S: B% I# S( A$ v) R+ k, p! @ |
|