|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 D9 B& Z3 ]1 T- [code]EDMA sample test application
X, k. O5 J$ R7 ?$ U - /*
$ h9 h6 H: u% B$ g - * edma_test.c: w) g& k) E7 e+ S
- *6 J. T, [3 i1 c, h: U
- * brief EDMA3 Test Application- X6 Z- o. N+ b8 F# B0 j: C
- *& w8 }9 o% ?8 p6 f: ^# v9 ?( P
- * This file contains EDMA3 Test code.
2 E# [7 n, K2 H. B% t" X - *
0 m6 L0 X$ n+ C- `8 _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 Z+ a* I! e/ C+ B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% }6 _+ H' x1 W( X) }' x' ]& N9 ~
- * TO CHANGE.
% E+ O6 Q4 z G( J, p - *
L" e1 c$ e! D# F0 ] - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' [) I; l) W4 O# I
- *$ b6 {8 B$ R% X( ~& ?6 b
- * This program is free software; you can redistribute it and/or
% Z) i5 j, Z. W7 K1 T3 O: T+ \+ R - * modify it under the terms of the GNU General Public License as! p/ \4 J- H6 D3 |, K6 }9 H4 y
- * published by the Free Software Foundation version 2.& _* P* I6 `" S3 Z
- *
+ S4 E: [) W: {' g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
2 ]" _& M' ~0 t4 a, i3 ]: h - * kind, whether express or implied; without even the implied warranty
2 Q1 c) X9 D& l4 v, w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; G3 e0 f, w8 L9 k/ g2 C - * GNU General Public License for more details.* g, a% B) b% H0 B* y
- */6 f% D7 n& r( a" @* E; h% g
1 K) T r g( @6 m6 T+ u5 F6 w! x- #include <linux/module.h>- N% T5 R; ^3 z9 R! r ? f
- #include <linux/init.h>2 | ?; j# ^0 P# ^; m7 ^8 A
- #include <linux/errno.h>8 {/ @8 o, A' F' m
- #include <linux/types.h>& C* p6 t) n, ]# b3 L" c
- #include <linux/interrupt.h># z. _5 @9 V' r3 T
- #include <asm/io.h>" E* g/ a o7 k4 Y* `# i f, R
- #include <linux/moduleparam.h>9 p, K5 y% ^2 N* t
- #include <linux/sysctl.h>' H$ Q/ l+ \" T/ S; N6 v1 ]
- #include <linux/mm.h>
% ~' g8 @& u j& z& K( I9 Z - #include <linux/dma-mapping.h>
+ e# T+ F+ b' C( w2 b$ {
) |% \3 x }" g' K# F' I) a9 B- #include <mach/memory.h>
6 c, t! y/ _4 j; H6 K - #include <mach/hardware.h>& Q* [ b! V& Z. t6 a; i
- #include <mach/irqs.h>
1 v$ l3 J: B9 X; K2 P5 X3 k0 s" N - #include <asm/hardware/edma.h>
$ I: t0 a( s- ]( x; }; v - % Q j" R5 ?3 D) `
- #undef EDMA3_DEBUG- ?, V# [3 ~; r/ {3 f9 b
- /*#define EDMA3_DEBUG*/
, S" w' _5 I$ a, @, `2 I" J
1 i4 c4 v: i$ q/ k- #ifdef EDMA3_DEBUG
( N. H/ ]- T2 R8 ?/ Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ B6 |9 |! K z. L& K* f- [5 J - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 U% J% W1 {3 O4 d: g' S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) L1 S& l& J1 ~2 n; t# F/ Z) L - #else
, o- k2 a' X n - #define DMA_PRINTK( x... )
: P0 Z8 R/ I2 P+ `- ~9 A+ b - #define DMA_FN_IN. Y( M5 F; D- K7 V) N6 w1 t2 u
- #define DMA_FN_OUT( m; Q& j# E. [, L5 ]& O4 g
- #endif
! o) a8 C6 k9 E9 ]" i1 s) z - " c5 B* \7 O0 v( D
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" g# b3 b i- R4 _2 u - #define STATIC_SHIFT 3
3 }- B+ k& i+ H3 N+ F7 s - #define TCINTEN_SHIFT 20
* {6 F* j7 B2 \' K9 k: `3 P, G t - #define ITCINTEN_SHIFT 21% G" h; T* }" d/ x$ H- J9 ^& W0 t
- #define TCCHEN_SHIFT 22" k; a1 t$ N! U3 {! P
- #define ITCCHEN_SHIFT 23
- A5 F9 b4 a% A) ]2 M( l2 B
6 ~: ~) L ]' Q4 j- static volatile int irqraised1 = 0;
7 G8 E2 S$ _1 H- M; g o - static volatile int irqraised2 = 0;
' j0 N6 H B! O2 J! M
' J' y1 G" Q' A# I- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ j/ o/ g/ w) y3 }" H - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* A9 s$ R- x m2 L1 v) W% `& m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 Z) ^& `, V. F- r Y) f( `0 L
- 4 Z% P6 f2 T2 }) \1 ~
- dma_addr_t dmaphyssrc1 = 0;4 L7 N, v% } h# a
- dma_addr_t dmaphyssrc2 = 0;
" o6 [0 a) I1 A- |( }) H# @& A/ r - dma_addr_t dmaphysdest1 = 0;
2 J: Q( ~ J i, N - dma_addr_t dmaphysdest2 = 0;# k- I9 g, o+ b, P6 l' |
- 9 M- J& p9 ]& o* e) f5 J
- char *dmabufsrc1 = NULL;& _. x. e- F5 F1 A; e
- char *dmabufsrc2 = NULL;
0 o4 v6 X' F8 ?6 ` - char *dmabufdest1 = NULL;
0 Y7 e4 x( V: T - char *dmabufdest2 = NULL;
& ]( i' X0 Q" c7 |
' h- O9 d. F* ~. I- static int acnt = 512;) u' m e$ s9 s0 Y/ B
- static int bcnt = 8;- _5 n e( P* }8 r9 _! v
- static int ccnt = 8;
$ o$ p/ e, j/ b+ R. a
$ A8 F$ a1 v$ X( U- module_param(acnt, int, S_IRUGO);
( @' Z' E9 C" B* Z - module_param(bcnt, int, S_IRUGO);
$ A* L; n; T" c* ~) E T0 x' j* m - module_param(ccnt, int, S_IRUGO);
复制代码 $ p+ k0 }- H8 _: C3 R- u) q* W
- H3 Z8 Y8 I; Y9 ]' i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ e: N+ U! z! K) |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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* s* N9 d( n) o% ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 N; K! e6 {. |
; O3 v1 Z9 [: h) e5 W8 z3 ^8 H+ [
% @5 Z/ G: E% Y1 h$ x |
|