|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 k4 L) V/ }# T+ R) Q( g- [code]EDMA sample test application
% |8 R+ m6 Z, T0 Z: R - /*
/ {4 u% V3 O1 d2 Q( Z, f0 ] - * edma_test.c" H7 a4 V$ F: B3 d/ @4 \
- * G: Y6 A1 A1 T9 c. v
- * brief EDMA3 Test Application* H9 Q% N' d1 p: }5 }
- *3 i) O# ?- ?# X3 v; }
- * This file contains EDMA3 Test code.' F. v( I4 ~- q7 b: ~2 N
- */ `" g2 Y+ q* ?# B% @; u/ W& c
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 \' ^7 L" O1 n: y ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 V6 [ s$ c) n7 U7 ^% V
- * TO CHANGE.
9 R- W! n( q9 E" t9 ^' W - *
f0 ?3 _* N) r( m! u) B1 i - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 _& |" h( h9 \ - *1 M7 x8 T- [8 j2 T* X. y1 e# @% w
- * This program is free software; you can redistribute it and/or
" y9 `0 Z+ f* [+ d( J7 v - * modify it under the terms of the GNU General Public License as
: I4 [2 K' ]* r2 b$ C - * published by the Free Software Foundation version 2.: }& l7 D, z% H% ]7 P' M& x: v. R9 T
- *
& {. u* |( O; O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 r% f" |, B; y- N w% T
- * kind, whether express or implied; without even the implied warranty
% e/ z* X( s: I) b( n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 k$ u K/ N8 y5 }& h - * GNU General Public License for more details.% i3 T2 b& i- M! N* J8 J
- */
. ?( F8 s+ d( v/ L" n
/ z3 M- c! |' l0 x/ c' ~) C- #include <linux/module.h>) p4 a( E W; e
- #include <linux/init.h>
' _" V: q; ^- A6 P# V8 s7 ^ - #include <linux/errno.h>% u( ~. \* y" x+ r" C; ~& f3 H
- #include <linux/types.h># r! ?+ `+ L2 ~. T# R( i0 r
- #include <linux/interrupt.h>
. v. a) K6 ]: W8 I - #include <asm/io.h>
# [6 S: u4 g# N7 `: u - #include <linux/moduleparam.h>1 @1 M* ~" v# M- C( S/ W
- #include <linux/sysctl.h>
5 u' x1 P& W$ Y4 q E- `7 n7 z - #include <linux/mm.h>' Q9 Y P) e$ ?4 i$ M
- #include <linux/dma-mapping.h>
, d0 a9 b9 T* J/ Q8 M; L( X! @+ }+ z
4 h8 h& G. {. m2 {( @; k) z- #include <mach/memory.h>: R8 h: d2 F9 B; ]
- #include <mach/hardware.h>
& c" h0 B2 U4 L7 U) A1 q/ t - #include <mach/irqs.h>
9 n% l0 e( F4 p# F/ b/ c5 V - #include <asm/hardware/edma.h>2 L2 a9 |( l& e8 V, A, k. c% I
! J+ Y n: ?) [# t6 p& o+ R- #undef EDMA3_DEBUG, c8 ~9 j3 M- T5 A
- /*#define EDMA3_DEBUG*/
- F! H. T5 w' U K - & T n( Q8 x9 N5 M$ U( D7 w
- #ifdef EDMA3_DEBUG
- O" C) J! K% f3 a- C x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); Y% ?7 E# L. M# Y i7 O" t O
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& f8 G% K7 J1 f4 M. i n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)1 N+ ]" }# ?4 q' }4 a# n
- #else
5 W# X- S# B* q+ b! O3 W - #define DMA_PRINTK( x... )
" C: \; D( a$ C - #define DMA_FN_IN; _8 C0 ]' n7 i7 q
- #define DMA_FN_OUT( J; v0 Z* ^7 G
- #endif1 T7 I2 ^6 R# s8 G
4 p* ?; I; ~: V: X/ K( @2 R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
( o, L3 y! H! s# t) Y - #define STATIC_SHIFT 35 A0 F+ o: {6 ~" @- U0 K5 p
- #define TCINTEN_SHIFT 20
$ X, Z" h% A' x! T9 [" Z - #define ITCINTEN_SHIFT 21! c& A: I- c: N! x
- #define TCCHEN_SHIFT 22
4 Q9 y& e6 G8 Y9 }. z2 r# P - #define ITCCHEN_SHIFT 23
8 R' U9 I) X( {2 P1 [7 ] m, [7 N - 9 {, C1 p) j9 t0 x
- static volatile int irqraised1 = 0;# W4 J `& o# f2 Y
- static volatile int irqraised2 = 0;
- A8 d3 X& ]7 W7 C/ J
2 m. o" a& |- G# a4 i8 O$ K% a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% i$ H3 ~" d! |) b% v8 q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 w$ i- `1 w& x+ k
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 k( _$ x- g+ G0 Y( } h+ U: e - L" E) S1 l% [8 t. H+ |* b
- dma_addr_t dmaphyssrc1 = 0;
3 K- ]5 K5 p* o- J3 [8 b - dma_addr_t dmaphyssrc2 = 0;
: T8 u; D' `# F: J+ T, i - dma_addr_t dmaphysdest1 = 0;* I1 M2 ~& i5 H/ r. P4 S, A5 b
- dma_addr_t dmaphysdest2 = 0;4 U$ i8 G9 \$ P9 w# A
6 I3 @* A! o. y" H: ^* u" O9 g/ ~- char *dmabufsrc1 = NULL;
4 l* M P. T! U+ i - char *dmabufsrc2 = NULL;6 ? [# q/ @/ x: |- h8 a$ @
- char *dmabufdest1 = NULL;: {( K) Z; \7 {8 }' S6 ^# D
- char *dmabufdest2 = NULL;; l& B! C4 w% t
- ( G4 U6 Z0 X: L0 o" p6 ~
- static int acnt = 512;
9 T4 v- l) {$ t" w8 X - static int bcnt = 8;! x, G# F A0 K
- static int ccnt = 8;3 R' R7 L8 G$ ]- r& D {3 c
1 Z& V6 k' G+ E0 n j- module_param(acnt, int, S_IRUGO);, D! O N+ F! a7 I, {. ]
- module_param(bcnt, int, S_IRUGO);6 m7 j. o9 `5 z9 s/ c' h
- module_param(ccnt, int, S_IRUGO);
复制代码
; p, {. Y" U" O; U0 ]& I' I5 h, y+ x( ]: K# h; m, c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* ^# s6 ^7 b6 Q/ ~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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 H0 ]; Q2 L# q I9 K4 l2 E, m1 O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 F/ O. p! I; x- A. U
1 A% t$ s3 C) q6 l- ?' h
M+ Y8 R$ H# N2 f |
|