|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# T* E2 x% o5 }5 R1 S S- [code]EDMA sample test application
+ w9 }* r3 ~% V8 y - /*: K" j. A/ I2 w7 }/ w$ K' V- h( q3 u3 h) _
- * edma_test.c
& y- j8 O3 P0 T% w - *% T1 ? F. I) S7 L5 i
- * brief EDMA3 Test Application
' u% a8 ^$ w; h. D% S- t; d - *
/ v; Q" a( L' P* _ - * This file contains EDMA3 Test code.
2 h- V7 e. T: R' \" F - *
7 P) X# q% B! F& o- `* F o/ v* | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 V* b" T$ |# G8 O/ G, k - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
}* H! n9 I; q6 l# A - * TO CHANGE.
( P: Z2 @4 s3 O0 u - *
# P; h, l( R. x& W, z/ g0 U: X* ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: {$ u/ R- m4 G( o8 r O: c
- *
" c9 w8 ]* |8 x" W/ p8 ? - * This program is free software; you can redistribute it and/or% m/ P$ d. W( @* b+ B V) B
- * modify it under the terms of the GNU General Public License as$ `) a- w6 n( i$ e- W8 y. v
- * published by the Free Software Foundation version 2.. R- |8 i' G" Y' W; i" T! N
- *4 }7 N! U" e9 m* C) y% E
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) N1 }2 b" E+ f/ n - * kind, whether express or implied; without even the implied warranty
3 ` h% Q" d/ k+ }4 [- F) _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; v" ^* n/ e' A# V. o$ E: y D - * GNU General Public License for more details.
8 {2 A& z. U* }* e* @! D - */( q6 J X+ @7 E# Z
9 H; K9 }% k' b1 }- #include <linux/module.h>
. G0 P& Z+ C2 r* |1 V - #include <linux/init.h>
) A' `$ o* O& x - #include <linux/errno.h>
/ w$ v. w8 a, L- |+ Y& j - #include <linux/types.h>. t/ g9 r* d& N! k* l
- #include <linux/interrupt.h>" Y: l; L1 z: q
- #include <asm/io.h>
' {) m3 V& {# K8 T; }5 T0 U9 p. ~ - #include <linux/moduleparam.h>
8 U2 e4 x7 V6 C" N0 D - #include <linux/sysctl.h>( r; j7 M# U; {+ I% o
- #include <linux/mm.h># n$ b5 ~8 l) e8 O/ G4 Z5 F& R- U/ u, U
- #include <linux/dma-mapping.h>
3 V6 n2 l% _0 c [ - " s/ c" ~" ]! y0 V; m, ]0 }+ ^
- #include <mach/memory.h>* ]7 X" u2 g$ O
- #include <mach/hardware.h>
" ]9 v4 Y; G, K - #include <mach/irqs.h>6 H3 e$ A# G7 p" ^
- #include <asm/hardware/edma.h>& A+ x" X; B, V! ]9 ]$ Y
- d5 f4 i4 @# ^' q0 _. u: m8 Q2 M
- #undef EDMA3_DEBUG$ c7 q# c2 b ^* @3 Q! A: ~5 F
- /*#define EDMA3_DEBUG*/
. _4 L i7 g5 [4 @+ p3 S. {9 J
; I6 l: M3 U6 O* W% m9 r) t9 I n- #ifdef EDMA3_DEBUG/ ~4 C o% _0 f- @. S/ J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- i! j4 L5 {) Y- o/ a9 g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 n+ b( l9 h# O8 D3 W, s: @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 H4 z4 ~ y1 E5 D% I - #else
: Y( W/ m; A2 z$ z0 K - #define DMA_PRINTK( x... ); T0 N9 `& V2 A
- #define DMA_FN_IN
* s8 r5 C6 R3 C* m. n - #define DMA_FN_OUT
( B5 u- ~$ x9 x- I$ t- l/ z - #endif; t O0 r) ]& Y; C. O; x% w
- - d- G0 Q7 C' f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768), K& Y5 L, ]6 H, ]
- #define STATIC_SHIFT 3' I# u {! P' B) V3 y, g
- #define TCINTEN_SHIFT 20
8 y$ A5 s: A( E" L$ O - #define ITCINTEN_SHIFT 21
. E2 ~" {1 l0 |3 ~% H$ }5 x4 r# j - #define TCCHEN_SHIFT 22
* \# N+ h1 J; t- d( X. b! v6 G - #define ITCCHEN_SHIFT 23 M! q% i, Y, J4 x5 L, E6 d* U
- 2 ?( a- p, g' E6 o3 P7 u
- static volatile int irqraised1 = 0;
/ R. j1 P0 m' q% [' D& ] - static volatile int irqraised2 = 0;" L& I0 D- C; \7 D. S1 }6 |
5 T9 C# C) F: f4 q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. B5 e" L% J+ J2 V( \* @8 E6 |/ G6 b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 q% p3 t( A- m! [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ u% _5 E7 Y9 F: C7 j: w5 p! b
- ~" C5 F' ?9 q0 w- dma_addr_t dmaphyssrc1 = 0;
* _0 n& G/ }8 n - dma_addr_t dmaphyssrc2 = 0;& j$ O! L C, D: h
- dma_addr_t dmaphysdest1 = 0;0 ]# N6 t9 N* w$ F3 a& P$ A8 s5 f8 J
- dma_addr_t dmaphysdest2 = 0;
7 X' ^3 k. Q8 n1 U% a$ P y; ^
( O4 \! `5 a2 \/ [! O& }' v( \- char *dmabufsrc1 = NULL;
4 N# W8 c3 V2 W ]3 O - char *dmabufsrc2 = NULL;
& [$ Y3 E4 m4 l- n% d- }* e - char *dmabufdest1 = NULL;* K+ K7 D) i1 ~5 K! S% r7 T+ o' |
- char *dmabufdest2 = NULL;
9 R9 W$ D; j F2 s2 b
+ B% z" P* U) V% f1 U- static int acnt = 512;
$ q3 o, [- Q6 X3 G5 U5 I - static int bcnt = 8;
+ y' H+ S4 D0 w8 Q - static int ccnt = 8;& c" D* \4 u6 q8 A; a3 m: ^& c$ p
1 M* A% _% t: U1 r8 j9 s9 B$ v, l- module_param(acnt, int, S_IRUGO);
" |& Z- e5 M o - module_param(bcnt, int, S_IRUGO);1 r6 Y% L' S/ B9 r
- module_param(ccnt, int, S_IRUGO);
复制代码 ! m' i/ x, F7 p, B8 ?
1 A7 j4 H O! P: K2 p- x 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 l$ C4 v& S: t. b! [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. U: p3 z$ Z7 s {! D: x, S( |5 l- m 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 ?5 [; D+ i% p0 R- [2 w" p6 d
! s: b9 i- Y7 G9 P
6 ?3 h- [5 L0 p
|
|