|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( A. i, V9 l8 |2 P- [code]EDMA sample test application
5 W# l$ J4 M$ R - /*
# B8 r& U1 X; l0 \. t - * edma_test.c
2 a7 N9 g4 w: z3 y8 B/ f4 `3 K8 N - *
: A' {$ Z) K6 g9 c" O: ?$ B - * brief EDMA3 Test Application
. H2 f% ^" x8 @, c' ?1 r - *
/ t/ Q( P' y) P& N, ]' v+ u p - * This file contains EDMA3 Test code.. [1 M& ?$ ~1 o* S7 A" h7 y! e7 P, B
- *- u x0 l+ M9 D2 A- _
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 j6 D* Z |4 X: _, K+ v% R/ [3 [$ E - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; j n/ S# A6 W
- * TO CHANGE.
3 j2 S! M$ j9 Q6 O+ m- s6 b; T - *9 f. D- o+ B; }. D
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ I( s9 T! B9 q$ X
- *
- T8 `6 a7 Y3 r3 U" b8 F) S- F - * This program is free software; you can redistribute it and/or9 I2 X) c6 F# F! H$ U, h! a
- * modify it under the terms of the GNU General Public License as0 A) z ~3 E+ \& d1 z3 U
- * published by the Free Software Foundation version 2.
1 ~5 M2 T( d: }- x6 o# f - *4 Z5 z& @- X/ a
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, V5 e* j9 C- j! | i0 k
- * kind, whether express or implied; without even the implied warranty
& n- ?+ V- u5 P4 B" o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 A4 [; Y+ J- ^! i" a9 P! o* g6 j5 E7 l) ~ - * GNU General Public License for more details.
4 y! ?$ T7 k: l - */ r$ F7 a8 `/ ~
- - k' j. w/ e* Y/ C& c! W5 R2 f3 ~
- #include <linux/module.h>
6 \# G( @; K6 }. V/ g% M- \ - #include <linux/init.h>
" Z" b0 U% ]9 n/ `: \) ^0 X - #include <linux/errno.h>
% k+ o2 ?+ p+ \ - #include <linux/types.h>8 H' Q+ r& ?. ]. w, n( w
- #include <linux/interrupt.h>
- k" O% E: z; Q7 z& ]1 x9 y* [. [( Q - #include <asm/io.h>$ p! }3 O9 @1 S: {% Y
- #include <linux/moduleparam.h>
5 J- F5 t7 m/ J, \' A9 r* m( W - #include <linux/sysctl.h>
. R9 t' D; Z, x7 `' r% w' | - #include <linux/mm.h>
; G& y' h! z `4 [ - #include <linux/dma-mapping.h>% x- i# y) S+ s2 i; v. K
- + H k9 L1 j; u
- #include <mach/memory.h>; y) X1 R( X/ }0 l0 B
- #include <mach/hardware.h>
) E \% g4 S8 n& X6 E' T- u - #include <mach/irqs.h>4 F5 {+ ~/ ]* h, E/ t: s
- #include <asm/hardware/edma.h>% P. U) S ?; m9 Y& `/ n! N
- 4 q4 S; n" ~1 q' d/ f3 |, i% L& h: q
- #undef EDMA3_DEBUG/ B& j" E% q' ^. ~) \ d
- /*#define EDMA3_DEBUG*/( V' R- _9 m- P1 w! F
- 2 c: f6 ^2 v) T# i
- #ifdef EDMA3_DEBUG
/ L3 s$ `4 ^# R) p8 W: I6 ~$ A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)1 _7 w# Z+ c' q4 ^ @. Q3 ]8 p
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& U+ n7 ~# ^0 X( T! p1 y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* N( p' f% F, I0 o - #else+ B) _) I7 e" a+ J1 e m) E2 H
- #define DMA_PRINTK( x... )* ^/ z' B ~- M9 q9 ?& t: W6 f' @9 G
- #define DMA_FN_IN
6 Z. {$ \- a w- N# Y - #define DMA_FN_OUT" d" K. `/ z9 w$ t6 B6 W* G$ q+ R
- #endif
# f ^# D: ^' h
. ^$ `/ e. f) y! p/ l' }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 G2 }# m4 s( h- Y& { - #define STATIC_SHIFT 3
- W/ z, a! V2 K$ F( B+ e } - #define TCINTEN_SHIFT 20
" v0 X$ f! s8 |2 ]& E, G( } - #define ITCINTEN_SHIFT 21
Z/ s7 g2 z: x5 Z6 B - #define TCCHEN_SHIFT 22! a( K! P+ h U2 e% g- |9 D6 h+ F3 n
- #define ITCCHEN_SHIFT 23
8 w( f* a2 I0 h
3 x8 U0 ?! ~# N3 R8 w- static volatile int irqraised1 = 0;3 W. u6 R7 O3 ]" r
- static volatile int irqraised2 = 0;
& L- v% a) M; s6 n" E
! G# X7 s: U9 N' l4 e& m, U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) T. t/ ?: W& F- h+ O( B: c H6 H9 ` - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: ]+ w; f( ]* L$ B; {/ S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 I4 u- |+ s% b( n, E5 }/ @
- F4 Q0 C' M0 _: X8 T2 d* @6 z) b- dma_addr_t dmaphyssrc1 = 0;7 L, x0 |; v! H6 N/ L
- dma_addr_t dmaphyssrc2 = 0;
5 d p/ k6 d( K" h; e* L6 z) X - dma_addr_t dmaphysdest1 = 0;
3 R7 I4 b* P! J( j - dma_addr_t dmaphysdest2 = 0;. E' g$ X) Q5 ?- |# F, \5 X
* C* u4 \9 \+ ]- char *dmabufsrc1 = NULL;0 p0 N7 g. O7 ~- |
- char *dmabufsrc2 = NULL;
" n1 n. U8 E3 Z8 l* F - char *dmabufdest1 = NULL;' j# _) _& f3 b
- char *dmabufdest2 = NULL;/ @. g: k2 b& O% F% K9 U( Q; a
- ; w2 ], x5 U# M/ f
- static int acnt = 512;: a2 b c2 ? b. p: ~* l( T
- static int bcnt = 8;
4 \6 ~' L8 h8 E0 y. |" @# V - static int ccnt = 8;/ N' a& ^* { [5 } [
# s' ]( n" A: c- module_param(acnt, int, S_IRUGO);
& _5 G3 P6 o. G5 v - module_param(bcnt, int, S_IRUGO);
; n6 P# O0 i" J& n+ g% S1 u - module_param(ccnt, int, S_IRUGO);
复制代码 $ F# ~; r6 i* \/ [; k
; n9 |* C \3 w4 g" l4 l! |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ j- {% V4 R; N6 j1 farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& L( _2 d1 b: t: K/ l
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, q0 V0 ^. g( c0 j. T ?8 \
* q3 X( T% B5 l- ?2 n5 o" _2 x; M, F: S1 ]8 m0 q0 _3 V; o
|
|