|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % o+ C0 Y, i. J5 t- J
- [code]EDMA sample test application
) t0 D* _ C8 {5 Y+ j7 S - /*
' V* h) A$ O% s+ w6 [; r8 R - * edma_test.c/ D1 u6 f# y. u# _0 g
- *+ W: r9 I7 C0 ^1 ]) m. D
- * brief EDMA3 Test Application( y: d$ P* A6 h7 V+ u( e7 Y1 U
- *
& d) J* ^/ w. A/ T0 N6 f" s4 _ - * This file contains EDMA3 Test code.
8 @7 ?1 j8 U. r0 ~% ~$ U - *; m" Y* f8 R1 [2 r
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 I, E1 c9 j6 x! e _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 M# Z0 s! S7 S' b( K
- * TO CHANGE.. ?% m* i# H N
- *
3 ] R4 }3 \( ], G# x3 b - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) d; |1 ]) G K4 J K - *
) F& G3 k; p! [, D - * This program is free software; you can redistribute it and/or: E0 d3 h& K3 W: y% |0 F
- * modify it under the terms of the GNU General Public License as
. S/ {( J0 }5 f) U1 i0 r: p - * published by the Free Software Foundation version 2.$ k* c! E3 X3 c" ?' t) d3 W( O
- *
" D1 r0 E6 V9 ~# p+ \$ R! j1 S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 n2 ^& F( X: c! p, Q2 v" S
- * kind, whether express or implied; without even the implied warranty
6 A" X# }9 k% t9 h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 L/ d& ]- U+ p" [5 A, p3 T# Z( n2 ^ - * GNU General Public License for more details.- d7 J% a+ X4 u! h0 Z7 z' @2 |
- */: h: a/ |/ N2 `. Z6 E" h3 d0 u
. N2 F3 V! M. \0 z8 S- #include <linux/module.h>
$ t# n8 Y6 I. E( L0 k7 z* c6 {, @ - #include <linux/init.h>- c* b8 F* l2 P! G# T9 \! l
- #include <linux/errno.h>( B9 W$ ^. f8 I5 V
- #include <linux/types.h>
+ G. E# t& k! t: t - #include <linux/interrupt.h>( y4 V2 U0 A% R$ W/ b u/ t
- #include <asm/io.h>
7 \, r' d0 k* W8 F% L: l - #include <linux/moduleparam.h>
( M# ^7 e; h* s0 n- Z - #include <linux/sysctl.h>
# G& u8 K1 N7 `6 c4 ^! M. L - #include <linux/mm.h>
1 z T+ J2 _: `. Z - #include <linux/dma-mapping.h>$ ~, Q- z& R1 h
; C( ^3 Q/ M/ j0 ?8 j$ c" }- #include <mach/memory.h>3 o0 ]. ~5 {6 R; P
- #include <mach/hardware.h># C2 O* Z% U3 P2 r, p9 c/ p4 [4 G
- #include <mach/irqs.h>
; o7 H, z4 y5 } - #include <asm/hardware/edma.h>, Z% m, z) ~9 U4 }, h" S4 I9 K
. Z1 a8 b* b% R/ J. f9 F" c- #undef EDMA3_DEBUG
* X/ ?. P- T$ i* C, h/ w& E - /*#define EDMA3_DEBUG*/. d# A5 X: w& s# X; {& ]
- 0 ~$ k1 K* A8 x/ n' J9 ~% h
- #ifdef EDMA3_DEBUG% o2 C5 W* m; I" }0 w6 v, O0 [
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( P4 R5 Y5 o, f4 v1 |% P - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): f" O/ `! P+ ]" ^3 o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* W2 F* Y6 A* @
- #else
4 W$ z1 N7 Q0 t! C0 E0 z' k - #define DMA_PRINTK( x... )
3 J+ P D" ?+ |6 @: } - #define DMA_FN_IN; `4 ]" i6 d. P
- #define DMA_FN_OUT
$ L" P( }) O3 r; R% O1 Q/ H& J+ r - #endif
( p+ M! q5 _5 k0 J - + [3 u: E$ V* v% I
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, Q/ X/ b0 {) ~) b- P& K - #define STATIC_SHIFT 3- K5 D( K1 K) c
- #define TCINTEN_SHIFT 20* e! ^8 g8 t8 y" O( \
- #define ITCINTEN_SHIFT 21; c% {" f8 W( |5 V \! K& B' e/ t$ r
- #define TCCHEN_SHIFT 220 {. R9 Q! P$ b1 R8 Y) N
- #define ITCCHEN_SHIFT 235 S* r! P/ T5 c+ H8 E/ D1 G
- ! @" s; T; x! W
- static volatile int irqraised1 = 0;
7 X% |6 I3 o8 W, {) }, \# g9 D - static volatile int irqraised2 = 0;" ?! @0 L7 d. `5 z F5 U) ^
8 w$ n5 T( M l. r7 e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 F1 Y( @0 ~( p- k2 A
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 [2 L2 @1 R* \. s) L) d1 E r - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ H# [3 l; c, t! x+ j4 p( F
/ t. l! C1 b% }7 S! N, m4 H# A2 A- dma_addr_t dmaphyssrc1 = 0;5 O' ^7 e* n& u: t" v
- dma_addr_t dmaphyssrc2 = 0;. M7 d0 v& k9 B6 _7 v; y
- dma_addr_t dmaphysdest1 = 0;3 o+ T' x; s) o3 n8 l1 h
- dma_addr_t dmaphysdest2 = 0;& F8 J. U. l) D/ o" J. ]* \
- ; v: l# w+ N0 T% D
- char *dmabufsrc1 = NULL;
( \" `7 X% k: N - char *dmabufsrc2 = NULL;
9 S9 e. L* x. G# G - char *dmabufdest1 = NULL;& y! P0 S2 i$ {5 a
- char *dmabufdest2 = NULL;
" J2 w5 ]3 N" C, T4 z- |
- F: G' [: G* @- static int acnt = 512;
1 T n8 g( N3 [7 ] - static int bcnt = 8;
8 E3 u1 s c. u3 _: J. C% g" z- T - static int ccnt = 8;6 \+ k1 H% Z( a
& `( y) \$ q2 Y& }: P: t, C- module_param(acnt, int, S_IRUGO);4 _5 F1 J$ E; g
- module_param(bcnt, int, S_IRUGO);
6 B! i" k- } b" y7 W - module_param(ccnt, int, S_IRUGO);
复制代码 0 X4 y t: m- Y! o$ u3 h S
: a2 K- ]: X/ u/ R5 A9 Y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 T) d$ l8 ?# E" \
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ ^$ R- v' t% m7 [# s, Y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% N' H7 X0 d i6 x: X6 g( f, A
+ f; C! @$ ]3 f0 Y; a' {0 V) B3 t+ P9 k# w) b
|
|