|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % W1 r0 p2 ?: l% k
- [code]EDMA sample test application
( X6 t9 e0 b, A+ `5 [3 h - /*8 A) k* _, k8 O% e+ q0 M3 P. Q
- * edma_test.c# I r6 e$ c2 m) o* v
- *( ^. |. C! i) C' X
- * brief EDMA3 Test Application* b$ y5 w5 V" \3 B9 {% D' O+ _1 O
- *
) N, }) f7 S: ]- k+ a: B* p: T - * This file contains EDMA3 Test code.
* x+ q4 X4 K# E, ], n* w5 N7 G - *
. j0 y9 K# P3 y0 Y8 {# g - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 N; c1 b7 ]! B/ b: ^4 } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 ]' B$ X- v& h3 r/ W! s
- * TO CHANGE.
' ]( H, e6 L- D. I$ m* N$ ` - *
7 ]9 }! @- I6 K. M - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 k7 r$ p( ?& |7 {! _; {: g3 n
- *) G d0 w! h9 ]
- * This program is free software; you can redistribute it and/or
; }. t9 x) u% ^) u: e - * modify it under the terms of the GNU General Public License as; O9 o( g" D' p. S% y
- * published by the Free Software Foundation version 2.
. |% E4 B) v9 J( x/ y6 a - * A `3 h6 A3 M( s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' I ?+ J6 V1 p9 Z; E) N - * kind, whether express or implied; without even the implied warranty; r4 v6 D% c& I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* \/ R( g/ ^: S
- * GNU General Public License for more details.
) a4 Y V/ i: r! v( {0 S - */
0 F+ }' y- n' s& @9 y; ]
* Q5 N+ K' m/ ?9 j1 d' r- #include <linux/module.h>
2 z' p5 R: B( C8 @1 ^4 @ - #include <linux/init.h>
- f3 z2 K7 y5 R" f9 R4 _! L: r$ \ - #include <linux/errno.h>
2 M% E8 J" {2 M) t6 v: F2 X - #include <linux/types.h>
: B. m: h# {; _. |$ ^4 P - #include <linux/interrupt.h>
, H* ?, A; r" S! O+ ] - #include <asm/io.h>
) D w2 e1 s7 \6 J8 u - #include <linux/moduleparam.h>5 t; J \" F1 X3 p4 M
- #include <linux/sysctl.h># j% t N3 J& `5 ~+ F" H
- #include <linux/mm.h>
/ U% w0 n. @5 p. F/ ` - #include <linux/dma-mapping.h>6 X- F' M( ~# e9 ?
5 J; O% \5 }: v9 f% |$ x- #include <mach/memory.h>
, R5 w% i- F$ [ k - #include <mach/hardware.h>; w0 t% k2 a' Q8 d. @) ?
- #include <mach/irqs.h>5 k/ r/ R' R9 }* I
- #include <asm/hardware/edma.h>2 L0 N ~/ d( R Y
- % z% p: ^. x! B% R$ r
- #undef EDMA3_DEBUG
0 X" \1 ~& [( k% K* E - /*#define EDMA3_DEBUG*/. Q% \5 o% h( u2 G
- ( c2 i h' @" S. D- n/ Z
- #ifdef EDMA3_DEBUG& Q& W% T! `8 ^4 i6 v
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ Y8 L! q% a4 G; s - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' O. X: ?9 @- {# e8 s9 h; _ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)/ J2 n1 @5 p% w5 ~$ U
- #else ]7 K: ~" ?8 ~$ ^
- #define DMA_PRINTK( x... )
% _0 z0 e5 {/ c' F: @& s - #define DMA_FN_IN+ e6 [# T# M4 t1 | z7 a, j# T
- #define DMA_FN_OUT
c3 }+ G. N; u* O% L$ E. p - #endif
. ?; k4 b4 ^) M/ w4 ~- z2 S - 6 t0 D5 d B8 Z
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 H' t/ n* m! B. m1 J - #define STATIC_SHIFT 3
2 W, y. p- Y+ c0 a6 T5 f o. {$ s - #define TCINTEN_SHIFT 20
7 ]- i: z" \8 d7 S0 F! B- g - #define ITCINTEN_SHIFT 21
& b. l# f9 P; l ` - #define TCCHEN_SHIFT 22) X% @2 t4 p) J; h8 V3 x
- #define ITCCHEN_SHIFT 23. P; d4 H7 e. a3 W+ `
- 4 Y9 O% S# y- E g% Z1 @ I7 c- p( t
- static volatile int irqraised1 = 0;$ y' M) H1 \# O# f% e
- static volatile int irqraised2 = 0;
* a/ z0 S) g/ t9 Z. ?6 m8 o& P
" O1 o! T0 K/ u, v- J( {0 k7 S- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' y% Y7 i% T$ U
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( w+ o7 f3 S) U& I
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& t7 p' [) R1 ] W7 y - 8 I7 a3 t( n8 T9 l6 Q0 V& B
- dma_addr_t dmaphyssrc1 = 0;
9 [; y. u- B3 K& R - dma_addr_t dmaphyssrc2 = 0;
3 u9 G; L6 ` N" W, `+ N2 | - dma_addr_t dmaphysdest1 = 0;
* H f$ b0 Z$ o. J9 O( S - dma_addr_t dmaphysdest2 = 0;
$ I& @. X5 R" v X7 ~' k
% p& o/ }4 Q& |! ?; y# s- char *dmabufsrc1 = NULL;
! f8 l' L+ n2 o6 c9 l - char *dmabufsrc2 = NULL;
9 ~9 x+ X! }0 ^! C! H6 c - char *dmabufdest1 = NULL;
# c+ M/ g: o2 I6 h8 L - char *dmabufdest2 = NULL;
0 w4 M& ]; _$ k! A% ?4 H - V& x& j- _2 a8 v$ p/ ^* g
- static int acnt = 512;$ {3 c L8 |6 [2 r3 m
- static int bcnt = 8;# j, U. A, P0 }& {7 F& d$ L% Y- y3 |' m
- static int ccnt = 8;
* v" |* C; ? D' M: \0 ]0 N& K7 u - C' C4 P! t# J( |" c
- module_param(acnt, int, S_IRUGO);1 N& H% ]7 O& n- \9 L) V7 w
- module_param(bcnt, int, S_IRUGO);
, ?' P; P4 [- U+ A* R! s/ X+ z - module_param(ccnt, int, S_IRUGO);
复制代码
, F. W: N- u/ y' C O3 w- L9 a5 o" _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 g- _2 e* ?! ?" A- B( o1 J( F
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ v' V: Y$ j( |2 |( A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# X% B3 z; U, F( W7 V, y. j6 Q) P! R+ Z
( H. k/ y5 N% x0 z [ |
|