|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " Z$ [. m7 `; i: C# V6 O
- [code]EDMA sample test application
! y. |4 A1 H6 ^/ w9 ]! j! E9 L - /*
' K0 ~) G$ w7 X( c - * edma_test.c, K. t! ?' {3 J/ t. h8 d
- ** C- ]7 O$ ?8 ?- z1 u0 s! C
- * brief EDMA3 Test Application Z* o" y. k4 u, x
- *4 m. T2 W w7 m# x8 X
- * This file contains EDMA3 Test code.: f% h( r- l& a8 `: ~! ]
- *
+ A( P* o6 S. U' _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, I5 |2 ? J5 y9 {
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 C* z5 p/ T8 \8 t" l - * TO CHANGE.0 t# I0 k$ Y3 t! j5 [9 ]
- *
: @' Q: t8 C8 L& T0 b$ V: X: U - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: }7 _6 [& u1 i$ b
- *
' N$ k* m+ ]. O; D, g+ d0 p& {3 F - * This program is free software; you can redistribute it and/or7 m( M3 n# V( w+ K' O
- * modify it under the terms of the GNU General Public License as
6 i. {0 @" x g0 A7 C8 O - * published by the Free Software Foundation version 2. e. }. C& Z- {& \* `7 N: t- [
- *
$ _, _3 }+ ], `: L/ s - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. n& h ]5 O9 g" N9 ]2 n
- * kind, whether express or implied; without even the implied warranty' v# e5 J8 V( M' {; \: g K
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- r0 s) v3 b; q8 [" v/ v; j$ {
- * GNU General Public License for more details.
2 [5 P; d8 [, V/ h - */7 k3 x8 C: l$ R* v8 r
! C: H3 T1 N! q- #include <linux/module.h>& l; b4 p7 N! k$ o. \
- #include <linux/init.h>& h& [. h! O% a" O( W# A6 G: a
- #include <linux/errno.h>( y9 F, }) E$ g5 n; a
- #include <linux/types.h>
. o& u7 S( v/ @" Z& E2 O* S% j2 N3 | - #include <linux/interrupt.h>4 u. n8 S5 M" t9 h* E4 Y
- #include <asm/io.h>
6 O% I8 x4 A6 D B( P$ h3 h - #include <linux/moduleparam.h>
7 s) c3 a/ R* x- Q1 [; q - #include <linux/sysctl.h>
+ I& G* c! s9 M) x6 V' V - #include <linux/mm.h>! S' s& j6 o. i
- #include <linux/dma-mapping.h>, T: S. @. q- \( o
/ I' h" a, z- D$ g% p6 P8 C- #include <mach/memory.h>& C1 m1 x/ E8 ]/ q# J- _) l
- #include <mach/hardware.h>
0 J& W) l% O' H( C8 p8 N+ l - #include <mach/irqs.h>0 o: v( O# y" A- Z8 m6 f
- #include <asm/hardware/edma.h>
. Y/ f. J0 ]2 t+ M
9 K, L# E/ c" s' S. h: A$ R$ I- #undef EDMA3_DEBUG. L* [2 @3 V* z) K
- /*#define EDMA3_DEBUG*/
1 \6 d g' i1 R" a5 r8 c4 S
; z8 `, d/ ~* I8 n; b6 U" c- #ifdef EDMA3_DEBUG
( U3 y7 b% `3 h( H - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' Y3 H* s8 ]) `( {# L& p
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 F* y4 L8 _( V7 R5 A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ V' |( m0 X7 v% [( i7 K; ~
- #else' Y* D, c. }% q+ @) J5 K1 g1 c' j, G
- #define DMA_PRINTK( x... )
. `, d. H5 b* J - #define DMA_FN_IN
' `4 u+ K+ P2 @' u; `+ C - #define DMA_FN_OUT# q5 {, K1 r) V
- #endif3 y1 G! `* H8 V0 v" c6 ^3 J
8 l0 C9 {9 {9 @# V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" X) O9 K# \& D6 e \- K% z
- #define STATIC_SHIFT 3) B/ t |4 J6 e' [, M f
- #define TCINTEN_SHIFT 205 i6 t% z) F9 [
- #define ITCINTEN_SHIFT 21
$ k0 N) \9 M1 b. _) d1 w3 y - #define TCCHEN_SHIFT 22
& J, j/ F" ^9 |! Z1 S - #define ITCCHEN_SHIFT 23
& i2 T: D4 n) Z5 L8 e
, q6 A1 p' ?1 K( V% t- static volatile int irqraised1 = 0;
& J" U0 B7 b8 [6 w - static volatile int irqraised2 = 0;! a! j& l) [5 X2 ]5 A+ r
! g/ d# M2 Y$ C/ M2 T" s; _- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: D3 e& Y: i Z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 V7 t4 V, N. I8 X/ F M& A3 U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 _' b5 C% M. T+ U8 Z$ B
) P" W4 R+ X! q; n7 w) o- dma_addr_t dmaphyssrc1 = 0;5 _/ V- z$ E6 X: d) l
- dma_addr_t dmaphyssrc2 = 0;
# L0 v. |9 a! n/ k: D0 h. @" Y - dma_addr_t dmaphysdest1 = 0;* e: }5 v2 j6 b+ U3 {
- dma_addr_t dmaphysdest2 = 0;7 S+ R: M& U& p1 Z6 e% f
- " y+ N: _) f# r7 _7 S9 Q
- char *dmabufsrc1 = NULL;+ t3 v* l% y, `* \3 h) {& A ~& L2 X( |
- char *dmabufsrc2 = NULL;/ X- Q' G# y& H; p
- char *dmabufdest1 = NULL;/ W5 k$ X" k1 B
- char *dmabufdest2 = NULL;
I" A, I' j6 T8 R - & e# t, { Z6 Q
- static int acnt = 512;! w) ]) h% k( l0 u& m8 x
- static int bcnt = 8;
2 n9 F+ J, C) N n# C, h5 N' }7 }$ q8 _ - static int ccnt = 8;/ [8 J) T, h9 H
! L0 [9 @9 B) \) b% Y- module_param(acnt, int, S_IRUGO);" ]. O; I2 m. c. D8 S" N: Y& C s( K
- module_param(bcnt, int, S_IRUGO);
! `3 W, r, b( o! F7 u2 P/ \/ E - module_param(ccnt, int, S_IRUGO);
复制代码
& L: L8 \! z' U. i
9 F: y) x: c- l 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( r1 Q5 \3 o& P$ ~! B8 varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, X0 B8 _, j3 f: H; v9 Z) q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 v+ F, O/ R$ U, @* \/ D
! ~7 g4 b; T- p/ \. |2 P* A
0 l& H0 j7 m# m" Y
|
|