|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : k1 a8 | Q" a7 U* l, m
- [code]EDMA sample test application
% z+ }7 B- s" m( u - /*' [1 r) r2 U% B- S7 m9 ?6 W
- * edma_test.c4 @& Q$ y1 O7 n* z" J
- *
/ ]1 T+ R0 i/ J2 J# } - * brief EDMA3 Test Application4 k: G- ~5 o+ d: \
- *
$ t% A# w; A" l2 ~8 ]3 }6 g - * This file contains EDMA3 Test code.4 g4 m5 Q' O0 W* d v' q0 _/ t: f' T
- *6 a2 \. I% _/ e) F
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 a9 j& o' E& X% ?. z0 |2 z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% d5 J4 C9 G$ U - * TO CHANGE. p, k$ L5 i# X: Y+ e" Y
- *
; [2 |- V( h# \! N$ S - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 Z9 }, L. H' o4 E7 d( p; U - *
4 q2 z3 \& w+ ~ - * This program is free software; you can redistribute it and/or
/ v, g% Z8 b0 l% `$ F6 e - * modify it under the terms of the GNU General Public License as
1 I& Q% ~7 i, w. K! r - * published by the Free Software Foundation version 2.7 g: o) w9 z( A" k2 e, c% ?
- *# E' f5 z( T$ S g7 m9 X! ~7 Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ G7 s3 T) u3 I1 N$ c5 L% v( M0 {6 g
- * kind, whether express or implied; without even the implied warranty
# y+ u: e7 X, O. |" K$ g9 L - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* J8 H! g$ x7 N$ Z - * GNU General Public License for more details.# H+ H9 b3 H" }) v1 f4 _
- */
% A$ |6 C* ^; ?" b* n+ \ - 8 R9 @4 b8 S. W
- #include <linux/module.h>
; j: I0 s0 l# `: Y - #include <linux/init.h>0 ~- e* l) d/ m2 p: w
- #include <linux/errno.h>; O, v4 W( p1 Z
- #include <linux/types.h>
/ H* \+ y8 i5 `3 u$ o) @5 V! O - #include <linux/interrupt.h>
: Y+ N8 k( _: i' G1 C - #include <asm/io.h>( l2 t' i# E- D" r& n: C
- #include <linux/moduleparam.h>
7 ^' p0 C1 |0 w% J7 [6 w+ F - #include <linux/sysctl.h>
- x9 F: C4 D, I( q6 j - #include <linux/mm.h>+ K7 O( k! K4 J2 @" a: R
- #include <linux/dma-mapping.h>
I- k9 n9 c4 r# ?9 r3 D5 [5 K+ C - 8 Y, I" }, n# B8 ]
- #include <mach/memory.h>
7 m- n" Q, `" D - #include <mach/hardware.h>5 [4 U8 u* ^+ ]8 a A5 M
- #include <mach/irqs.h>
8 Y) P0 ^; X- ?& }& w6 y - #include <asm/hardware/edma.h>1 |) r5 v# m% \- I2 Y N! b
- 4 G7 n5 f3 M7 Z4 O7 o# r
- #undef EDMA3_DEBUG4 Q# w& _# P, ^/ }. q( t- i
- /*#define EDMA3_DEBUG*/
6 P3 } D( f. g
. [/ r/ k8 [, [( X! g- w: X S6 ?# o- #ifdef EDMA3_DEBUG
2 f- z! h% i" b4 T' \ m - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! d. m$ Z9 x: N; O7 r* C) v6 ^! y) K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ Z1 A# h4 M% N L0 c6 q, ~
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- C( B0 q4 |6 p: `, e - #else9 R: T6 B+ M% O9 |1 r# c
- #define DMA_PRINTK( x... )
! m) p) h2 ^, Z3 U+ g - #define DMA_FN_IN9 ^, e* Q; k! J3 k N
- #define DMA_FN_OUT& g0 Z: R- W: b. O6 H, w% a
- #endif, D( [$ F. K7 c! Q2 P
$ X# v* u8 E* s' P% @ c& D! v0 ?5 d; u- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" M T8 U+ z. s/ p
- #define STATIC_SHIFT 3
# G; n$ w5 [/ L; _. `7 Z - #define TCINTEN_SHIFT 20
% q1 N6 h+ J w a- _1 b - #define ITCINTEN_SHIFT 21
4 L- {7 }7 n/ U" r. A - #define TCCHEN_SHIFT 22
- V" q0 h0 T7 n6 o9 i, ~3 h5 r - #define ITCCHEN_SHIFT 237 R* Y* Y* |: P# w
- " K3 S: G# w9 N; { r
- static volatile int irqraised1 = 0;
3 w3 {" e) N( n) F - static volatile int irqraised2 = 0;
- |# r- J0 E4 M1 s - 8 M7 m$ \! p4 w% v# ]- M0 D; H* f& f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 L' z+ q: |, \7 r1 G - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ M) k' f5 G$ e+ {6 b* F2 Y2 m
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; w0 q9 h8 }3 N
1 t" Q+ g. p9 c- dma_addr_t dmaphyssrc1 = 0;. l3 ?" E: N6 y5 T
- dma_addr_t dmaphyssrc2 = 0;
' Q; {( b: j2 i; C6 ?: K7 k - dma_addr_t dmaphysdest1 = 0;
8 {6 ] t+ U! @2 `0 d2 ~( S - dma_addr_t dmaphysdest2 = 0;0 e! ]9 P$ n; r4 }- `
- 3 z: ^ a: i. l v, ?
- char *dmabufsrc1 = NULL;
+ i8 _% z: s! f7 \ - char *dmabufsrc2 = NULL;% W7 {" P2 ?; a- n& w$ b
- char *dmabufdest1 = NULL;
$ o# i8 I) D: D; g) r - char *dmabufdest2 = NULL; Z3 g. y) R, I( m6 S3 h
! V6 G6 `/ x- g- p- static int acnt = 512;
, w) ^/ r" q( r - static int bcnt = 8;) C% _7 I3 }% |3 w/ V1 r9 t
- static int ccnt = 8;
$ H) _0 Z& I- P% p% e
6 m" Z8 z! {& H- module_param(acnt, int, S_IRUGO);
$ S/ c, b/ v# v9 h- S( A$ d - module_param(bcnt, int, S_IRUGO);# a; ~* K Q$ l# P* x
- module_param(ccnt, int, S_IRUGO);
复制代码
@9 O8 G( X5 U# l" v: y4 B
8 x( X. t" Y5 J& E' c0 q. e( n: @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
* H- N$ F; M- o4 Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 R7 `$ |: P. I
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" v, `& B: q. M1 F% K
0 _9 ~+ @9 X5 v9 r4 V- j
' v; q, d# b7 L* S5 b; P
|
|