|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ X& U- d# Q4 q/ \3 a# f- [code]EDMA sample test application
& h4 k& I u. d( [( D* c - /*
) f* x- _7 h: f$ g1 P- F - * edma_test.c
3 u& i/ e- m/ M3 {: c+ \ - *
& e& T, T4 r, t - * brief EDMA3 Test Application% o0 H4 s; y7 L
- *7 Q5 F. v6 F0 X# ~, C) M$ f# y6 R. v
- * This file contains EDMA3 Test code.
3 T( F; e' t, G5 a5 @( q! [ - *
3 Z( f/ b! z' D" J# S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ Z- l f: p) D, b3 _! V$ S3 k- a ] - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! x4 l0 p. V: {: J. e" F' ~3 f- K
- * TO CHANGE.
1 Z, J* c% k2 g- Z, D8 G( w* H9 o - *
. D" U( T) ?+ K8 J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& y) s1 O% K; w4 k) x9 J- O+ w
- *- O1 Q3 L6 A8 P6 d% K
- * This program is free software; you can redistribute it and/or
+ {( E, y0 l5 U/ R - * modify it under the terms of the GNU General Public License as: Z# z$ k+ P$ g& C# A9 Q
- * published by the Free Software Foundation version 2.
; v& a% ]0 J, y$ X - *
' x5 w/ R% k. n. u, T4 c4 @: S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 v" z9 a Z! G' X( D( i0 F
- * kind, whether express or implied; without even the implied warranty
% `% y/ z; C) Q2 V6 r6 z; c1 d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 H, l/ {, L) m! Q1 ` - * GNU General Public License for more details.2 k- k# R5 z* Z. l. v9 n, x
- */
$ `) ]6 b% q m) S& l& ~, n6 g2 j/ p - 7 |& H- z) ]) r% `+ D4 k4 |
- #include <linux/module.h>% p+ ] H+ @! k, x! W6 p
- #include <linux/init.h>
( B. f% w6 i- Q/ f - #include <linux/errno.h>/ A+ S7 P- I7 {" f: {, q
- #include <linux/types.h>- `6 B* S" M$ w& a" E
- #include <linux/interrupt.h>& A5 ?! s, W/ _2 P4 }' ^( |3 ^
- #include <asm/io.h>! ~* }% P& z7 U3 `, k0 q5 X5 H) e t
- #include <linux/moduleparam.h>8 B0 ^4 R+ O6 N9 z
- #include <linux/sysctl.h>) z# _/ X' F6 K, g9 D/ s$ w+ C
- #include <linux/mm.h>; N, }" [5 ^' i; J
- #include <linux/dma-mapping.h>0 O9 ]) t' V" s! y6 k5 b
- 4 `5 v6 T' d# t# a# V C0 N
- #include <mach/memory.h>2 o! |3 T8 Q; h4 P- ^: L
- #include <mach/hardware.h>
: M; e- s0 }' `) K& T: C - #include <mach/irqs.h>8 P: ~ M2 w( m4 E
- #include <asm/hardware/edma.h>* p9 s8 n9 Z# t; u- I
- 7 J1 |1 q g- R' g
- #undef EDMA3_DEBUG" D$ ^' ]- k% p) q3 K; J
- /*#define EDMA3_DEBUG*/
1 K7 P/ h0 j5 K5 L% |' P
! `6 X+ y! w3 p. r/ L J3 x- #ifdef EDMA3_DEBUG" p; V3 F1 @( C1 }' A/ w
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)! H0 n$ a: P2 h* h$ M& D) U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- k6 T9 E' T O$ }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 n2 u0 c" y% d. }4 V4 ]' `' E* Z
- #else0 g- ? W3 I3 a5 e" ^( ]" G0 B( E
- #define DMA_PRINTK( x... ); T/ N; g3 k) n7 p+ [
- #define DMA_FN_IN0 y# l/ x5 b8 Q2 O
- #define DMA_FN_OUT8 X+ Z a+ R$ [( R! I8 n# {3 C
- #endif* q# @5 f0 D; d$ y
- $ E% F7 x2 g3 |
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
|, ^& Z3 A7 r \! d# ? - #define STATIC_SHIFT 3$ n+ {; i5 o* r! N2 K' A
- #define TCINTEN_SHIFT 20; }/ ?. [5 q' x( O3 S7 `' ^
- #define ITCINTEN_SHIFT 21
7 _" P; r( |8 { - #define TCCHEN_SHIFT 22. A9 s/ L! m1 J! B3 d. H: B
- #define ITCCHEN_SHIFT 23* Z) M! Z( c2 j& d# V
7 J+ M! J- ^* @7 F4 a' u- static volatile int irqraised1 = 0;! Y& T9 s7 X+ c* Y
- static volatile int irqraised2 = 0;7 l6 P; k0 z ] H) d
5 y( o, G1 o5 G1 v% l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. E/ N5 T4 X" H- y9 l b) N - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' }* s$ r4 F- u( |: y6 f
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. B0 H# }. o: E
7 t! G! p" g) E( t- dma_addr_t dmaphyssrc1 = 0;
' I9 C0 W; K# U. F, ^ - dma_addr_t dmaphyssrc2 = 0;
3 b: o; ?2 W) q7 j; A3 N# ]7 a - dma_addr_t dmaphysdest1 = 0;; L, g1 [% B" L4 {$ {. P! P
- dma_addr_t dmaphysdest2 = 0;! Z) v+ h- u/ r: t. s& M
- " {% t9 ]6 \4 L9 k3 A
- char *dmabufsrc1 = NULL;
6 F) ]2 P7 [& K6 h2 f - char *dmabufsrc2 = NULL;5 Y+ [( e- g5 Y8 r( c. F) r! L
- char *dmabufdest1 = NULL;0 i$ V2 o# Q6 x$ K
- char *dmabufdest2 = NULL;+ d! ^% G1 U; n/ E/ M: t" M
+ d+ y% [# m! D$ h, I$ v- static int acnt = 512;7 @) }6 }/ c, M2 ?# u( f: q" K, q
- static int bcnt = 8;! m% ]8 ], p, \9 n0 F& ^6 p
- static int ccnt = 8;& |, J6 ^4 N- F8 k* F6 Y; E
8 U# K+ K& g# I; K6 w* ~- module_param(acnt, int, S_IRUGO);# b# _+ u1 ]% L) t, H
- module_param(bcnt, int, S_IRUGO);' \9 T3 z& S& J* D4 Z8 X
- module_param(ccnt, int, S_IRUGO);
复制代码 ) e) u! Y# ^+ r4 [* E' y; a4 J
) Z" R( j' O& l' Z' q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, H9 Q- e% g% P( K" darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 K1 M$ P n0 T' U( F* \+ z+ H; ]. F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! Q" ~) u- D' @ F; n
& d& J" x$ @. R8 s- D5 B: Z1 k0 i8 _, M: Y: M P& |9 K
|
|