|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : n% f/ r* M$ Y' s5 p* \2 K! e
- [code]EDMA sample test application3 c, P+ j9 P& y
- /*
! s5 K" @" T6 C - * edma_test.c# D9 u3 U) D2 U" m& M+ B/ M' ?# U
- *" W) ]& n- s% z' S/ O
- * brief EDMA3 Test Application
3 s" q" W7 w4 ?7 ] - ** T6 k& X) ?+ N! ^. J+ T! X7 C' E
- * This file contains EDMA3 Test code.
+ c' d; `# B) h4 x5 m5 h - *
% K4 Z4 E0 |; r8 J. d4 C; l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" x7 Z0 x% A% ~3 ]$ d( v
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 t& Y* f- F( K/ q. g- B3 r - * TO CHANGE.# h H5 F/ w* h" e: F
- *; v" q' G+ \" r) p" R/ Z9 z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# } B' _9 B% a( E6 g, ]6 b5 v+ T" W
- *
& G+ N2 U1 I9 `( p7 H* p3 a% ~ - * This program is free software; you can redistribute it and/or
% X, ^; s6 E" c* S8 j& o1 e6 P - * modify it under the terms of the GNU General Public License as+ O+ _/ g8 j3 Z! |
- * published by the Free Software Foundation version 2.# R/ a# k- q3 Z. }* n8 h# ]
- *3 {' {( L5 g/ g' \& V! c4 d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! P. w. ~+ Z9 R5 m* b+ @! ?% \ P - * kind, whether express or implied; without even the implied warranty
8 A9 L! c0 |! f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! J1 G! K( B( h v
- * GNU General Public License for more details.. y! J3 A6 T! L% {8 S0 ?
- */# U' \% g5 m% U- G) z6 B4 h* Y1 m
) U& q1 h6 k# u( `- #include <linux/module.h>
8 m# h" w" l' @3 L3 c; y6 _' n - #include <linux/init.h>6 b9 W: a0 K/ ^: x+ X+ m. h
- #include <linux/errno.h>0 {% m+ k' Q$ f l" a
- #include <linux/types.h>
1 {2 C# r6 k% _* D/ E) b - #include <linux/interrupt.h>$ Y- O6 t- f% z# j
- #include <asm/io.h>
! [ a' q6 D9 z( {& ~ - #include <linux/moduleparam.h>2 v; ?$ S& ^' x
- #include <linux/sysctl.h>
4 Y! z2 _2 z ~) F* l+ d - #include <linux/mm.h>
$ G% B! o$ ]1 t _6 b. C/ ^* B - #include <linux/dma-mapping.h>
3 n0 W( Y# `. e* w5 f% k' q' V
5 \8 e' z& U) r: o) _- z- #include <mach/memory.h>6 Q& W$ l/ w8 V2 R
- #include <mach/hardware.h>5 l( M& J1 q* U. d" n
- #include <mach/irqs.h>
) H! {; i" A% L( ` - #include <asm/hardware/edma.h>4 ?% Z' u$ i# Y0 U5 k
5 ]1 ?" ]6 o, R$ r: Y5 O- #undef EDMA3_DEBUG
8 M. R3 e9 y3 d. E! I1 P' U0 Z - /*#define EDMA3_DEBUG*/
0 k. m: B" b% X4 b: O; x9 b - & m# |0 f" y- f: c. ]- ~) F8 @: R
- #ifdef EDMA3_DEBUG
- j% a; ` H0 m" ^ i - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# K/ x( H" m4 r% l- l: s: d2 H
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 z: u @/ t, I5 O1 w" V' U* b
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" b% @! ^6 Y) @/ v3 g. Z' R4 E q - #else
. l8 C9 [* R4 y' d* V2 E. W- m - #define DMA_PRINTK( x... )
4 [% s( N' `# d) O# l$ ? - #define DMA_FN_IN
2 r2 Q6 u$ s1 ] @ - #define DMA_FN_OUT: ~+ B$ O# _& ~2 x
- #endif
7 P, z& X2 J/ y0 G - / N/ f; y) f4 d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 \/ u- ]% q3 L& T& D4 s3 _ - #define STATIC_SHIFT 3
+ r' f, j8 W7 }3 f - #define TCINTEN_SHIFT 20 g& Z* p1 p0 z
- #define ITCINTEN_SHIFT 21
' |- V- {9 P6 E" ^/ h; r& A$ z - #define TCCHEN_SHIFT 22
8 A0 ~% k8 g6 n0 b* b - #define ITCCHEN_SHIFT 237 i, c5 l/ z( ]: z6 |
- - w* P) v8 F) h3 y" I1 o8 K( A
- static volatile int irqraised1 = 0;
3 l' W" y7 C0 B6 J - static volatile int irqraised2 = 0;
1 z8 q4 t, X0 L0 L% g
* |: n9 N. ]' x' F2 f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ s9 i! n, u) Y7 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
w6 v' Z. O8 G3 y - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 _+ X, ^0 @0 x, f9 k% W
6 J. r% F4 V5 _! F) A/ Q- dma_addr_t dmaphyssrc1 = 0;' n" t! C! n& x
- dma_addr_t dmaphyssrc2 = 0;
" Y( X: i7 s; j: }2 { - dma_addr_t dmaphysdest1 = 0;* e P/ p: T; f* S/ o) N; P, m# T4 p
- dma_addr_t dmaphysdest2 = 0;
m/ Q T# ]" k/ b; Y n1 Y7 Q - / c) w. y0 O2 L
- char *dmabufsrc1 = NULL;
2 J$ {0 C- I/ c$ t1 Y5 l+ ?( d( w% x - char *dmabufsrc2 = NULL;
: v: M/ M' V5 d0 q8 w6 p - char *dmabufdest1 = NULL;
- b' R: V4 G' T- G - char *dmabufdest2 = NULL;
% ~5 L* K$ k9 b V - N0 y8 ]2 a* @# Y3 C
- static int acnt = 512;
; u R v5 M7 C' ~, k! c c - static int bcnt = 8;
5 C P2 W' K" j( A6 \ - static int ccnt = 8;. J6 Q8 ^" }6 u& H6 N
- % y# Z( e9 ?& I3 \) k
- module_param(acnt, int, S_IRUGO);6 m$ D! C. Z: M9 P I( U# S3 P
- module_param(bcnt, int, S_IRUGO);
$ r% B, I: |$ L; I - module_param(ccnt, int, S_IRUGO);
复制代码
) z$ _* z* [& V( T. b
1 e2 U$ R+ X Q4 a 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 P+ b x! A8 k3 x" p5 C) _& L( oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, C: |* E4 s, e9 F( H. P2 m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ e/ b/ I q9 P5 }% l/ y/ L
3 T* J4 F. c1 ~5 {( s) S; ?' X7 K1 b- j
|
|