|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) r- D3 ?( v; w5 C$ a6 h8 z
- [code]EDMA sample test application" K7 o( _' V# j* m$ Y
- /*
# _! m7 d% U& T6 l - * edma_test.c
/ l4 u4 |- O- ?; T" K2 C; Z - *
1 Y( p; S2 A6 O3 h& u& X' m - * brief EDMA3 Test Application: m) G3 b' P0 ~; ~' w4 O. z1 h
- *
$ E4 R3 }3 ~+ X9 S" |6 ~. { - * This file contains EDMA3 Test code.
/ ]3 Y2 F! P4 V - *
9 B3 w1 E8 X; \5 b( ] - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% U7 V3 [+ k! {2 U* Z3 l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! j. f& ?; I+ t# X1 ]& H - * TO CHANGE.7 x0 P" ]5 i$ ]
- *4 }3 X. Q3 C" ~- [* z- s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( X: O- H' ?6 p, } - *7 x# c1 g; _* U
- * This program is free software; you can redistribute it and/or
/ \, ]6 @- [$ o0 T, } - * modify it under the terms of the GNU General Public License as9 r( K! Q3 d$ @1 U
- * published by the Free Software Foundation version 2.
; Y+ D: F5 ^) F; P, S" @ - *
! o- N- L9 z! H! b8 K( K. B - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# K! j7 f4 a* Q$ r - * kind, whether express or implied; without even the implied warranty# Z4 M( F/ L9 q* _: X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# x, e7 S2 D0 s- U: h& P$ @ - * GNU General Public License for more details.
2 F4 Q7 P. U4 y2 \% A - */
5 S4 L, r0 C3 \ [% o4 b2 p - 4 ]3 H$ G$ m" C! _( y: m
- #include <linux/module.h>& o* D. j+ ~- `: q2 N
- #include <linux/init.h>
+ C/ q+ S6 ?; n. }. A6 L - #include <linux/errno.h>
' \# i+ P4 c Q0 ~ - #include <linux/types.h>
) k& F! D( O N% X$ b4 W+ o - #include <linux/interrupt.h>/ {4 O; ~, k/ a) [. \6 k" W) q2 d
- #include <asm/io.h>! u1 e3 T3 u% h8 L0 H# ~2 Q3 g
- #include <linux/moduleparam.h>$ R. o5 v5 {" N& t* L
- #include <linux/sysctl.h>
4 ]) ~+ b) `9 M! ? - #include <linux/mm.h>
' M- \0 k5 z n7 ^0 W* R% t - #include <linux/dma-mapping.h>
, P! _2 a l$ ]3 N# x
" t- w1 r i' T% p: ^/ R: b( E( ?- #include <mach/memory.h>) C( P( J0 j7 [
- #include <mach/hardware.h>
/ M1 n6 q8 L& q x2 [4 ?! z - #include <mach/irqs.h>
- j1 ]0 O( A: y, ] - #include <asm/hardware/edma.h>
9 s' `2 f0 c a: X
$ J" L- H; c3 ~5 V; C; f- #undef EDMA3_DEBUG+ t! ^! s! D2 v# J
- /*#define EDMA3_DEBUG*/8 a. F- t$ N5 m3 \9 g
- 1 q( @8 m" n" A- Z; P6 S
- #ifdef EDMA3_DEBUG9 @9 @1 Q6 ?1 O( ?* C1 y1 B$ V$ l1 O$ c9 s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 {& _2 d( y5 x |* R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), E9 ?$ o: X/ E7 K" Q" |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 _6 a9 Y5 w" A& \6 c. ?* N - #else# y, E+ Y6 u6 W
- #define DMA_PRINTK( x... )! U3 o& n$ r( h W9 j
- #define DMA_FN_IN7 u4 j- [, B/ j6 G2 T
- #define DMA_FN_OUT
. |" ^* O- [/ a. P - #endif
/ n+ s4 l' u F3 H' @& g8 ` - + G4 y8 }$ E: v! y7 R3 o- H/ @* G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! g2 |' X4 l& J! P0 p* b$ X
- #define STATIC_SHIFT 3
0 ^ E5 v9 d( d3 ^7 L8 `6 { - #define TCINTEN_SHIFT 20
. s5 s( ?7 [, f* ?) D - #define ITCINTEN_SHIFT 21
. z$ q+ Z+ r/ U - #define TCCHEN_SHIFT 22
+ V. B m5 }( @4 p! \8 O - #define ITCCHEN_SHIFT 23
8 O" K% k2 D" t - $ Z* `% X% O0 q" ^
- static volatile int irqraised1 = 0;" r3 S* ^" h. l9 n* s i0 }4 L
- static volatile int irqraised2 = 0;
! {- n5 Q) N+ Q, B
* a0 i, Y# ~2 A- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: G1 o9 a7 g7 z1 e) U, G - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! S2 o2 Q& o( X! |& y2 }: v7 J
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ \/ y9 i* k- m
- " @1 ^& p( w% P5 _3 r
- dma_addr_t dmaphyssrc1 = 0;
0 d h+ X1 o! b8 y6 l - dma_addr_t dmaphyssrc2 = 0;! l' A' q6 x6 `$ f w
- dma_addr_t dmaphysdest1 = 0;
+ ?/ b: w! m' L, C6 T - dma_addr_t dmaphysdest2 = 0;+ V8 l% p- ? {! |) t8 U" f: S
- 6 Z; e3 U6 p; u" g( z3 }! P5 p! v
- char *dmabufsrc1 = NULL;
$ Q- i1 a; T7 ~( k f/ b - char *dmabufsrc2 = NULL;' k- f' ~6 x7 y
- char *dmabufdest1 = NULL;
& D) a5 T% D- e: E$ Y( T2 H - char *dmabufdest2 = NULL;
& x% T$ l1 e) h% P( V - 9 Z2 t) P, G7 {
- static int acnt = 512;/ J6 C( @5 V! @. z
- static int bcnt = 8;& i) G S5 W) N# Z0 `) k
- static int ccnt = 8;
4 ~, b) O* A/ M9 c% t
9 F3 O; l; d6 G& ~0 U! l- module_param(acnt, int, S_IRUGO);7 b) {3 k. z" ]5 x0 Z7 k3 u
- module_param(bcnt, int, S_IRUGO);
% F t% @* p/ K& A+ e: A - module_param(ccnt, int, S_IRUGO);
复制代码 + w" O: e' Z6 G L, M
) q/ b- U6 `9 J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 o4 P7 f) j2 i& u2 W
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* Z7 }; ^0 I' F, V2 L9 p2 _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& C1 Z- J5 n2 ~1 G3 d e% u& B' A- C
7 N8 s* F7 ]/ p1 y4 U4 V8 t8 W7 N: e, W( k
|
|