|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 |" ?( Z( q& x& o, Y& m- [code]EDMA sample test application
/ V5 H+ V/ d% { - /*- X% F/ A }4 `( e
- * edma_test.c
5 `/ h" Q9 l% _* l, M - *! l& Q# V9 ]6 A6 o' _ }' g
- * brief EDMA3 Test Application
$ `' F. H+ L4 X) I, P: Z - *
1 S1 v/ b$ o* o9 N$ |0 \ - * This file contains EDMA3 Test code.
) T4 K' X! q! F# L) S3 f - *
2 q) [2 {4 @+ |! f2 U/ y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 B: q3 g1 T6 y& r* h; ]4 L
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 V r* t, t* Y, }- ~4 o! K - * TO CHANGE.
. V w7 n2 N* K: d" n - *) J# i) b* I! r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 K* R% A# G q: a- s3 a - *
! _' q# X$ G& t4 N# u - * This program is free software; you can redistribute it and/or
- w0 ]' ]! Y5 e3 a& b, q- u% o+ t [ - * modify it under the terms of the GNU General Public License as; R0 c) s" P! a/ Y
- * published by the Free Software Foundation version 2.8 Y: }' Q7 H5 z4 ?+ ]
- *; L* `9 Y- B& u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 [; j; b$ d& Z6 R3 T3 K+ ~ - * kind, whether express or implied; without even the implied warranty- U2 P! r- u; h
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 L. Y# V: g) Z
- * GNU General Public License for more details.
; M! p) T6 _1 v5 ~+ c - */
2 b0 K! i; g: R" a- d
+ R* t; X+ \# k4 m+ C1 b% y- #include <linux/module.h>
* Z. z( E& |; C/ e9 V6 @ - #include <linux/init.h>
6 }1 A* a* D) f - #include <linux/errno.h>1 l3 w; z' j6 t! O, y7 h
- #include <linux/types.h>0 i7 x$ B( q: i1 P
- #include <linux/interrupt.h>1 S. I0 J) l9 z: j. \! u' P
- #include <asm/io.h>+ V/ L5 \ _3 Z' U1 @& u( P. z% ^
- #include <linux/moduleparam.h>, `: k* Z: V5 B8 q
- #include <linux/sysctl.h>0 H# x L. A$ N- _5 x1 H
- #include <linux/mm.h>
2 @- z+ z. F& i7 K$ U1 U - #include <linux/dma-mapping.h>
( V1 I9 @- _9 F& E6 I - 1 K5 N. e* m$ X, p
- #include <mach/memory.h>
; M1 u7 Y4 m, L' y7 v, s - #include <mach/hardware.h>
7 T9 d0 {0 R3 [' n5 z# ^ - #include <mach/irqs.h>
1 y2 I% ~/ ]! }) K3 E: A - #include <asm/hardware/edma.h>& z5 ~) m+ t; V1 H- D
9 B( m, y% }& ~( |* @- #undef EDMA3_DEBUG/ `7 s* W: X: E; g
- /*#define EDMA3_DEBUG*/
6 P0 Y5 Y7 L5 G5 n+ B0 V J - # ^, p! R" L1 _, q3 c
- #ifdef EDMA3_DEBUG
# T/ l* W' h, R* {! y) u - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# y# [- l' _! ?
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' X. Z4 H$ m1 i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( A( ^5 F- C1 @5 {
- #else
, P" N, x6 F( l - #define DMA_PRINTK( x... ). n% U' Y, m( C2 j' \" }0 r. j |
- #define DMA_FN_IN; D6 g6 B: {& e0 f
- #define DMA_FN_OUT) U2 _' s' _ W# ^9 m: t% Y
- #endif, i3 ?' S/ C& \+ k
- 5 I2 @- U6 M" }9 E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( E+ a* s5 m7 F; d5 A9 w' \ O
- #define STATIC_SHIFT 3
* h1 p) R8 Q" I+ c7 _7 j - #define TCINTEN_SHIFT 20( J0 H/ b d, y! _/ }: s
- #define ITCINTEN_SHIFT 213 A/ B. o$ C6 W8 b) {, U1 j
- #define TCCHEN_SHIFT 22
" M: F- K) o5 L: {. Q' f' L - #define ITCCHEN_SHIFT 23
* J {) e0 H! L3 {
9 g' c! C9 d$ r9 m% G- static volatile int irqraised1 = 0;# C9 b! `4 D0 l4 i9 D6 l
- static volatile int irqraised2 = 0;9 T: B0 H+ c4 o/ O0 \% o
: {/ N* M. R3 p+ j3 E% r/ q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# S+ [* s# E1 A9 | - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* F: T% C* `9 c8 w! Y& a
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ L& q4 P/ X0 A% E6 @' i$ x
- + L0 V. P+ t, S8 l
- dma_addr_t dmaphyssrc1 = 0;
5 u3 X4 F7 `* s# f - dma_addr_t dmaphyssrc2 = 0;7 P: o9 `7 H5 e4 [% `
- dma_addr_t dmaphysdest1 = 0;, f& \( L* o+ }+ \1 x& M5 r
- dma_addr_t dmaphysdest2 = 0;& x* T! J" K5 Q2 c: n
% n# b3 _# v" C$ Y( d- char *dmabufsrc1 = NULL;
3 N0 Q! H& F2 P" ~" | - char *dmabufsrc2 = NULL;
% L' C( r4 ]5 F) I& ? - char *dmabufdest1 = NULL;* s, ^, `. I! c& @
- char *dmabufdest2 = NULL;) | p3 j3 Q# Q- Z& {
, X: O( Y: x" z- static int acnt = 512;
& |- C) a- X! Q Q - static int bcnt = 8;' Y2 V8 C! J# ?- O0 r8 Z
- static int ccnt = 8;, ~6 `9 A2 Y$ g0 M* L, M
~* j5 [* ^! e6 d) B7 K- module_param(acnt, int, S_IRUGO);6 U* [7 l2 n( ?9 }8 w
- module_param(bcnt, int, S_IRUGO);5 `- ?% ]! V1 D+ Z) f
- module_param(ccnt, int, S_IRUGO);
复制代码 + Y/ k5 N: s* p; Z) I0 T$ \
+ L7 a. k4 B7 K. k/ U+ X% I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 J, P* z/ Y2 z5 i
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- \/ |% o7 p* K; x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ Z+ D! e: Y! L+ ]1 V( ]
, |* p4 t. I! j+ f( {2 B
5 M& ]7 I# ~4 M" A |
|