|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! C3 h- i3 m: e! R1 Q: c. o% E
- [code]EDMA sample test application
& m8 u& x) l% x - /*/ Z- y8 X; d, V$ t
- * edma_test.c
) a3 ~- n& n7 b0 ^ - *( z7 c! I( ^) v, @. b! H
- * brief EDMA3 Test Application f5 s5 L/ ?; Q) }- [
- *
! X8 X6 ^0 |2 Z3 t) T - * This file contains EDMA3 Test code.
1 s" I' g9 t+ E; b6 U% s9 l7 z - *
( ]; K" \& W& {0 Q7 M% Z2 K4 x' A - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 c. G6 g5 ?/ j2 _
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 F) U3 t8 m/ U5 ^2 H; S - * TO CHANGE.5 Q) {; y5 d1 ?) f
- *$ p% K. |9 w& D7 J, Q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 Q8 s- F$ L& T2 c" x% S - *
8 D* b8 D/ @% f X. w# }6 V3 H - * This program is free software; you can redistribute it and/or
, ]" X G! J. y4 e. w; | ` ^# R - * modify it under the terms of the GNU General Public License as
1 c( L- _' m4 e# W - * published by the Free Software Foundation version 2. `) {0 g8 Y7 p8 X _
- *
0 p9 Z9 n* D' w, c4 J0 r+ I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 w P7 N$ k6 a; G' Y0 g
- * kind, whether express or implied; without even the implied warranty
: q! C1 `" q0 g& K; T5 Z: \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ c7 Z, _0 {. U: e8 b( i8 b
- * GNU General Public License for more details.+ ~. u/ Y7 N, V7 l% Z
- */. Z- U& D! \) x7 k, j* H* l
- ; B- K9 p$ I3 U4 W+ t7 l
- #include <linux/module.h>- h7 ^+ T3 d2 I) t3 m! p/ F" a
- #include <linux/init.h>! o, Q4 ^ N6 ?4 b
- #include <linux/errno.h>/ p/ u* H% ~4 I8 e2 G
- #include <linux/types.h>) }9 d% ?, I) ^
- #include <linux/interrupt.h>
) k1 z4 w7 \$ t$ b0 n - #include <asm/io.h>
# K! \6 s2 E. s( K0 t$ p2 M - #include <linux/moduleparam.h>7 R# z- D" S* @6 {4 j6 v
- #include <linux/sysctl.h># n2 v6 S1 u4 o
- #include <linux/mm.h>
( P! b: J# E* ?& l* Z# i+ A* b - #include <linux/dma-mapping.h>
: R9 ?" ?; L& O6 I) G
4 V3 \" t3 J. X' y: R3 L- _- #include <mach/memory.h>' y5 s. A( [' x3 D5 ]
- #include <mach/hardware.h>
$ D, y2 D4 V; ^! T" p& G" i - #include <mach/irqs.h>; U8 l2 P$ C; @1 P+ i4 \
- #include <asm/hardware/edma.h>
* [4 X% Y5 f3 H ?" S5 N
/ q6 d2 _& b& l! a% ?9 F t- #undef EDMA3_DEBUG( }, U( P4 k! Z7 {! _ f
- /*#define EDMA3_DEBUG*/0 z* a9 ?- j* o: h5 v+ ~" V
- 3 h. T5 |9 r+ C
- #ifdef EDMA3_DEBUG
+ k) p. H" x/ D& W4 j% m, N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( _5 \ s8 ]1 M% n- z: Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' `0 u4 X$ \1 `0 O, g" s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& S) V2 u/ s/ G6 d! G
- #else
/ T1 |- s+ |8 J, |+ ^8 s - #define DMA_PRINTK( x... )
: {# F" ~2 B8 s/ i+ v - #define DMA_FN_IN+ u$ b" q2 S6 n* T/ q+ o. A
- #define DMA_FN_OUT! T2 E( a$ i/ [/ v5 o
- #endif
/ H( R6 F2 A* {$ m- d- ~
! \0 {' l. p; z' d5 H; R- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 l2 w$ J& S4 }& ?# e6 [ - #define STATIC_SHIFT 3% ?! o$ s7 B/ `" s; Z
- #define TCINTEN_SHIFT 201 o U( Z* Z+ w+ v* l
- #define ITCINTEN_SHIFT 21
/ t. i& r# d# z$ y - #define TCCHEN_SHIFT 22 B! D8 }+ s8 G/ }
- #define ITCCHEN_SHIFT 23
! F( C$ j' K# k" f' { - + c z$ G* A) V7 L, B0 f
- static volatile int irqraised1 = 0;8 @6 n" ^, `# V' |
- static volatile int irqraised2 = 0;9 a% f4 G+ r3 [2 `+ b
- 2 Y( M2 l# j% E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: J, E- `& t6 N8 R% w# x" [+ t2 ] - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" D T' ?8 e9 z: _" D! q3 L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; F* k" w8 [8 R- O9 J* d/ U2 P
- : I* O; s2 V5 i. S
- dma_addr_t dmaphyssrc1 = 0;! ]6 d& L. m8 k5 ^, [! I* w
- dma_addr_t dmaphyssrc2 = 0;$ A" N3 F4 b8 K
- dma_addr_t dmaphysdest1 = 0;
7 }5 l+ }8 C# I+ { - dma_addr_t dmaphysdest2 = 0;$ ?; Q v; Y; o; P' A' n2 S! u
- - A8 ?7 f; u |8 S3 h8 k/ l: K0 ?& A
- char *dmabufsrc1 = NULL;: Y* ~) [( T7 G2 [/ o: ~5 m
- char *dmabufsrc2 = NULL;
9 @6 n% I) p% B U2 G" W: K; B, I - char *dmabufdest1 = NULL;( {" g+ s' [& |. K; ]2 a* M' `
- char *dmabufdest2 = NULL;
3 h$ \: D0 I1 d$ B5 x6 E# ~7 S: r
5 Z" S" ~* C/ @: X- i- static int acnt = 512;
$ M9 |6 U0 @! ]6 ~! V - static int bcnt = 8;8 o" ?: u. Y5 ^9 x2 L! s
- static int ccnt = 8;5 B! E6 e" u P' M# X
- 5 |" @) X: {/ ]$ }5 i
- module_param(acnt, int, S_IRUGO);( g- L8 L A' c U
- module_param(bcnt, int, S_IRUGO);& j# t( S+ J4 u/ Q3 B# a0 {
- module_param(ccnt, int, S_IRUGO);
复制代码
$ P |/ ^$ A' F" P* m1 O$ s7 L3 [5 P/ ~/ k3 m/ K
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 a3 T- o% i9 Z' |5 a. carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. `3 ? e! @+ c 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 g2 u' E3 T( G [6 N3 Q$ {
" D/ u! K; X; p x9 w U" ~
& d6 u- ~' o; l+ b8 I9 |) @; w
|
|