|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 O, y# Q5 E# M+ y) Z/ ~- [code]EDMA sample test application1 i. p6 a5 s& ~; l. y
- /*8 ], J4 \2 ^' i2 n2 s
- * edma_test.c3 H; n4 U3 V3 j5 G
- *
" s9 o; p1 \! M1 ? - * brief EDMA3 Test Application, x; X U5 f, F8 q; N, E
- *# {& _: i B( I3 {: ^- E
- * This file contains EDMA3 Test code.
' T! j! S* q2 M8 a: |8 Y- a) T8 w& k - *( D- h# x i! @. h, `: S
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
T8 h* x% _% ? - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 I: Y5 U+ {( o9 u s3 w% o7 z
- * TO CHANGE.& e8 B4 b* _: w$ e5 w
- *6 i2 N V3 L/ f1 O2 [/ N
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- y5 b+ R. W) p+ w
- *
$ p) x1 z4 u6 H, v o8 \$ W - * This program is free software; you can redistribute it and/or L4 U" K1 S% H, V
- * modify it under the terms of the GNU General Public License as
4 o- B% o! U& U# ~5 ]) g - * published by the Free Software Foundation version 2.
: s/ h$ U7 e% A& q - */ h5 {1 n1 T& T) j! z) f
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& ^" x9 Y ~4 x7 o/ m - * kind, whether express or implied; without even the implied warranty9 a0 ~/ ^6 r* F2 z& R6 \' V- b
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! L8 L( Y# s9 L: H l - * GNU General Public License for more details.) P0 Y: L' W1 q4 H! _
- */' E1 v& |5 x, @ ?: G* ]* [9 E, q
- & D- D, H Y7 p! m
- #include <linux/module.h>1 i6 D2 v! s. N% i* g# r: N8 o X
- #include <linux/init.h>; x/ o; t* n0 P c C* K; d/ w
- #include <linux/errno.h>7 a0 |1 ^4 d- D7 ~. p
- #include <linux/types.h>
+ |7 r( o T( y$ Y0 N% Z+ F" n$ D6 K - #include <linux/interrupt.h>
5 r5 k: N4 d8 Z- W2 ^2 k - #include <asm/io.h>
0 ?* K4 q4 p5 y8 C - #include <linux/moduleparam.h>
. A3 |' T6 {9 _' c6 }- I - #include <linux/sysctl.h>
- H7 G1 L! h1 ]. c - #include <linux/mm.h>1 [3 }$ ?9 j- X+ g; h
- #include <linux/dma-mapping.h>( f) p5 t: }* b; }
- * @4 J! P! j' C* J
- #include <mach/memory.h>
; ^2 H) W/ o$ `5 c- _9 m7 {" b) e4 r - #include <mach/hardware.h>
& d5 p F- c @4 E7 S) G. Q2 Q - #include <mach/irqs.h>
6 D' S9 X; n1 o7 K5 d" W - #include <asm/hardware/edma.h>9 C u2 c/ }, R- t
- . K* Z, g# h2 j% s/ q# l0 w
- #undef EDMA3_DEBUG( y1 u: E( a/ T) x& O
- /*#define EDMA3_DEBUG*/4 z5 {8 k* l$ w( {4 I. V) i) e
- 5 }! |2 @, [( v$ x0 |& H. G' G
- #ifdef EDMA3_DEBUG3 j, X1 }# T' M" Y" n/ ?$ d! |1 f
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) p l$ }% {- E3 D, |. O7 H - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 V) \2 d4 v5 h' z6 a
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% G+ ~+ |3 F) E1 C6 v" r( }7 z
- #else
G& {' ~' D7 \1 s+ m - #define DMA_PRINTK( x... )
) \/ l1 H1 s- [: Z+ q8 D( M; O - #define DMA_FN_IN
6 P' t1 e+ z9 \# o$ L - #define DMA_FN_OUT. X* }$ ^. a! `# l
- #endif% R6 y6 Z' l1 Q* ]7 x- T
. M: z, L, }6 g" {' L# t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 O( M8 W, n1 l
- #define STATIC_SHIFT 3, l# t: v- V% x: i5 I
- #define TCINTEN_SHIFT 20
4 E% o; y+ H! h. x. N! B+ D - #define ITCINTEN_SHIFT 21
+ H( l5 E8 |) r: q: T+ O# W - #define TCCHEN_SHIFT 22% `* P9 j) T" d0 J0 P3 j: e) m; [" w
- #define ITCCHEN_SHIFT 23
" H. q7 t# [% j" ^3 d - ' C3 o, ~+ ~7 H
- static volatile int irqraised1 = 0;- h( X% [* X/ F- d6 O& w- }7 B
- static volatile int irqraised2 = 0;0 }, z9 l |! s- {+ t
- - [* s. u3 _ R& i
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ i/ \7 {7 a2 Q7 y' F$ P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 `9 a" U e! X5 W
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 `/ \4 Y- i* Y" N
) c$ j! Y' q8 a$ k- s- dma_addr_t dmaphyssrc1 = 0; ~- w6 Y6 a! M* {" B
- dma_addr_t dmaphyssrc2 = 0;1 v3 q! l% S( S$ Z: z1 E M, \
- dma_addr_t dmaphysdest1 = 0;
& k* f) |. }4 w5 P - dma_addr_t dmaphysdest2 = 0;
0 Q$ M+ G, n; g, N - 4 [- P: ]! I5 X, B& ]
- char *dmabufsrc1 = NULL;
+ @( u. t9 `! ] g* M - char *dmabufsrc2 = NULL;9 P! h# N7 Y! H; T
- char *dmabufdest1 = NULL;
0 L% b* g. r1 _ - char *dmabufdest2 = NULL;
5 Q3 }4 U! U- x& Q
3 H4 Q0 h+ _ ^0 h- L! H7 Z% g+ L! i1 i- static int acnt = 512;
: r% E2 e* f/ t% ^" N1 j - static int bcnt = 8;
9 J; Y- {9 p; o$ ?" ^! k) [6 ?" c - static int ccnt = 8;
5 B* k0 W1 E& `+ C4 w - 1 L4 n* @0 Q5 {. L, _2 Y$ t7 d u
- module_param(acnt, int, S_IRUGO);
1 C ]9 U b& ~/ t3 a6 u - module_param(bcnt, int, S_IRUGO);
/ v3 j U U$ B4 O - module_param(ccnt, int, S_IRUGO);
复制代码 8 m8 }' w6 M" m w+ H, v
* h7 p! _5 Y7 Z+ _# f* U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ N& @8 j- K6 l# R" {5 ]7 Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' i) _5 o" r: ]6 X0 ~$ A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 b9 X+ K) V7 I' X% y$ h
0 \+ ]" o- q' s- {, I2 T! K7 X( s) W' z0 u
|
|