|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % E+ z7 O8 O% Y
- [code]EDMA sample test application
& o5 E& I* x0 _/ Y - /*. ]$ V) e3 w* O: v- o2 g
- * edma_test.c# M6 _) b' x6 o# U8 F+ T& L
- *
, @$ r. O. r! ^0 l - * brief EDMA3 Test Application! i4 O4 t: z; P! Q9 Z, t
- *
, ^5 h3 ?; b# Q* E. g - * This file contains EDMA3 Test code.+ j6 x/ e8 M- r) s. b
- *2 t3 j& \+ Z8 A7 |9 E0 @
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' F' I8 o! @( \' c, _* z3 B - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ n B/ I2 P6 `: c
- * TO CHANGE.# r* O1 T9 Z: p) m* c! c! Z
- *
) s0 }( L8 g+ k* p - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ H( Q* c6 \& J3 I4 U - *: k* }/ [6 v" |) m" l
- * This program is free software; you can redistribute it and/or
) m" }- ?% m5 N1 q# q - * modify it under the terms of the GNU General Public License as* @4 V7 Z* ?7 I. t
- * published by the Free Software Foundation version 2.4 u+ X) Z7 V" Z8 K! c
- *
" m0 P! K K3 o5 O5 R5 F$ n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* R* t0 m" \8 o - * kind, whether express or implied; without even the implied warranty0 B& J6 C' w$ m7 m3 _ N- L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 n( Q8 L8 ^/ R" J. E6 F - * GNU General Public License for more details.
! b, ~# L2 p& `0 }& _( Z - */ X6 V' l; `3 A }! c9 n
- " b$ {4 w5 H6 y
- #include <linux/module.h>6 P7 S" r+ C1 {! Q/ D9 B3 n" p! u* f
- #include <linux/init.h>
, ~ a" v8 M3 o/ ?0 Q. G- d - #include <linux/errno.h>3 r7 b- a3 u# {1 H' r- a
- #include <linux/types.h>
t: s; K- f m8 Q" m4 F j: _ - #include <linux/interrupt.h>5 I3 R1 m! J) T5 G" _: _
- #include <asm/io.h>
( L: ], x6 Y1 E* X - #include <linux/moduleparam.h>
! Z# ]. C3 y" I% c6 G( S - #include <linux/sysctl.h>9 c. a: p8 B9 C+ m6 E, T5 k
- #include <linux/mm.h>
$ n+ K8 |- T: ?# K, F; W/ {6 `1 v$ \ - #include <linux/dma-mapping.h>
% ~) E% v$ `% h b# }! b( Q$ b$ S - , a ~" q" r: H! h' l W
- #include <mach/memory.h>
% z3 b/ \: x4 U - #include <mach/hardware.h>, d9 G% V2 `7 [
- #include <mach/irqs.h>% o7 K' ~+ P3 ~0 {3 o1 t
- #include <asm/hardware/edma.h>
C% g0 H4 A. d! M; X% e1 H2 y1 E
- t& I# _' c8 F4 O7 X/ Z9 z+ l4 \- #undef EDMA3_DEBUG
- K$ n1 C1 K/ D d1 L% } - /*#define EDMA3_DEBUG*/
; Q4 h; U. @4 }/ o% _! z - 8 z" n3 _: K, x
- #ifdef EDMA3_DEBUG( r* q3 ?+ n' }" v. @) Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 r9 X9 L7 M: u5 d# `' |. p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ ?- d' A% n$ L# r, F* e" r5 e5 b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) L5 s4 O/ d0 _& {. `: t - #else
) n$ `/ P% Q% R - #define DMA_PRINTK( x... )* Q9 J" l- \3 d V ?2 V$ M+ X
- #define DMA_FN_IN; A* m, z+ w5 E( V0 \1 R, n
- #define DMA_FN_OUT
; q# B/ _3 b! [+ [/ c - #endif5 J/ a4 N: \4 Z6 k8 |) q8 O" U% ], U! x
- * I5 |5 {. T) T% t6 n. f8 ~
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& q* n5 C+ b' r a0 [+ H
- #define STATIC_SHIFT 3' r: L- X) ~. _# f
- #define TCINTEN_SHIFT 20& A* A; G* y8 I
- #define ITCINTEN_SHIFT 21
( S/ J$ F- W4 B. |% J2 r - #define TCCHEN_SHIFT 22
% ~' W( X0 t7 e& E - #define ITCCHEN_SHIFT 23
( T/ j: a# G! n. M; Q g2 ? - 0 k/ w7 o1 w M1 z
- static volatile int irqraised1 = 0;5 Q6 A; J3 B# q# l: l' T" j; X
- static volatile int irqraised2 = 0;
. \2 `1 ~. b2 p! F4 q4 W
, r# F; P6 K; f( i' Y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% T% y% E$ c: x3 t - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ w( M9 U$ Y3 M8 s# n - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 p7 \9 B: V& F* Z" ?; `0 c$ O
3 M/ h) o' k# A* E) m- X$ {( E8 W- dma_addr_t dmaphyssrc1 = 0; Y" g! g1 `0 f) R1 J4 K
- dma_addr_t dmaphyssrc2 = 0;
$ z8 N, j9 h5 o - dma_addr_t dmaphysdest1 = 0;2 v( p- }8 {* l; I; a' G
- dma_addr_t dmaphysdest2 = 0;) Y$ u& x8 Y# \! j8 B
: c& _" o' p+ D, K5 D* W7 ]3 z- char *dmabufsrc1 = NULL;3 j* B! D D5 l1 k" z
- char *dmabufsrc2 = NULL;
/ N q' `! j3 z5 u, F+ A - char *dmabufdest1 = NULL;4 y/ M- O4 K0 Z: \3 `9 U
- char *dmabufdest2 = NULL;
/ W# V! }( l2 i4 t
( g: X1 \7 |. b; [3 V' _' b7 q- static int acnt = 512;. ^/ H: q! r1 Z4 {! H; ?3 u
- static int bcnt = 8;5 h, _& z4 C1 X. h( Z/ v
- static int ccnt = 8;
% f6 [* i! J z- ?* d - : v, P x' e. { D) J* a
- module_param(acnt, int, S_IRUGO);
' ]' I1 `$ [' B6 v - module_param(bcnt, int, S_IRUGO);, U. F; P0 ]% j8 V' ?9 A: v4 r
- module_param(ccnt, int, S_IRUGO);
复制代码 / m% _6 F: p' i/ Z$ D9 q
; _) B6 e" V. r. T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 w+ {* [& s' b. U [' D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 z6 }9 a; l+ t7 e# Y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: ]7 ^5 E- z! u0 }$ F9 j% l8 R7 p, ^
) I" X+ M* A/ U7 m* a: q |
|