|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 v7 x7 I4 u( a, e2 G7 t6 U' u
- [code]EDMA sample test application& y& q( ^1 N+ t4 n( y# b% w1 z
- /*! }! a! b% b3 e' E1 w: j) R+ Y
- * edma_test.c
5 I1 y' } k: J/ |7 q - *, ^, ^ Q! y' ^, A. ^( X1 {( J1 c
- * brief EDMA3 Test Application9 U B E4 C$ v( S3 q
- *
5 B5 A! ]' b4 w5 E4 d7 C0 V* F" n' i - * This file contains EDMA3 Test code.
% F, J" `& V5 ]) t - *
! ]. S0 P$ ^' f$ U7 c3 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ Y1 Y+ s q& U' A+ _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 d7 ?7 C: v: Q( W4 U4 O' T - * TO CHANGE.7 J6 b( n* q; C/ e) s& T5 q" p
- *
* @" O; O! ^ I5 V' {% g - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* X+ }9 Y; h+ l/ O M; h' }1 h0 D
- *
( C- E" ]2 V/ _% P - * This program is free software; you can redistribute it and/or
& \0 g5 {3 ~ r( j( D% W - * modify it under the terms of the GNU General Public License as
& C+ w6 f( a' T. z' m. P - * published by the Free Software Foundation version 2.( v: H1 p& T- c8 J; e
- *: q4 _; n' e- Q9 l
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: B0 S9 b+ l0 }
- * kind, whether express or implied; without even the implied warranty6 o: ~. u3 U, C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 A2 X, J5 P) t% i: ? - * GNU General Public License for more details.
+ g- J6 G4 r/ `2 `3 C - */' }" b7 e8 L- |2 K( q
/ |1 H: ~5 f5 d5 ^, S$ Q0 w- F- #include <linux/module.h>
# S% S, V6 t! ?" V! k - #include <linux/init.h>
/ B* i( O/ @+ ]# n - #include <linux/errno.h>6 x7 z' N+ e- n+ k5 D H
- #include <linux/types.h>
% k) M5 w. Y' M1 v$ Y6 @# D - #include <linux/interrupt.h>6 W4 D# O5 }. q' C
- #include <asm/io.h>
3 Q8 s; t3 z# } - #include <linux/moduleparam.h># G& z) f" r' Y" G9 V& m% ]: H8 p
- #include <linux/sysctl.h>
+ y+ E1 y) M6 G! ~. M4 r - #include <linux/mm.h>6 |; E8 b& \; D& N9 `9 v
- #include <linux/dma-mapping.h>
) A# Y5 T( k+ t" v, _3 Y - ! {5 L& L1 ?7 h* Z& R
- #include <mach/memory.h>
* |' H7 H. y K; Q4 x6 `1 G; j - #include <mach/hardware.h>
% s1 r4 ?5 j0 {5 l - #include <mach/irqs.h>/ t" Q! R& b! Z5 i8 L: E
- #include <asm/hardware/edma.h>
8 }8 b. I# o# G9 [
$ C+ v! l, @& E! r" o6 s- #undef EDMA3_DEBUG
' p' I5 j0 v. O9 B4 V - /*#define EDMA3_DEBUG*/
$ A/ l+ T2 L2 ^# K - ' W) N6 m3 M2 H1 d9 F7 [
- #ifdef EDMA3_DEBUG
( p3 l# m- D5 F# i' ?8 R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% w/ @) \# z& X- u1 ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 ]0 E* L6 B& y& d& x* ^# s - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- L: h6 l5 x; g - #else3 c& p w) W" y- C5 q
- #define DMA_PRINTK( x... )
4 n- W/ _; G" M& R( F - #define DMA_FN_IN
0 S$ r- g: _7 q - #define DMA_FN_OUT* L3 W: p5 s4 i5 V0 ~- \- ] b: j. d# ]
- #endif
/ @5 P. g7 s$ q( r - & d4 B) k' @( q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ Q8 S. i* I5 E. v$ _# ]4 m
- #define STATIC_SHIFT 39 n! I% J% L; ]" W
- #define TCINTEN_SHIFT 20
( c0 i1 _! o/ P0 M6 ^5 T+ l) X) [% ~ - #define ITCINTEN_SHIFT 21
/ s4 ?- F( |% _& P - #define TCCHEN_SHIFT 22
' ^1 |+ n: P i9 d" i - #define ITCCHEN_SHIFT 23) e% x* d* |0 y# X
; |6 D, R# U i- B0 \& }+ P E2 o- static volatile int irqraised1 = 0;
; c! Y) @) A4 l - static volatile int irqraised2 = 0;# x: R0 M- w. F2 j/ \9 j# n
$ e# u3 c) X8 M* P" H7 v/ c- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; z: ^' X& {9 Z5 s! {! `( N2 g - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ Z0 u/ I6 ]0 _$ e+ `6 h+ [2 U7 u# F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 ?5 d5 e8 V9 P - 3 R6 R* d" ?3 z* `+ o
- dma_addr_t dmaphyssrc1 = 0;# @1 Y) H T" ~
- dma_addr_t dmaphyssrc2 = 0;
; [8 Y" y; a4 ^/ v6 O' L# I: c - dma_addr_t dmaphysdest1 = 0;
8 @ [& K% ]# P+ c2 Y - dma_addr_t dmaphysdest2 = 0;7 x& [( Z" {3 c1 s) E4 W
; T! _& M% A5 @2 S- char *dmabufsrc1 = NULL;
; B$ w8 i' t% ?% l - char *dmabufsrc2 = NULL;
2 u8 {% i1 i+ |* C# | - char *dmabufdest1 = NULL;1 x; S" k0 |7 h7 Z
- char *dmabufdest2 = NULL;' Y% r, b0 r+ f5 L
- 0 H+ ^: r$ S! \/ a- a
- static int acnt = 512;
; {" v0 h4 V9 y% _ - static int bcnt = 8;( i( |( i9 V% k6 K: P& l
- static int ccnt = 8;
( t2 F7 ^# F& q. |! K - - Y, X8 p7 U& T
- module_param(acnt, int, S_IRUGO);
2 k3 C! A) N# y/ \2 D# o - module_param(bcnt, int, S_IRUGO);
2 T4 _8 y- U- t& W x9 k& q: v, s - module_param(ccnt, int, S_IRUGO);
复制代码 " Z3 Y; j7 F$ H8 u2 Y, `6 s
' x4 r9 j* ?% n. K7 S5 S
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( o- w: q6 d3 u8 S' v1 ?+ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* P/ A/ |! ^5 { 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# Y! `& X8 l5 ]) }, n
" p& t! m5 \& q; E" {" |1 F( Q, T! z$ t/ }. x/ ]8 l
|
|