|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 w5 H1 B+ I) @3 M5 @/ ]- ?+ o- [code]EDMA sample test application
5 n0 J$ G! Y# `% w' M0 z( _. G - /*
# r0 T% u3 P X# c7 D/ y - * edma_test.c; v6 e; n* @: W
- *7 M- q6 y/ |; C- d
- * brief EDMA3 Test Application( L1 r# L+ f( I7 F8 }
- *
' b( ^3 q7 P- i* y" f. Q" A - * This file contains EDMA3 Test code.
3 v4 x- g( M$ z8 b% k- q, ? - *& H* R" ?+ o+ r0 @' H4 _) {
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
^. D+ a! I! E* n. | - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; ~+ b5 f3 n f Y: r: g7 W
- * TO CHANGE.
- W: U6 N0 O0 n% Y' ]# T5 N - *
: u. a" a' Q1 ^5 q! J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 x* _& v; ^8 i
- */ L# I; e+ Z5 v4 k2 _7 F. {
- * This program is free software; you can redistribute it and/or* K+ r5 T+ _' a7 x" B, a4 r/ r
- * modify it under the terms of the GNU General Public License as
& F0 y8 d$ K- Z, E( `# \# n - * published by the Free Software Foundation version 2.
0 z8 A2 F) ^/ Q# { - *
' u9 A" z7 B" E# p7 d9 H0 u8 b - * This program is distributed "as is" WITHOUT ANY WARRANTY of any: M+ ^ |6 [/ H3 t8 f
- * kind, whether express or implied; without even the implied warranty; A4 Y3 o& @5 R2 {* f) l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! h2 o9 D' L2 L6 u$ B3 V+ @/ U/ V
- * GNU General Public License for more details.
0 X7 F# E: U5 Q$ e8 u5 e. }8 I - */, K+ ]! n. u2 T. K
; v2 J, n9 e! d* C0 l. b- #include <linux/module.h># o7 F; h f0 O8 W* n
- #include <linux/init.h>& V) S+ Q6 m4 ]! @% m
- #include <linux/errno.h>4 `& B: {8 g' z$ _9 j0 s: t2 b3 E
- #include <linux/types.h>2 \* i, | U: v5 x
- #include <linux/interrupt.h>
* S7 N) `* c+ t0 C5 e* } - #include <asm/io.h>7 F) U$ n! I* d1 p6 \% S
- #include <linux/moduleparam.h>* @3 i# n3 Z: b- z r! u" ^
- #include <linux/sysctl.h>0 K4 }2 x3 ?! [, f9 b) q
- #include <linux/mm.h>6 W1 p4 t# L) X, L1 w- E
- #include <linux/dma-mapping.h>
. E- E! S9 h1 S0 j) k
% H. a( K* g; h9 k- #include <mach/memory.h>
; ?2 V" U$ L" a8 n - #include <mach/hardware.h>7 f/ M5 u6 K: Y
- #include <mach/irqs.h>
" O% @, ` Q; H! D& I, W - #include <asm/hardware/edma.h>
* g% V7 g) O' v' e - + D: j$ K/ _5 H- y5 q2 [+ u/ r
- #undef EDMA3_DEBUG
2 A# _3 U8 F; }* u5 V+ U/ X - /*#define EDMA3_DEBUG*/
+ H' ~! D, D) g. G2 Y7 s1 ~. ~& l
' s1 |* z8 {! w4 W; R5 h- #ifdef EDMA3_DEBUG" }# b, {% u' b4 _0 k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# j# [5 q' J2 L1 g$ z8 s' x; L
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ T' S* ~3 ?" P, r2 J3 B* y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 j9 Q$ L0 `% v ~
- #else
8 r0 E. r' y$ m h8 t - #define DMA_PRINTK( x... )
+ v& {8 z; C$ t* R# C - #define DMA_FN_IN' P8 c6 ?, h F1 n
- #define DMA_FN_OUT
4 j" n i# C# q0 u3 p - #endif9 g) T1 H1 h. J Q3 M$ g5 Q! u
) b1 _5 y% |, T) t* N( f3 U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 I" u$ [0 [5 f" G( C- K
- #define STATIC_SHIFT 3( i& K+ ~* v: \3 s M/ u* U
- #define TCINTEN_SHIFT 206 n h. G# j$ N: g) R
- #define ITCINTEN_SHIFT 21
7 h; X/ s6 H5 l% ? - #define TCCHEN_SHIFT 22* |+ @4 s5 M7 m; j/ _& J! o' ~
- #define ITCCHEN_SHIFT 23
2 l' [+ G8 \6 c8 J. A T
% ?* _" d, v2 H- W/ m! s- `- static volatile int irqraised1 = 0;
( L- g9 ~9 F) A2 W! t - static volatile int irqraised2 = 0;, S& B: Y2 l/ e% F- i# A
- - b7 c0 w& X; q/ |+ u! A: d/ W
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( L; \3 A& P8 e4 H0 x9 O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: u5 L( _8 g! ^: Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 t/ I2 i0 L8 J0 S
0 |# k. O: z7 M- K# P6 \( C- dma_addr_t dmaphyssrc1 = 0;* _$ B. Z3 W; c; B0 I6 e1 ^
- dma_addr_t dmaphyssrc2 = 0;
* u/ J* X4 x' ` - dma_addr_t dmaphysdest1 = 0;
q; h. @. g. l+ y - dma_addr_t dmaphysdest2 = 0;
+ G, m5 ~7 t& {* w - 8 F4 B0 \/ w) Z$ ]
- char *dmabufsrc1 = NULL;" A0 ]4 H! U. h5 {' N9 m$ O9 M
- char *dmabufsrc2 = NULL;
: z! q3 u* c! Q8 e; `% m [$ i - char *dmabufdest1 = NULL;6 ]& G2 I, c# ^% }$ g$ R
- char *dmabufdest2 = NULL;8 `1 e: I0 i4 E
- ; Y( n, m/ X8 `- a- h" J
- static int acnt = 512;: _; A0 H9 f* J) w9 r6 ?8 l, F
- static int bcnt = 8;
8 j. ?- p% @2 u) P) T# { - static int ccnt = 8;
7 Y! T* [0 C4 u$ G( Z# G- [* q/ V
! z7 ^7 D2 i' |# k G$ e. l0 h- module_param(acnt, int, S_IRUGO);
U% o$ L W+ g8 Z7 Z - module_param(bcnt, int, S_IRUGO);; O, R! v& B" u+ w2 T% `4 c; P( V
- module_param(ccnt, int, S_IRUGO);
复制代码 ' X- p% ]) G8 V
6 ?9 L. w" w: R* Q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ w& Y! l' ]) n- z' m/ E
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; r$ f; h: k' a* G& _8 L
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 D) z% d( N+ q% O- O% M, H' i& w4 u& ~$ @
, M$ z) j. T+ {5 M
|
|