|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 v" x/ r, ~/ ?+ }: _6 q- l
- [code]EDMA sample test application
. z& e; P( c: n! G' D3 n& J - /*
. ]0 e! W. K2 T( l- S5 ~, m- H0 ` - * edma_test.c
4 o ^. L1 [' i& m6 }' ~ - *
5 U, P1 s1 L! [ - * brief EDMA3 Test Application
. x8 v+ A2 F6 ] - *' r" O& A/ r: q; ~# a
- * This file contains EDMA3 Test code.: C- Z; a7 v6 @1 k; p( z
- *9 _- l9 w ]) T5 ]/ ^ }. Q5 M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( w" [+ @% W$ r# N, g. j8 }' I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ Y# l* A$ I* Y: ?8 R* s
- * TO CHANGE.8 J( r: @9 l: |
- *
+ k/ p/ X8 D% _- [" E" E: v9 ^" n - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
! T: X: @( s2 { t - *4 A9 ]' m5 L7 M) j. E) c& e1 P
- * This program is free software; you can redistribute it and/or
# Z2 Q6 e3 a$ Q' ?; e* @ - * modify it under the terms of the GNU General Public License as2 u' ^' j. ?1 U; f6 H) {7 m' C
- * published by the Free Software Foundation version 2.- D3 b' u8 z; C1 d+ [# D
- *4 o$ J7 W; v& S; y) W6 K* P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 p- T o( U; }: P4 X' E4 L
- * kind, whether express or implied; without even the implied warranty0 [: |% E& }, Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( V0 |- V$ ~% }' A& r - * GNU General Public License for more details.4 Z9 |% R" {. Y7 c9 g( i
- */
: S' } S2 E$ F! p: l3 X9 ] - 5 m0 d; k0 |1 z8 R- {; l- S
- #include <linux/module.h>* f% W7 \ Q8 j4 Q$ Y, E) b: A; S
- #include <linux/init.h>
7 H7 e I8 r; p$ W% J* I/ y7 l) M' v8 ~ - #include <linux/errno.h>
2 e% f. F) J, E! [6 X6 [5 Y - #include <linux/types.h>
# X+ V& Y3 u* i, F - #include <linux/interrupt.h>- F8 O' z1 c! G: }0 v) Y
- #include <asm/io.h>
1 q8 g- Y, ?1 T1 }, H4 z - #include <linux/moduleparam.h>
% z! O+ s$ V% R1 g" V( G - #include <linux/sysctl.h>
+ x0 ?0 {5 f4 { - #include <linux/mm.h>
' u5 t/ I4 v+ s4 ]! p - #include <linux/dma-mapping.h>5 k/ o0 X1 H. H8 Q5 C& d8 _3 k! {7 U) `
- & H3 M' l$ s$ ]1 i( O& H4 d/ j
- #include <mach/memory.h>
% a6 H: x( M6 x6 S - #include <mach/hardware.h>7 O. U1 K9 X' F) r
- #include <mach/irqs.h>" h1 p) O+ X& N( B) z
- #include <asm/hardware/edma.h>8 B; o4 p& p# P) ]4 x& t( P9 ?5 p
$ l. v" P. Y# k+ n, J7 ?9 n- #undef EDMA3_DEBUG
: ]! `9 }" @! g* [ - /*#define EDMA3_DEBUG*/
9 s( ^. A4 ]- |% K! k
' G4 t M$ F4 c: P- #ifdef EDMA3_DEBUG
/ e2 `* V0 b1 I5 T% ?+ _; x9 X - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ F! \* C" z; {6 B0 ^. } n- a# X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) c: ~ n5 o, C$ K
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% V0 Y0 H) Q' M: t$ k5 Q - #else
- n s1 Z9 G1 | - #define DMA_PRINTK( x... )
' g+ z6 Y/ t; X% z - #define DMA_FN_IN! f6 W' ?( b0 @2 v! X1 P6 W, n
- #define DMA_FN_OUT5 h. H1 _# q, u0 n8 v5 I( A- K
- #endif
) \$ I+ Z! f: Z6 v" O; t" _! S# J - 4 U4 y# r+ d9 `/ y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- w' z) P( W% [' w - #define STATIC_SHIFT 3
, ~: J0 q+ w; U$ S - #define TCINTEN_SHIFT 20" d- N( V# r T7 ]: I* `7 B
- #define ITCINTEN_SHIFT 211 g% `0 c7 T0 S5 X' u3 X
- #define TCCHEN_SHIFT 22
( U a$ { I8 S* S6 i - #define ITCCHEN_SHIFT 23
# G. ?/ ^6 k# e/ E
6 Y1 f8 `4 `6 p+ z& |6 o! d- static volatile int irqraised1 = 0;
+ y4 {0 l( {" h6 ]6 ` - static volatile int irqraised2 = 0;6 P9 H) H+ k5 |- r5 z
- 3 e' J5 O# G9 I/ _* _
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 t" X+ Q( E5 T0 _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 f9 S/ M- G$ z1 @ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 v/ d& M- H4 b
- / ]* {$ |4 |# J/ ~9 T' t
- dma_addr_t dmaphyssrc1 = 0;6 n/ [' e0 i2 z
- dma_addr_t dmaphyssrc2 = 0;
' P# ~% h6 [7 F* K1 P4 `5 D& P - dma_addr_t dmaphysdest1 = 0;' c. J% Z: N* ~
- dma_addr_t dmaphysdest2 = 0;
/ f9 N$ g- I4 y& g3 h9 r
1 d/ A2 w, W" Y5 |$ H5 O, G- char *dmabufsrc1 = NULL;
' N$ j a0 Q5 L+ U0 E! g! e5 Q8 v - char *dmabufsrc2 = NULL;& u5 `( v0 I* w t, {! ?: w' {
- char *dmabufdest1 = NULL;/ |2 ?" Y- H1 d6 p! D
- char *dmabufdest2 = NULL;
" q2 I- c ]9 |% _ - / U4 `. A1 m/ n% }
- static int acnt = 512;
- M! p( |& _5 ?+ y' w - static int bcnt = 8;
5 r% x% U! X | f( e - static int ccnt = 8;
& m! z8 S: ^- G2 j* k: l0 b7 g
" T" k H8 B3 C9 S7 A: d- module_param(acnt, int, S_IRUGO);
3 E/ K4 a( v: `4 M8 G3 v% m - module_param(bcnt, int, S_IRUGO);0 u/ P# ~& q, i& K& o/ g# ^! `% o
- module_param(ccnt, int, S_IRUGO);
复制代码
1 A+ e8 L8 n1 d6 j+ }& Z0 Y! L1 i8 _+ B3 T. S+ P, d3 R0 _1 t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. b5 W, U6 N4 i- G: s6 U4 X' R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' [2 f. n5 H \1 T4 k: U7 B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, }, ], Q# @; c
7 t8 g" }& K5 k1 x! x2 z. |/ f2 N
1 D3 ~; \3 V% I G8 R; P5 Z |
|