|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / x P j2 \0 N
- [code]EDMA sample test application
2 A2 w9 {9 ^& p9 ~- h7 R! r1 p+ Q) ]9 { - /*
( c/ Y5 u: E3 M - * edma_test.c4 ?# L: @7 x: Y% d. R z0 \
- *
8 g* ?9 U* \6 e6 K' E+ H4 ~% ]0 k - * brief EDMA3 Test Application) n8 t) e7 u9 X0 ?
- *
. F9 ~/ O. h/ C: C0 j1 a - * This file contains EDMA3 Test code.
4 l- D' ^$ q+ B! \# B9 {1 H - *5 X; h* [6 Q7 n7 E( Q; `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
s; D {/ l, |% W5 a4 V: Z& n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 O: L7 d* ~0 i6 S
- * TO CHANGE.
+ x4 P( P+ n* y' T0 j' _ - *
g% E( i+ [$ E1 s, { - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* R0 Z7 |/ k* p6 r. j- p - *
7 ]" R u# _; D4 F) V - * This program is free software; you can redistribute it and/or
2 x g ~( J% V D4 B7 } - * modify it under the terms of the GNU General Public License as
) X" k% P5 A5 h$ F5 V - * published by the Free Software Foundation version 2.
$ z4 R$ u2 |3 z( Z$ t - *7 E& }3 J; d' P5 _6 w9 D) P _) c
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any& k e5 x% E! c
- * kind, whether express or implied; without even the implied warranty
5 H. g. v3 R0 B/ C: ^ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 C4 _/ c# K& }* R H
- * GNU General Public License for more details.
: S: h# x. k: y5 N& r) w2 t - */9 |# W( V5 p L! b
+ C [9 P* j; L" N7 u- #include <linux/module.h>) V/ y' e. F8 M3 c+ m) }1 M
- #include <linux/init.h>$ J( Q& C: i# t* T+ } W1 w U$ H
- #include <linux/errno.h>% S5 @1 d- }1 W5 M" n( Z
- #include <linux/types.h>
' V! _) W" _1 m- e - #include <linux/interrupt.h>. t! y2 H+ y7 T. ~- ]7 f
- #include <asm/io.h>, R6 G" P& z" C8 E8 g
- #include <linux/moduleparam.h>
8 C8 \) y; A+ q$ k7 Z - #include <linux/sysctl.h>2 I( P) m( Q3 r" `* i% {; Q9 k
- #include <linux/mm.h>
- @- H! ~0 @. |- J @ - #include <linux/dma-mapping.h>! j! H7 s1 L$ v1 P+ ^
- 0 x2 f9 E) m+ G- i: c2 T3 t) ]
- #include <mach/memory.h>
2 I- f R% S3 z0 J% r. \3 Z - #include <mach/hardware.h>$ r6 Q& _% M9 X: X
- #include <mach/irqs.h>7 c- j9 G. O! D
- #include <asm/hardware/edma.h>
$ I7 G0 k+ g/ P
6 H; u( o3 k+ ~( _4 q8 h% d- #undef EDMA3_DEBUG: \+ a. J, B7 E# K2 t
- /*#define EDMA3_DEBUG*/
1 N; \1 D H4 H6 L) p7 z& T
" n7 x4 I; d5 O1 m1 t0 N- #ifdef EDMA3_DEBUG
: ?+ Z. k% L* G4 P( [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 N/ X r; y9 Q4 d5 E8 R
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# J; X) I4 f# P( B4 a% } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 ]( r3 x3 X) n) l8 U9 L6 V
- #else
, X- i, o; p. U! N - #define DMA_PRINTK( x... )
4 }! s1 H1 ?& m7 Y2 h - #define DMA_FN_IN$ ?$ J! _4 C2 U4 X2 I2 P
- #define DMA_FN_OUT7 g" `" Q6 D9 Y. o9 o/ S! r, A
- #endif
2 m$ a& \6 [/ z0 V% x$ ?; l# e4 L( h - ) H, b2 ]) p+ n- K/ ~
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)' k* }- ]1 r M- H- q% s
- #define STATIC_SHIFT 3+ O/ t3 [$ x5 U$ ?% R, V$ }
- #define TCINTEN_SHIFT 20
, X: x, v) `, c0 |1 v5 |. b - #define ITCINTEN_SHIFT 21. b( w5 [( \- j, S) a) A, |
- #define TCCHEN_SHIFT 220 A, ?! r" S" R \' `/ t3 H
- #define ITCCHEN_SHIFT 23
# E5 b4 B# x9 r2 u0 J. P9 N) u - . [9 S& C8 i0 t$ E# q' M4 L9 `
- static volatile int irqraised1 = 0;- M" N/ g6 m0 R6 x
- static volatile int irqraised2 = 0;
9 G6 j7 ~) h: w8 m9 F# [
3 m$ x" z+ u; k9 V& a. @ H* M0 q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' T J# D( @; w1 R
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# }, K/ V% v& G+ B
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* c4 S5 r2 O% R4 n+ |# v
2 S5 M! f) |& R: E- dma_addr_t dmaphyssrc1 = 0;- ~% S, H3 A4 |. w! B: v, M0 m
- dma_addr_t dmaphyssrc2 = 0;
0 k9 I1 Z4 D2 | - dma_addr_t dmaphysdest1 = 0;
+ L0 Q3 ?+ V% [; X! x! | - dma_addr_t dmaphysdest2 = 0;8 |* L7 E9 @. ^: f+ n! V* l
- 2 Z, C' j4 E% D/ E O' Z/ L0 s
- char *dmabufsrc1 = NULL;
: e7 y6 k6 q3 s8 O0 `- X - char *dmabufsrc2 = NULL;
* t) G0 c' N M& o5 Q/ k - char *dmabufdest1 = NULL;2 Y* J+ @( n8 x2 b8 `7 F
- char *dmabufdest2 = NULL;
7 z. a: \6 K1 l* \9 U
J; ^( T% X% }6 u9 l- static int acnt = 512;$ u' V6 U& p; p- d6 t
- static int bcnt = 8;6 G) ^& J" ]1 a$ _7 I
- static int ccnt = 8;- E P4 b% c: ]; h5 ]2 B
! W4 k+ @3 L1 G4 e) s% v; G" x- module_param(acnt, int, S_IRUGO);, s! d5 i/ I+ A* q/ U
- module_param(bcnt, int, S_IRUGO);4 t/ \7 D: j% P* t. K0 r4 f+ A3 X
- module_param(ccnt, int, S_IRUGO);
复制代码 3 Q( L& U7 \4 }, Y) ?
$ ^8 F, _. F1 A) I& w0 [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 K. O6 S( g0 d5 ], y( _6 Rarm-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! M3 ]2 Y. A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
F) }0 Y* m1 k8 ]" t: F- m: h" m- {# d6 Z G4 z8 n% X0 Q
5 F; C" d9 G" [- o- W) V
|
|