|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + X6 |8 S6 X8 D+ i' Z: S9 U
- [code]EDMA sample test application
& \6 A4 Z m w! e& p; E0 _ - /*: `; E/ ^4 ~, j! k. x3 V3 G* o
- * edma_test.c
! @, ^8 \: V6 ?2 M - *
3 y+ u) L8 M4 `( m - * brief EDMA3 Test Application- s4 b0 r3 [( s, ?7 n6 v* \
- *8 e/ {0 U5 n/ U- d
- * This file contains EDMA3 Test code.
: X+ w6 B3 W( g4 x9 @$ e E - *
1 U8 b' m5 F5 e, r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 {. c2 f8 E! n+ n/ E0 F
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 M0 _( ?: j: e! J$ Q& r
- * TO CHANGE. }7 S4 l0 K& }7 G+ T' t
- *8 _' I, W& t9 s* _+ R: m$ w! _0 A/ H
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- U+ [2 J- b5 _( ^6 W6 a - *
6 ?4 ^: `# Y4 _/ i: A- ^ - * This program is free software; you can redistribute it and/or
( F e% n# d3 ?, i" I- W - * modify it under the terms of the GNU General Public License as
6 {8 b- J8 o H, |& o. @2 ~8 }# X - * published by the Free Software Foundation version 2.
- p7 [0 q! K& z; q - *% A9 N1 ?& H9 S2 T2 U
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 _6 H' {7 v. k* S" \3 Q8 r - * kind, whether express or implied; without even the implied warranty
" r% Y+ y8 k$ O: x2 d! s - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 N6 ?) J- [- d3 ^ M( K. m
- * GNU General Public License for more details.5 K) {1 P# U' b
- */
# l) |! V, Z1 w" r% [/ w - ) M! i2 y$ B* V3 M8 Y% ]
- #include <linux/module.h>8 v: E# Z* L3 A* s" x
- #include <linux/init.h>" q$ w8 V1 G1 F. x, l3 R+ c
- #include <linux/errno.h>
% C( A: y; L, X3 f- ?, x% c - #include <linux/types.h>+ N0 U: y3 c' k1 k
- #include <linux/interrupt.h>" E! G! e1 h5 @8 z, \
- #include <asm/io.h>. X- \; _) }$ c# r* j
- #include <linux/moduleparam.h>" U* ~4 U( X+ w
- #include <linux/sysctl.h>
+ g7 c0 X$ U2 q# `/ S8 }& ^6 m5 T - #include <linux/mm.h>
" K' P1 a) @; w2 Z - #include <linux/dma-mapping.h>, f9 J7 F* p5 ` ]8 q- n
- # ~; ^' @5 T, J' |
- #include <mach/memory.h>4 G5 V9 G) r- _ R% ?& y
- #include <mach/hardware.h>
, t- ]5 J4 H0 v5 | - #include <mach/irqs.h>
! \' \# _: g5 a0 w' w# i4 g - #include <asm/hardware/edma.h>6 h5 Z' W4 `& f
) k. c. K' p' J- #undef EDMA3_DEBUG
( v" |% I# ~$ l9 i# M7 H5 Q - /*#define EDMA3_DEBUG*/0 p1 h. @+ D, C- N. F' J$ k
/ {7 B$ M& K9 s/ N$ k2 O- #ifdef EDMA3_DEBUG
0 h% {. @ r" l5 W: R, B' ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 h, h$ b. S, N; e/ _7 q6 v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& c8 @2 @0 G K! u5 C7 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ ^! P+ G; _1 A9 Y3 }; e - #else+ ]0 G% l$ T9 F6 r
- #define DMA_PRINTK( x... )
/ }+ w7 _ u3 x- A - #define DMA_FN_IN
+ [& S7 d. b; w8 [ - #define DMA_FN_OUT) w( y" F, X: R/ ^1 i) A
- #endif
: _- b: a' ?# m+ p
- R/ E' N! e! Y5 h0 Z7 }% Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 O9 ?8 z2 a0 h- b9 O! P; H5 y0 R - #define STATIC_SHIFT 3
9 G$ b! \* z9 F0 L! L# ?: U - #define TCINTEN_SHIFT 20+ O3 F' g, R- M" i
- #define ITCINTEN_SHIFT 21
" I1 J0 A6 n# K7 \8 E- F5 o1 O - #define TCCHEN_SHIFT 223 q6 M: b5 c, d& Q$ x( ?% D
- #define ITCCHEN_SHIFT 230 Z- O' L" D6 F
- ; K. M" e7 L8 W3 @" g H
- static volatile int irqraised1 = 0;/ H7 M! c. a2 I% M0 o; J
- static volatile int irqraised2 = 0;
2 P& {! }4 i( Z
1 K& D# y: _( |& Z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 y! I* f1 K( }& d5 i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 \! N- V8 @5 f# X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 `! _9 Q8 b3 v0 b
0 {+ H- m Z u- ~2 ?; P- dma_addr_t dmaphyssrc1 = 0;! M: d: F3 Z( x* U% t
- dma_addr_t dmaphyssrc2 = 0;
% }( Y4 p+ q. Y& j! P) X - dma_addr_t dmaphysdest1 = 0;- q: l) p9 H9 @, I7 n$ J) @ A
- dma_addr_t dmaphysdest2 = 0;0 u& U+ d: B# `2 x1 k/ h. w
- 3 b; M% F& U6 ? x. c
- char *dmabufsrc1 = NULL;( d% R, k V+ v* q. ~; w1 H
- char *dmabufsrc2 = NULL;1 V5 {8 R+ v6 W, t4 J
- char *dmabufdest1 = NULL;
+ o* n, e& A- j4 m3 E* M( @ - char *dmabufdest2 = NULL;9 S. f8 c% S& |& k* w( m2 a" E
( |' z3 \- v) C3 S2 n+ ?, I- static int acnt = 512;
% ?6 p4 }7 i/ Q5 r) H - static int bcnt = 8;# M; M: _; c' ]" T8 a
- static int ccnt = 8;
' G& z2 i" x- t& M7 `! k - $ A9 o% c0 S+ T
- module_param(acnt, int, S_IRUGO);6 c2 P1 Z. h# i% o) W; u
- module_param(bcnt, int, S_IRUGO);
. ~7 _6 n4 i7 w - module_param(ccnt, int, S_IRUGO);
复制代码 7 A8 [; M6 ^: k/ n3 M8 ~
) _; ?$ M9 C! k" P& [8 o0 r
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 z5 ^1 d, Z- B3 A) V
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 J6 S: c) t" Z$ N+ N 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( f/ t4 T& P1 o$ _ V* g8 d; e4 }
5 i" `0 `2 w3 m; I3 z
; S6 f. z3 @. e J; q |
|