|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 Q+ x& y0 w* m8 D2 J3 L" j- [code]EDMA sample test application
7 Z8 m3 _% _3 E2 h9 } - /*
0 t$ l" c# [6 V u* N - * edma_test.c5 a$ ~' M4 L% y1 V5 t6 N5 ~' K
- *
) F) L% u: K8 Q5 o: ^' j" Z, E - * brief EDMA3 Test Application1 I6 Q3 o+ S8 R' i& k
- *
! J4 J+ i: x" b3 S+ m9 r) R - * This file contains EDMA3 Test code.
7 e! `* Z. J' Q7 U! n; M! F2 u! [- K - *
0 ?' J! v3 u( S% M' j v - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, E5 F. a' _1 u& b
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ o6 [, t5 y" P7 r* l - * TO CHANGE.
6 \ Y1 T8 e& i' ^, E ? - *# [" G2 d5 V0 J* z6 p4 G
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: X" Q# A: K2 _) z' T% B) i - *
[! q9 G1 A0 J( i N1 q - * This program is free software; you can redistribute it and/or, ^/ m2 W7 U' C8 L/ ~# {# C
- * modify it under the terms of the GNU General Public License as+ j, T& E! S, @
- * published by the Free Software Foundation version 2.$ E# A, m2 Z+ }) K( X3 Y; Y: @* r
- *
; D9 V+ t! k/ o1 N) a. c - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) c5 o1 P2 r4 f
- * kind, whether express or implied; without even the implied warranty
& q0 l" a/ a5 g+ \- v ?9 D, K6 ^# s - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ g8 y- c4 d3 V) i$ \1 A9 u4 O( `& P( v - * GNU General Public License for more details.
3 T$ t, A3 x) y - */; `4 e5 l* A1 V2 Q, r
^/ ?3 y. [: {; f" Z- #include <linux/module.h>2 g/ q! s7 I3 {, |
- #include <linux/init.h>
7 D6 y! V! ]2 y# R( L - #include <linux/errno.h>6 r8 Q' Q0 J' w3 o. N5 j# w0 n
- #include <linux/types.h>! Y$ o, w v M: p4 Z
- #include <linux/interrupt.h>
9 U' U2 K8 [+ ]; K& C+ w - #include <asm/io.h>7 ~( Z% J: l& E: P9 h" b
- #include <linux/moduleparam.h>) u K, S8 r( S3 ^
- #include <linux/sysctl.h>
% @" G* j' z* ?3 b. j - #include <linux/mm.h>
+ |+ e1 T* ]9 l' f$ ? - #include <linux/dma-mapping.h>
+ v; D$ G6 y2 h* n - + V5 |* M3 Q- o% E6 g( | N+ j
- #include <mach/memory.h>! k# `8 X+ {7 ^$ u
- #include <mach/hardware.h>/ }5 j, X) a6 ?6 P# ]
- #include <mach/irqs.h>
9 g8 s8 q7 O. V3 B8 t- y4 [+ ^ - #include <asm/hardware/edma.h>
5 j( l M! R8 p d; o2 k% l- l" o - 2 ?2 H7 k& r* ? A% {% g
- #undef EDMA3_DEBUG& o! I! r/ m3 t, G
- /*#define EDMA3_DEBUG*/
- q; h9 A; m$ ~
8 y: n1 }$ p4 g/ W6 Q1 u1 F+ l, e- #ifdef EDMA3_DEBUG
# I* A! o! a9 r7 u' ~; A5 O1 D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# y; Y# k) O' W1 B; i
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* P/ _9 R4 C! W3 L, B - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ `4 l" k' L9 p* f6 G- [
- #else4 x$ _3 T; ~# }2 u. m j
- #define DMA_PRINTK( x... )
, H; l3 F2 |8 ` q - #define DMA_FN_IN
, N6 {4 I, R( B( m0 u+ x - #define DMA_FN_OUT/ A) X2 J, }" O% U+ v. P
- #endif
9 s V/ d3 Z; `! U" p
3 o) z1 o7 P u- `1 g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 h9 K. A& f6 {! A - #define STATIC_SHIFT 3
9 N4 a1 k i; Q1 R |! W4 Q( B - #define TCINTEN_SHIFT 201 S+ O g+ [! t7 M* l
- #define ITCINTEN_SHIFT 218 A H3 ]& p5 X' Q, W# H
- #define TCCHEN_SHIFT 22( Q& P0 M2 a5 C* ~
- #define ITCCHEN_SHIFT 23
( b% I+ S* K" X/ G" a+ e; l! h& ~0 A - , ? {$ C. h* u8 V" a3 \/ k8 N
- static volatile int irqraised1 = 0;
5 F# s- [7 N/ G! u9 n+ d G - static volatile int irqraised2 = 0;
7 i8 m9 U1 _3 ^- ?' ?( U
+ H( p6 C! |9 f; }/ v9 V% d$ p8 O- U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* ^$ ^" ^1 d4 O! n) L# D1 X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' Q2 n/ O( H+ H - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 @, ]: z5 D( u) D
8 D2 A' C2 C$ B+ U7 |- dma_addr_t dmaphyssrc1 = 0;
# G* N0 `# V0 }4 \ ^ - dma_addr_t dmaphyssrc2 = 0;
7 D6 V( i5 O" U+ \. [) W' u/ ` - dma_addr_t dmaphysdest1 = 0;
1 W/ m3 \- [5 ~+ h1 @ - dma_addr_t dmaphysdest2 = 0;
) I8 p3 g& t$ A, G& B" ]
' I' F& ~6 H# u9 Q) t- char *dmabufsrc1 = NULL;" i( Q5 e% l9 T1 ^
- char *dmabufsrc2 = NULL;
, ^9 u: {% L0 K - char *dmabufdest1 = NULL;
6 _, L, G k) E! J - char *dmabufdest2 = NULL;
& Y H! e( N4 Z# R# j1 b+ ?! U
) `3 _+ q% ^4 L! v: l- static int acnt = 512;
' b! H+ z3 a8 r& w$ X - static int bcnt = 8;4 g# Z$ ^8 O$ ~2 ]( q# _4 G# J
- static int ccnt = 8;! O4 G1 _/ ?9 d4 t
- ' ]8 [. B4 D6 q/ x! M3 ]
- module_param(acnt, int, S_IRUGO);
) n& ~2 L; J, g& i - module_param(bcnt, int, S_IRUGO);/ g$ D0 M6 g h* r* H7 c
- module_param(ccnt, int, S_IRUGO);
复制代码
/ D# u# |; M) @- G8 a0 b) v4 V% m$ m& P) H5 ?( z* M( t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 b- m4 b1 g- q6 h2 v; Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 l9 S! \6 R- [' T 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 {: |, A- w) |( ]- p0 K; X) x) `
. Y4 Y3 l1 {$ C( m% p; Q3 e
( O; w+ ~9 ]( I |
|