|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* s& G8 G4 y0 Y0 P1 p7 u# [- [code]EDMA sample test application
" v% [2 N4 Q) j' f" K) L - /*3 k$ ^0 d6 w: d
- * edma_test.c
4 O7 g8 z* w$ O# e2 x - *% j Z7 Q# W5 e: l/ Y9 T2 ~
- * brief EDMA3 Test Application
8 r0 h2 ]. x, a - *
) y% ?' ?/ q9 Z! g) G1 q - * This file contains EDMA3 Test code.
0 V/ Z' f6 x" d. J3 p3 O3 I* n - *
" D, e# _5 ` J% D S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 M8 {6 G9 @# C3 y; _. m - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' [+ l4 A4 E @: G0 w5 E4 Z! |
- * TO CHANGE.: E8 K! v9 r, `, B, @9 I
- *
$ k0 s" d& h' I( A$ V, D' K* j2 h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 k. I, K! l2 N: V$ ^, [ x3 m - *6 V6 s) G% C4 D
- * This program is free software; you can redistribute it and/or
* P+ r( f$ g0 h, ~4 x! D8 H - * modify it under the terms of the GNU General Public License as! i( |0 a( V) V3 l5 d# M' s2 e
- * published by the Free Software Foundation version 2.
2 J+ _! ^& E3 u0 h" u: D0 h2 ` - *
+ O9 W9 Q2 f- h' m& R; D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any% q! t; B2 O- {( s' H
- * kind, whether express or implied; without even the implied warranty' }2 D5 K% @1 g! W6 s2 Y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) K$ n6 o: v4 K9 b5 W - * GNU General Public License for more details.
9 I5 V3 E8 Q. H - */7 k { x" |; L
3 W/ Q; ^. \' y1 w5 G+ X& T- #include <linux/module.h>
% R, |( U) g3 R7 T - #include <linux/init.h>% k' l; R2 m [- Z; S5 s
- #include <linux/errno.h>
$ I+ f3 u- x$ j7 T- ] - #include <linux/types.h>1 G4 z* Y( l. W+ l9 c3 I. z. L) l
- #include <linux/interrupt.h>! f$ C0 V- h* }, f& _# [
- #include <asm/io.h>
1 @4 |# w. K$ ? - #include <linux/moduleparam.h>
6 ^8 n7 U9 M5 J8 a% D - #include <linux/sysctl.h>4 r# _% ?, A9 d- Y# R
- #include <linux/mm.h>2 c( W9 ~/ Q2 w5 p# c: T
- #include <linux/dma-mapping.h> v0 c) A) j9 i3 k6 G, i( M
- 3 n7 x/ U6 K) |" T. \
- #include <mach/memory.h>3 A- W5 j8 V+ q/ n5 \: G
- #include <mach/hardware.h>
1 p$ G& ?2 q3 a - #include <mach/irqs.h>
* V2 i' f w5 D* z) ^7 s3 `2 s& G& u - #include <asm/hardware/edma.h>
. h' S0 ^0 H8 u& q1 ^8 t - , c/ k0 e: B* Q
- #undef EDMA3_DEBUG; y" |- l7 X9 D& U0 k
- /*#define EDMA3_DEBUG*/3 C+ J3 W" k$ u2 d
% D' P; [$ L/ M- #ifdef EDMA3_DEBUG
}' p2 W5 ?* n+ b( x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ Y" l6 z$ _3 N4 b. X% @6 }7 X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- i2 c4 Z, e; A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 M9 \1 J9 l# s* M1 j" a - #else* W5 y1 H3 ^4 Q; t7 T8 J
- #define DMA_PRINTK( x... ); B( V6 P) c7 h& M
- #define DMA_FN_IN
( L- x; n4 V- [1 U2 ^; H - #define DMA_FN_OUT7 g _& s, n7 s; |) P
- #endif( v |. V6 K$ e b: N
- 9 I2 e( c+ c5 } U7 C
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
], ^2 J' B: z6 P - #define STATIC_SHIFT 3
8 _3 ?7 ^4 q( ? - #define TCINTEN_SHIFT 20. E4 r. i3 ^$ [, v
- #define ITCINTEN_SHIFT 212 W. o. R- K6 T. L8 u
- #define TCCHEN_SHIFT 22
- R" ?" Q. h5 @$ P: e - #define ITCCHEN_SHIFT 23
' Y0 a4 z3 |1 ?# y- y! g- r1 S( @4 _ - , P3 _! y8 ~2 S) c
- static volatile int irqraised1 = 0;2 J5 \4 ^/ w; F" {( W& Y: S% T8 p; }
- static volatile int irqraised2 = 0;6 p5 h5 F% \6 [ b1 R: q, }, \9 ]8 t
$ C; ~! t, E- u6 A C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 S8 y& F! A- x7 T% T1 B - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ f, J4 S1 S' U4 [5 } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& ~3 O- S, ~9 z- e3 {+ G( N6 b: c - $ V5 `6 i1 i: ]. G$ r( c
- dma_addr_t dmaphyssrc1 = 0;
" E/ k. g' X5 W; t! D/ [* J - dma_addr_t dmaphyssrc2 = 0;
7 x1 k+ g, t% V; Z! y3 y% m" o - dma_addr_t dmaphysdest1 = 0;
8 R, D% I& c/ ?0 m - dma_addr_t dmaphysdest2 = 0;
" o/ i/ \( |7 U8 _
$ t3 `1 ^) b, {# V7 \% _: p1 x- char *dmabufsrc1 = NULL;
) ]. c& @2 j4 J) E! f( [+ |, y# N - char *dmabufsrc2 = NULL;7 @$ Z+ Z8 G. T' M' o# l4 r
- char *dmabufdest1 = NULL;
% m; J. `8 A" y2 ?6 p! I6 T) u - char *dmabufdest2 = NULL;
( \* g* r3 A. @
6 z5 M3 X0 h- N9 G- static int acnt = 512;" ^4 B0 |2 ]1 h1 K3 f+ {
- static int bcnt = 8;
# M& ]) {0 J! U6 E+ E& f7 H - static int ccnt = 8;
: ]: N6 a* `/ x4 @8 u8 e
. i8 @ V2 J% } J4 Q. c' `- module_param(acnt, int, S_IRUGO);$ ~' `8 Q# @7 C8 K0 @' `
- module_param(bcnt, int, S_IRUGO);
4 C2 ~; S* E% Z, `. u - module_param(ccnt, int, S_IRUGO);
复制代码
3 g% _! R" w0 o7 k& R1 e+ ~8 m/ ? z4 i: l& z: c3 P2 ^& @7 K/ ?
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 G& i: s) V% R5 D+ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: f3 [8 K/ P! [' J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' q+ X, X+ q/ L9 ?
2 P/ }8 p9 y3 K0 V2 r" I8 O
; o) s. R( @1 w2 T$ d |
|