|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) D. b8 G! Y- u g* @1 w- [code]EDMA sample test application
" P. [7 w1 p) i' e& N1 z - /*
/ `3 ]1 _9 a+ f5 v( W( O# S7 O - * edma_test.c
% E: ]% }8 R K$ @, S0 Q - *: I- L% Y) R; A
- * brief EDMA3 Test Application V" { R" B! l. c. R7 @) T8 z: L
- *
* P }% n3 i! Z9 \! j - * This file contains EDMA3 Test code.( x% D2 ?/ f$ R
- */ y5 ]1 l* X" j `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" Z% U p* \- ^; W
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 o' o; q7 a! j5 q5 { i
- * TO CHANGE.
5 k& H) n! a. _2 \2 k5 X* e - */ W; C( A# Q+ Z9 l2 ~0 o
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' a2 K. J: \& b$ q - *
+ z- g2 ~5 e4 N- X9 ]9 m - * This program is free software; you can redistribute it and/or
; g% Z4 X7 e0 R9 S) j - * modify it under the terms of the GNU General Public License as
7 O4 F4 |7 M& c7 ` - * published by the Free Software Foundation version 2.# W- ?2 [$ V4 V
- *
: d* v8 e/ ], R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( u& q5 x) N2 n" P' h4 ?- Y% @ - * kind, whether express or implied; without even the implied warranty) y( e' h, G1 v+ I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 d8 V" Q( Z, O& x. _
- * GNU General Public License for more details.
. l$ ]( Y; d1 m - */
5 a- d$ t$ m0 B- f; W
/ r7 z$ z: g' q" Q! t3 T- #include <linux/module.h> a' U; Y; P2 [( K( Z! W
- #include <linux/init.h>
( b, ]/ i5 g4 i- G4 ?7 F - #include <linux/errno.h>
# U# ^5 j9 f: G - #include <linux/types.h>: E1 w9 K( v3 B# e
- #include <linux/interrupt.h>" W Y) W+ ^9 B. T
- #include <asm/io.h>
; \3 _7 m4 X6 K. r - #include <linux/moduleparam.h>9 c5 j6 u1 ]1 Z' H. C3 Y# y: e+ U5 ]
- #include <linux/sysctl.h>9 u& F5 t: j6 }7 x# Y0 ]1 @8 K3 e
- #include <linux/mm.h>, n. u5 J$ A. m0 Z) H
- #include <linux/dma-mapping.h>
Q3 W7 X4 W0 g* I y8 ?5 }& I3 f
& ]& [! c. K0 j& Q5 W, ~+ {- #include <mach/memory.h>
! O4 O- `: X- I( m$ \) _ - #include <mach/hardware.h>
! e$ S0 I4 S) K8 G5 V - #include <mach/irqs.h>
! \8 ] p. o' A - #include <asm/hardware/edma.h>0 ^5 I3 {) C! X$ O" h8 r7 a
- # G# |6 p) W7 J8 _7 g" ^( e
- #undef EDMA3_DEBUG
( X( o7 k V+ K* _) {# { - /*#define EDMA3_DEBUG*/
4 G/ a% \7 o7 a( q - 5 L, _& _- j* Y X) b6 j( z
- #ifdef EDMA3_DEBUG
; R4 O* p* j& g1 X6 n w( `( g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 X. ]- e$ E6 t2 j% T+ e3 X* m, y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: t' {3 w* G' k; Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 D$ O$ |! v9 T
- #else0 b5 }: r( h) x+ i: _! b
- #define DMA_PRINTK( x... )& `# ]) v9 e7 q/ f* E( z5 {
- #define DMA_FN_IN
9 U$ f: G% j! W( p0 z7 N - #define DMA_FN_OUT/ a- ^8 y4 Q: h2 F6 \: N0 v
- #endif' p: k$ L& q: b- d
' }4 v4 W$ S7 Q/ P0 G& h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! @! S5 p0 e2 k
- #define STATIC_SHIFT 3, S- g9 n* U) X! u% b, S! `
- #define TCINTEN_SHIFT 206 g* l7 \5 R4 T; b& Z1 |1 f, j
- #define ITCINTEN_SHIFT 214 e5 m/ H. F9 a4 C' R
- #define TCCHEN_SHIFT 22
" P4 T& Q0 y: X) g- I - #define ITCCHEN_SHIFT 23+ B4 C8 b% M6 Y H
- 4 U* E" ^* n- M% _8 ?8 K
- static volatile int irqraised1 = 0;
2 c- Y; z0 ~: N4 b) p* W' g% E - static volatile int irqraised2 = 0;( \7 L/ Z | z$ n% A `
2 r8 a/ W7 q9 _9 n! n- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. `" I/ b5 v, K8 h0 i) Y, E- z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; [* e0 H/ E1 y9 @! `4 L7 S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ e0 f" U3 j- f% m- f4 o( Y - + _2 F; R2 G+ }* u; Q) V% D
- dma_addr_t dmaphyssrc1 = 0;8 R8 I/ r' F. {7 [& ^9 L/ Y
- dma_addr_t dmaphyssrc2 = 0;2 b( h" @3 v1 k6 K4 Q
- dma_addr_t dmaphysdest1 = 0;8 I: v- n$ `/ j/ ~ z5 D& g, @8 l
- dma_addr_t dmaphysdest2 = 0;
! @' v6 h1 Y3 h. h% @( S - ! p" ~6 O" e) m; ?
- char *dmabufsrc1 = NULL;
! X2 M; l' M5 D% J - char *dmabufsrc2 = NULL;# u$ W" V8 e3 c G8 A# A
- char *dmabufdest1 = NULL;' I( z' ?9 }; }) |% R1 P. a$ ^
- char *dmabufdest2 = NULL;- O7 s$ y* N* a1 y V! P' l
- ' D3 y$ x/ {% H O
- static int acnt = 512;
. Q. \' |8 b# _; l$ L& _ - static int bcnt = 8;
8 {( M1 W/ w# l( o& K( S5 r' z8 C' _ - static int ccnt = 8;
7 Z, d- ~9 D" p! n! b3 o/ w - . @) R0 K) R, ^# B
- module_param(acnt, int, S_IRUGO);$ z( c$ N% @; y+ g
- module_param(bcnt, int, S_IRUGO);6 l; J# r4 M" H6 P8 }% I( J/ ~% E
- module_param(ccnt, int, S_IRUGO);
复制代码
3 I4 n4 b) A& n" G" W! u0 a f: F; I/ ?) n$ F% |) y9 h# f: i. @. i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) d) O0 f. Z( O' Z0 A' t- E
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
1 m3 |3 E. s' m, `. [3 ^ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 }8 ?" p4 J$ t% l
. a- _4 Q% L; s) ^$ ~! A6 ^$ x: ~( n
|
|