|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , [8 W* s) S" A6 X" w
- [code]EDMA sample test application5 J2 o5 C; J" M
- /*0 u6 b: k. g* | ?$ g
- * edma_test.c
7 a. v# u8 V5 I' ]- E- B - *
- C2 @2 ?4 T6 n$ ^ - * brief EDMA3 Test Application
+ F* v( C" E7 Z9 p& a! X" d* N% ] - *
2 T& s0 ?6 L) X - * This file contains EDMA3 Test code.& \& o' g! {- V! B
- *3 K/ @1 A+ ~( x) B7 @8 g9 {
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 {5 \/ t7 V" {- k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ F+ E3 V& g' u$ G - * TO CHANGE.% i8 ]; b5 i. l' q1 A J( [
- *
0 w* f' [/ {/ j0 \ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ `/ ^* Q9 y6 @2 R$ _! O - *" t3 Y- P" _0 D) H8 J
- * This program is free software; you can redistribute it and/or
5 P! @6 H( y/ Q# a/ t - * modify it under the terms of the GNU General Public License as4 ]+ h" p, N' G, ~" \
- * published by the Free Software Foundation version 2.! T. `& }8 N2 e) v2 P$ G8 L
- *3 r r0 j7 l$ r# u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 K: u! x; V' K% c' h0 i3 R' J
- * kind, whether express or implied; without even the implied warranty/ S3 X4 ], y4 k1 S5 x" t( X$ l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! B0 Q: I- N8 r" ]+ }
- * GNU General Public License for more details.
8 o. O* `. V- U5 i - */" `1 B4 ^- s) Q/ [3 @+ Z) M. ]
2 w- [& I- l# J" ]; c- #include <linux/module.h>
, X& x" N. O8 N - #include <linux/init.h>" S2 z: j! V; M4 `( C
- #include <linux/errno.h>
: R3 X l# ?7 w! W/ e( V* Y: i - #include <linux/types.h>
1 v$ q; v1 v) s$ V% K6 A - #include <linux/interrupt.h>$ c! o9 e# U7 h6 y
- #include <asm/io.h>
9 m7 }9 t6 c8 X+ r1 n. K% q Y - #include <linux/moduleparam.h>% q# I2 x! R; o5 n4 [1 S: X
- #include <linux/sysctl.h>
: y6 W$ p$ i G1 J# d+ q/ _ - #include <linux/mm.h>
" F! q2 S+ a! e4 S6 Q; u' p: h - #include <linux/dma-mapping.h>
# i9 ~. a7 E; X6 [4 E; ?
% i* W) _* ^; w5 n8 t- #include <mach/memory.h>
9 }+ _% f' q& t6 O5 Z! Y - #include <mach/hardware.h>. R6 X4 W) o- t9 R& a
- #include <mach/irqs.h>9 k8 z1 x \$ k6 g
- #include <asm/hardware/edma.h>3 ?2 j7 Z" O8 R. K2 s+ I6 w
- # Q+ u3 R" `, t% ~# O$ z+ L0 ]
- #undef EDMA3_DEBUG
c6 @7 _5 w+ Y& B6 n( I* x - /*#define EDMA3_DEBUG*/
, y7 D! }. J3 U% `
3 t* M4 w% K' s3 D- x- j Q0 G: E- #ifdef EDMA3_DEBUG
" L; I( r8 x+ z9 T- v+ v/ P - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, o" k0 M1 f9 N% @; e) V) J - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 U! {# k+ g+ w6 b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 n' y6 x/ P; p& u6 f* ?$ @" s& S
- #else) H! ]' Q$ k3 ?9 K" o3 W( R# ]
- #define DMA_PRINTK( x... )( Y9 {1 j/ m0 f3 F
- #define DMA_FN_IN( {0 }3 T' I; r1 {6 }' m Q
- #define DMA_FN_OUT
' S7 V& W% Y$ C4 u& V. S7 h# H - #endif+ ^, ^" Q& c* }
5 o4 d; g5 ^4 f* ~- k& P0 U f0 f- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 }% p" O* \; r V* i1 W7 l - #define STATIC_SHIFT 3
2 r5 x" S+ A7 [/ _0 s0 \& `1 |; ] - #define TCINTEN_SHIFT 20% j0 ]4 i8 w" F- H% z- P0 M
- #define ITCINTEN_SHIFT 21
h* ?- q" |$ m# w6 F/ H4 t6 J - #define TCCHEN_SHIFT 22: O3 n. f2 B0 N. r9 C
- #define ITCCHEN_SHIFT 23! v+ w( C( d# |8 f# V, V; s, |
& t. V/ X; I- i/ U% O1 Q- static volatile int irqraised1 = 0;; g8 F& r- t& a7 n1 }3 k
- static volatile int irqraised2 = 0;
* x4 i7 v! j5 o/ h. l) m; w
( O* ]* v5 T8 v2 B. |9 Z' U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, a4 a- n9 A9 e8 E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# a `' N9 }4 s5 e/ ^, g - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 u1 z5 _- s% ]- a8 Q
- 5 c8 o1 V2 u- Q! `
- dma_addr_t dmaphyssrc1 = 0;
9 b3 ~3 c% o1 x7 S - dma_addr_t dmaphyssrc2 = 0;1 }" E" l6 K+ x8 z1 `6 e. f6 T! ?
- dma_addr_t dmaphysdest1 = 0;2 v5 N! Z- N7 J% K' w9 B( K
- dma_addr_t dmaphysdest2 = 0;+ ]9 ?& [" Y: G) h" k
% L8 g$ B( b: l6 t- char *dmabufsrc1 = NULL;
0 l( u- N. @* a- I - char *dmabufsrc2 = NULL;
8 \6 T& [: @- M6 l( y - char *dmabufdest1 = NULL;1 `; e2 M& M, x5 `. d, A$ q
- char *dmabufdest2 = NULL;: i' B6 v* \- b( p
' J: w0 { W2 J: p7 q- static int acnt = 512;
7 z# ?) D! B' @3 Q6 h - static int bcnt = 8;
, ?9 d: ^8 z; {; X$ n2 l4 ^ - static int ccnt = 8;
`9 O% d; s! L5 a \/ P - ! ~% s& N$ A2 G
- module_param(acnt, int, S_IRUGO);+ c6 p% K o/ e* P7 `1 E
- module_param(bcnt, int, S_IRUGO);
g# B+ W! \3 G* u0 \8 W7 Y - module_param(ccnt, int, S_IRUGO);
复制代码 % W5 U2 Y: x4 r/ k, {
+ ? H5 |" t4 M) p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, x, ~7 Y5 h9 p2 N6 C% Y
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 i/ G8 Y) E; \; A& T" B3 @. l 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 ? [; `) U% ?3 j& X$ W u6 w
; m3 H. @& {, S: F6 l; Q( A4 m
! |, @9 [! D6 u' g5 ? |
|