|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 @5 _) m! e3 G- [code]EDMA sample test application
# s6 w4 S" |6 c- J - /*
9 g/ D- x( \# x7 d# Y3 {# V$ ?! D; S - * edma_test.c
6 u+ M% @& V8 ]- y - *7 c( P8 I( U+ F4 H# ]
- * brief EDMA3 Test Application
0 ~3 A7 j7 U. f1 E - *
: I9 C* R5 D' i! J }6 c* _! o" B - * This file contains EDMA3 Test code.' |/ q% I9 p' {( n! K! y
- *
- K/ k; `, h9 K \3 F - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! e+ h4 e. t# T, O. P. _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 b- [7 V' ]# F6 y; P$ H" t
- * TO CHANGE.; p8 X- E: P! t: r- P3 o) R
- *' p! I0 v2 {2 T, Z$ Z! p# N) d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/% r* o! [) |4 U, `( W' a
- *
7 n1 a* k4 ^; h+ s - * This program is free software; you can redistribute it and/or
C7 ~2 b- @& v: Z - * modify it under the terms of the GNU General Public License as$ e u) ^5 b4 {
- * published by the Free Software Foundation version 2.
( |6 r1 r; @% l8 o! E5 ]- j - *. }* N% B# J. j" i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 S; b D$ s- p& F" i# X$ a
- * kind, whether express or implied; without even the implied warranty7 o+ {1 P* K0 B, I2 E% u/ E
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* K+ o4 x- S8 T$ x - * GNU General Public License for more details.5 D/ ?, _- i/ U! u# P9 U7 P
- */
9 Y- T0 ^2 T6 E
% Y0 D. ^0 j- R2 z9 w6 L- #include <linux/module.h>0 k* E Q) v# j1 P0 J) [* l, w
- #include <linux/init.h>
4 S! |* @, v2 S. a: K - #include <linux/errno.h>' Q! K+ ]$ s6 Z1 S; b
- #include <linux/types.h>
% A# g8 c' ^2 [5 z6 ~ - #include <linux/interrupt.h>$ h! R3 W. \# H, g- c! n5 D. A& }3 z
- #include <asm/io.h>+ Z# X: Y/ b' o: u7 t/ P) X
- #include <linux/moduleparam.h>
( M& Y$ _" ~! s- H7 [- i - #include <linux/sysctl.h>9 a4 p7 T$ s( D& @7 P( J
- #include <linux/mm.h>/ V0 V3 g% O- l# @7 v9 m1 K4 Q2 ?
- #include <linux/dma-mapping.h>( X3 ^6 n( e3 t8 x) v0 b9 @! C
) q1 Q5 |% K# y) g9 w! K- #include <mach/memory.h>
o8 O/ A. c4 a - #include <mach/hardware.h>
6 }3 H' C# @& d2 r - #include <mach/irqs.h>
0 e+ c+ T1 v0 F9 ^ - #include <asm/hardware/edma.h>9 `' M! Y& i; `+ A0 X
- : {* z0 O/ N; N
- #undef EDMA3_DEBUG; ~ d5 \7 W0 E+ E" J. ]
- /*#define EDMA3_DEBUG*/
1 S7 k5 }: ]5 W. ]2 X8 |. f3 r
/ C) W) A% X+ P0 z- #ifdef EDMA3_DEBUG
$ l q3 o7 D9 R( h6 C7 b7 P" q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 Y6 X L0 f9 E- T% ]/ F% j7 b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 T6 m( ]* C$ H4 K. Q# O3 L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); u1 O' L. _# e' n/ E* w+ @
- #else
3 ~* |1 J+ o0 J% R2 f: _# ?6 p - #define DMA_PRINTK( x... )! x- s7 Z6 y8 h) w8 ?$ j
- #define DMA_FN_IN% ^' K, @; t; F2 u3 `# W5 x
- #define DMA_FN_OUT
* [& W8 {( z0 p+ v& S6 X - #endif1 Y# C3 `& R9 Y: o, W4 g
- % l( R1 N3 I% d) x" D* }
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 J3 [ A: z5 t. ~1 U - #define STATIC_SHIFT 3$ b. W0 _2 z+ }' z3 [2 o# f
- #define TCINTEN_SHIFT 20
/ K9 X% }: f6 c1 ~; h - #define ITCINTEN_SHIFT 211 ?5 s& I$ K- e# Q. u0 a
- #define TCCHEN_SHIFT 22
8 c3 Y( l+ I4 |5 r3 X7 h, M; d# k3 @ - #define ITCCHEN_SHIFT 23# {+ h8 \7 n, \4 s5 a
- ) r" ~6 X/ Z9 |1 Z" Y/ i/ N
- static volatile int irqraised1 = 0;( T; g. z& i3 K, d. {, b) M. [+ X; x
- static volatile int irqraised2 = 0;
, V1 x" A: y1 [+ A
8 ~' W8 c( l7 _% f0 @& R2 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! n2 s* u6 I2 {, ] h% A# {$ C* J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( R7 o, e3 C) r' J5 k. F- |4 W: \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% B# f+ Y0 Z S5 ~# J6 D% q9 @ - ( {% J6 e9 u }
- dma_addr_t dmaphyssrc1 = 0;: P7 i% F5 |2 J) W
- dma_addr_t dmaphyssrc2 = 0;
+ @- B3 M9 e2 t8 w; u% S( U# b - dma_addr_t dmaphysdest1 = 0;
0 t' X' Q( q0 V( l# ^! y } - dma_addr_t dmaphysdest2 = 0;- z1 Q% g5 E" F+ v$ D1 ]+ X
- # H' G1 e B) O4 A+ h
- char *dmabufsrc1 = NULL;
& }: h# h# e' T6 T, f - char *dmabufsrc2 = NULL; \* ^% l; _& J9 ~7 m: m j
- char *dmabufdest1 = NULL;
1 n3 B& j* P8 ?4 z6 I: B4 V( u - char *dmabufdest2 = NULL;# @$ u0 {1 B( J* g" p
. y( Q" T4 N6 D- static int acnt = 512;" f$ w& P# Q( w/ @1 @, o8 R
- static int bcnt = 8;% [$ }7 e) \/ _, R( x* m& M
- static int ccnt = 8;# [ p# f# z- T5 T, S4 R
- . _$ q& p' _8 c
- module_param(acnt, int, S_IRUGO);1 F" U! @5 R. a5 Z
- module_param(bcnt, int, S_IRUGO);. K9 ?- Q( N* l) ?$ Q l1 ^
- module_param(ccnt, int, S_IRUGO);
复制代码
( ~7 W6 j6 I! h- o: l; I- [$ M$ L7 ?; I. d3 ?2 g5 b
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: @ ]1 T u3 X% v0 Y8 G' Rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& [; `4 i% j9 S1 Q! z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: e: I5 r- ~9 ?: |. B. G" J5 L& F/ t& V& Y
6 ]- s- s0 J2 D- o3 U: F |
|