|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 Q6 s/ g" m: d) O
- [code]EDMA sample test application
3 [/ S* R. Q w* J @- q - /*7 R1 c+ \8 V: l* z
- * edma_test.c
3 F, e$ l6 W' r) W) h( T - *; I6 o3 X& \4 }: ^7 o
- * brief EDMA3 Test Application8 U& `9 H/ }( R
- *
- c. ~) l7 U0 L5 B. f; ` - * This file contains EDMA3 Test code.
H; {1 V- z$ J! F7 k# \ - * p: S. y9 p2 \8 [* ?# ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 a' ~- l; _' f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* j( y; `0 b7 m2 t1 H
- * TO CHANGE.
?, F; e8 n# b1 E( W! G - *& T$ s# X9 n6 N+ I$ {
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, A' F$ x; Q1 q% \% ?5 @
- *
& Q) `. ?1 f( ?& X! b9 {+ D% e - * This program is free software; you can redistribute it and/or
& E: q5 c) o {9 |! Y" @$ r M - * modify it under the terms of the GNU General Public License as
& H: H) q |" [' I* n( y1 s - * published by the Free Software Foundation version 2.. U" h6 j& n% y% n1 q. |
- *1 N; e8 |) Z' }, N" O; j8 X; y0 K
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, J* n. } v: ]% r& \
- * kind, whether express or implied; without even the implied warranty
$ O' b) D. _6 N; q& V! ~ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! x9 O3 O, C5 g
- * GNU General Public License for more details.+ r7 a& V" e0 b. {# s8 C
- */- x7 i# E7 t0 v: M6 S6 q
- 1 o7 V. @$ w- |. y% b" d
- #include <linux/module.h>
" F: c" |* x+ F/ T: B2 o+ I& j - #include <linux/init.h>
: x8 F+ o! e9 P( E0 F - #include <linux/errno.h>
) b( P$ k; s2 B. ^& r$ Q7 j - #include <linux/types.h>
) M' h4 h; {4 e o4 |4 m y - #include <linux/interrupt.h>* X' O8 z3 l; d# o; M
- #include <asm/io.h>
5 X( C1 X z# E# _ - #include <linux/moduleparam.h>* U9 G" B. Y2 I, t
- #include <linux/sysctl.h>8 y7 w/ J6 h4 D+ l* C2 w
- #include <linux/mm.h>) T6 d" x3 t! h
- #include <linux/dma-mapping.h>
2 a {- e) L d; k8 R
5 o6 b4 D: {! z+ v) J- [& v9 v1 W- #include <mach/memory.h>
$ n6 j9 y, m9 n% o - #include <mach/hardware.h>
1 ]+ w0 T: A% p! E. Y1 v9 P - #include <mach/irqs.h>
& P. d! L" `% Y - #include <asm/hardware/edma.h>
4 C O' G+ ?# y- {4 o - - j6 E/ l' T/ B7 z* s" K
- #undef EDMA3_DEBUG( F5 J8 J$ M. W! F- N! a+ m
- /*#define EDMA3_DEBUG*/1 t: u, W+ p/ D% o& ^
- % a# B( c" _! e
- #ifdef EDMA3_DEBUG
5 @$ F& ?2 I" p K8 U+ } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 X, X- a+ G3 O' a( F' g7 r& Q \- N - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' J* w i' s; i' C* g. M8 W, w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
i& N: W+ b* n6 Y( }3 \% w - #else
2 A4 J/ L; Y' I9 n4 c: D- E - #define DMA_PRINTK( x... )
/ Q' a+ A L6 h$ B9 X - #define DMA_FN_IN
G3 M9 X G% b9 e$ r0 ^; X5 i9 { - #define DMA_FN_OUT# V6 s7 x! i7 k- q
- #endif
* D" @$ L) _4 _. o% J
" \& C8 S7 ]' Q& w' B8 K8 a- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 ~8 j" G% P5 ^
- #define STATIC_SHIFT 3' X n u+ q: A/ ]& V3 L
- #define TCINTEN_SHIFT 20
! j) c+ W/ x" Y! Y/ [' w- N - #define ITCINTEN_SHIFT 21
: {5 ? f( O. z2 f - #define TCCHEN_SHIFT 22 b0 i7 o2 g: B+ {
- #define ITCCHEN_SHIFT 23
1 R" G0 ^5 d- U5 l8 Q+ ~0 Z
6 E9 Z" c+ T; h: n- static volatile int irqraised1 = 0; }3 f9 N0 m# E
- static volatile int irqraised2 = 0;
# q6 T- Y) N" K3 C
' @. h. r, L* _/ A" w; D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 q2 h, k/ v6 `- N2 v4 S8 O1 T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 @- W$ R$ [ E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ \- {; y1 ?- A8 c
5 {4 a. I J t4 ]- j, s& V+ [- dma_addr_t dmaphyssrc1 = 0;
, i5 w2 S- ^3 x6 |1 n - dma_addr_t dmaphyssrc2 = 0;2 ~& q3 R* n; y1 i
- dma_addr_t dmaphysdest1 = 0;6 o$ V& A8 ~: D7 h) |) H! x
- dma_addr_t dmaphysdest2 = 0;
( u9 j) H9 p! K$ ~ - 5 Q3 S. B% n/ S) A5 S9 f& u1 G
- char *dmabufsrc1 = NULL;
3 v0 t9 R* h/ ^/ F, K - char *dmabufsrc2 = NULL;* U0 k K2 u3 N, c8 [: x
- char *dmabufdest1 = NULL;
2 P1 r7 D/ }; c- t. }1 G' k( ? - char *dmabufdest2 = NULL;
( D9 K8 g* p$ f( @# r. J+ d - ! ~& @4 T, M! r. m/ [. ]
- static int acnt = 512;) I! n! q, U; ^
- static int bcnt = 8;: K- o6 F0 \* ~ `4 V& f
- static int ccnt = 8; z) C" O; F/ _( V+ W3 P
- ; O8 x2 h, Y+ _2 l5 J6 g
- module_param(acnt, int, S_IRUGO);8 X0 P! D4 _0 o4 J6 P
- module_param(bcnt, int, S_IRUGO);
( g. f1 t& l+ N/ _8 e - module_param(ccnt, int, S_IRUGO);
复制代码 , Z% Z( z$ A9 C, c3 w
( P. r5 K, x; {2 P0 g
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 I5 k3 l+ w" Q6 k# ]; v; ^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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! e: w! v6 T2 X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! b( B; a: k9 G* z* r/ F3 K8 ]! H
: T2 }" g- W- M; ?- v
6 x+ z8 L/ q; X- b
|
|