|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: e1 ?# ^$ f: G. p) H+ T9 ~+ j- [code]EDMA sample test application: M5 W* h6 m' B3 h# p
- /* d1 [$ m: G! G/ u& n& V: h
- * edma_test.c
" ]& F: m, m1 |0 u# F- G - *$ E, G6 X. l u; k; o9 ]
- * brief EDMA3 Test Application* ^ D( L. ]4 U6 x3 [$ q/ e
- *
$ J% G0 K+ H8 }, i - * This file contains EDMA3 Test code.8 z/ @6 }. |( t& W& s, T
- *
7 ^) |3 M7 G( a. | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, V' B7 @( Z. h7 m - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ w( X% i! y7 [! q - * TO CHANGE.
2 }- @( k7 R+ d" a) u3 @6 H - *3 G7 V( X* f8 ]( r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' }3 M" j/ Q- M1 S+ o$ G4 {+ Z - *
% e* S: m% ?) f G& S - * This program is free software; you can redistribute it and/or
4 }+ [' f; p8 I - * modify it under the terms of the GNU General Public License as
' c% p3 i' ], L! a - * published by the Free Software Foundation version 2., g; d- N9 d$ M2 Z
- *- K7 T9 \. J( R, F8 n/ L+ u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any( n8 P6 y+ k; N1 v: O7 D
- * kind, whether express or implied; without even the implied warranty
5 o d$ w. P m9 S - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 K) f5 m/ c- [ - * GNU General Public License for more details.
`% f4 y8 i% P% y6 d2 R* |/ R - */
% w. f( I2 N1 M - , e- R5 p; @# J3 t
- #include <linux/module.h>! V {# a4 Y# W+ b8 e3 R; i
- #include <linux/init.h>
$ T- x- f' S" Z( p - #include <linux/errno.h>0 q1 O/ f+ W, C9 ^7 \: ?3 T8 j
- #include <linux/types.h>4 `) E0 w) t1 Q. B9 ~) }2 B& t
- #include <linux/interrupt.h>
$ f3 O& u' T, w3 c+ L# h - #include <asm/io.h>
9 H( n6 {) V% e" i! d - #include <linux/moduleparam.h>
: h9 L4 D. p" _: q5 h- q, M0 W( {8 ]; }* W - #include <linux/sysctl.h>/ N0 ?0 t( O6 S P% I. O
- #include <linux/mm.h>
- z' ^! H! G. G* `0 e* J0 t H - #include <linux/dma-mapping.h>
8 n) h. G2 g1 K2 e
/ d, N0 r* i* P' x- #include <mach/memory.h>+ @( E: K5 ^2 [ t/ C6 F
- #include <mach/hardware.h>* m1 U T9 [6 r
- #include <mach/irqs.h>4 x9 q0 z& X$ C
- #include <asm/hardware/edma.h>
) f# m& t; M' @3 l# G* g - 4 @* I6 p4 S$ m& a
- #undef EDMA3_DEBUG
6 k& J& C; C6 m, L' P - /*#define EDMA3_DEBUG*/
+ X- M! k0 f+ z$ Y - 2 O$ @7 y, e. E$ [
- #ifdef EDMA3_DEBUG
, G7 k- C7 s" `8 P0 [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) Q/ K0 b, V4 T& l: W2 a0 ~9 S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) I+ o6 v) s3 E2 I) _( b9 V
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 Y1 v3 I) {) B7 D$ N; M @
- #else" R/ V" y- B2 ?/ q5 r
- #define DMA_PRINTK( x... )0 F6 K0 {9 B8 E" q8 C5 T( S" n
- #define DMA_FN_IN
K& d! A; l. A) v6 k+ Z* v* E+ A - #define DMA_FN_OUT+ ^* n* Z1 ~. Q( t! G
- #endif
# B) T' y+ ?7 ]; S! L
9 y: @, g5 ]; v- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 X- s) W: R6 K
- #define STATIC_SHIFT 3
s- F. s) j- g" e6 R - #define TCINTEN_SHIFT 20" y D! N& A2 S6 f7 h% h0 m( C
- #define ITCINTEN_SHIFT 21
A5 w3 v8 a; @. ]! P- @8 z - #define TCCHEN_SHIFT 22* F3 t; B* ] C; W
- #define ITCCHEN_SHIFT 239 z/ h [0 f/ m; [) v5 C. `
* t! A/ f. a/ r6 t- static volatile int irqraised1 = 0;; y) A9 w5 X& [( X% k; j+ r
- static volatile int irqraised2 = 0;
1 M D0 W5 T' L f; \- t5 k# j
$ Q- f) U3 q z% ]5 ^# f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 Q" W$ y8 q/ c, ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! C7 z! O4 T: s
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 _7 e& o$ m; p( K2 W# L - , ^$ n6 |9 d4 y; b# [* W- `
- dma_addr_t dmaphyssrc1 = 0;
+ Y. h. `) P( V8 p. Y* s! V& q7 m - dma_addr_t dmaphyssrc2 = 0;6 E; |8 m' P5 g) C6 A
- dma_addr_t dmaphysdest1 = 0;
2 |' \' t: d P1 s9 J - dma_addr_t dmaphysdest2 = 0;: \! V9 P2 s J# R6 e0 H
- * G. `; k+ P% I. }
- char *dmabufsrc1 = NULL;
0 N* I. Y) c" Z - char *dmabufsrc2 = NULL;4 F, c5 Z7 o1 u9 R% R8 O
- char *dmabufdest1 = NULL;
9 ~! y4 K# M% \- f8 C8 ]4 B - char *dmabufdest2 = NULL;
9 n# [5 E0 ?. j C! w
y8 J% T6 F8 |$ n \- static int acnt = 512;: P; @' J! p! T/ U V
- static int bcnt = 8;
. C$ R3 h/ k+ o4 |' D - static int ccnt = 8;+ R7 |$ {7 F6 I$ @
- 7 J; M" v5 w. w9 v
- module_param(acnt, int, S_IRUGO);" q5 W r! S' y# f8 L1 b! p {
- module_param(bcnt, int, S_IRUGO);, A; O( T5 b1 ?* ], ~+ U( ~: g
- module_param(ccnt, int, S_IRUGO);
复制代码
, L# Q Z4 `) z* _' [3 c7 l
4 s* f# {. y. y' A% S" a2 i5 P 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ I5 U' d/ X6 a0 carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; U0 q6 a+ q! W, f I. [ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 ]" W2 w* F' b: t$ f7 p1 t
$ _8 H& [ [. l7 W) Y
! O9 B& G+ l8 _0 J, V |
|