|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
q7 e M2 \+ M( t) b- [code]EDMA sample test application
* R9 |, N) o3 V; r$ e" N; @ - /*' ?+ w: `4 m \
- * edma_test.c& ~; B+ P/ v$ U/ I1 ]% G) ?% x6 ^
- *; c5 L/ ]- s' q& j) L1 G+ l
- * brief EDMA3 Test Application
% N+ P; ^) [( @7 E! b0 U - *
% ?+ O' ?$ f. t x7 W7 K - * This file contains EDMA3 Test code., L, j, o! P/ s/ t1 C
- *- l) W) Z, w# P0 E' |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' J* V1 M' i: i1 O! _: Z( P - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% ]: U* R @3 B f5 g9 a( T5 K) ^
- * TO CHANGE.
~$ y" k% l2 ]# | - *1 j6 {, B+ d$ X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ \8 H& Z6 M0 ~
- *# \4 K( m7 h9 e Y+ w9 z! w
- * This program is free software; you can redistribute it and/or
Z3 Y K( D0 k& d o8 u& c - * modify it under the terms of the GNU General Public License as- n) ^7 O4 L0 v! `# I
- * published by the Free Software Foundation version 2.8 F! `" g& ]( Q3 i( ^: o3 N5 `5 U
- *
4 R a, F2 h$ L9 [4 X! b) ^- `+ Q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 G2 [+ h1 R0 i+ i - * kind, whether express or implied; without even the implied warranty0 I3 c+ U' ]- A" {7 |
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* \: H9 l4 [* c( O& ~5 W( [4 M# _
- * GNU General Public License for more details.: w; ]6 t0 K5 n; j5 k
- */; D9 @7 d! [6 m5 L- M
. ]7 V* g0 x2 ~! h- #include <linux/module.h>
9 ^2 T7 K! F8 F) y - #include <linux/init.h>
0 x8 H2 O+ M9 T; P. e - #include <linux/errno.h>
: e% y6 N- c2 f0 W - #include <linux/types.h>( P; c& b$ f7 h
- #include <linux/interrupt.h>: A% W2 l4 b8 M/ U& v4 V
- #include <asm/io.h>
# L3 f/ }5 ?9 D - #include <linux/moduleparam.h>& Q1 u. \- b2 \: j/ G8 j
- #include <linux/sysctl.h>
$ T4 |; x9 B0 u. U: B" t - #include <linux/mm.h>/ L; O2 F$ d) ^: v8 G
- #include <linux/dma-mapping.h>. M7 J' S5 s0 i+ u$ |
- , T* O( F! ^; p _$ C0 ]
- #include <mach/memory.h>) p: M5 U- L7 \% e2 ~( s# q. F
- #include <mach/hardware.h>; h8 Q, t* Q' |; a
- #include <mach/irqs.h>3 |/ o+ z9 L" |4 y
- #include <asm/hardware/edma.h>" h3 h" ? M8 a
- ! u% [) z0 S" Z6 ?
- #undef EDMA3_DEBUG
* |! F+ [/ K5 z+ Z1 L - /*#define EDMA3_DEBUG*/
( U& }8 {+ m) K! B - + G8 l9 I( q9 s7 P$ I/ x8 ^
- #ifdef EDMA3_DEBUG9 {' }7 ?5 D/ _2 l I" x
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)9 J) ~& V( ^7 {, E% n
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. b* X+ V0 ]+ F0 s5 q, E& [ | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 [$ ]/ H4 t! C. w5 L
- #else a3 m0 O% ^5 w8 F* b5 b
- #define DMA_PRINTK( x... )0 O4 ?: C# e9 Y) V8 P2 P% X& a. R
- #define DMA_FN_IN
8 h7 P/ q+ g6 Z! _( _* N. @+ J - #define DMA_FN_OUT/ R8 B, [, H! J5 r) z7 M9 T
- #endif" t. u) M$ n" n& P' g
& ]7 K2 Z: {1 v/ ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ Q4 u% A* e* P. X0 v( C5 q5 P
- #define STATIC_SHIFT 3! G% {; |2 [) m
- #define TCINTEN_SHIFT 20/ ^. c/ U6 V4 ?* D5 V# K
- #define ITCINTEN_SHIFT 21& E. f1 E$ ^! N& C6 w2 e4 o: {5 O
- #define TCCHEN_SHIFT 22* c; ^9 p; G1 B ]0 a
- #define ITCCHEN_SHIFT 23
5 M [. R3 G* N. Q - 3 ~! X0 I: V& R; Z
- static volatile int irqraised1 = 0;6 F1 U9 }; g" C A
- static volatile int irqraised2 = 0;% f& O8 ?# V4 Y2 r
& S L$ ^+ u- g7 ^- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% [( d& C4 }/ x0 b8 R
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, k" k8 S9 N/ S$ i F+ q" d+ V, K
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. n% K {: f( W! ], H7 H - ; Q( F: A! m- o0 \5 K
- dma_addr_t dmaphyssrc1 = 0;$ Y! E/ G3 O& Q9 Z- `4 r% ?
- dma_addr_t dmaphyssrc2 = 0;
" ^6 m+ g/ G+ C& p( z* h - dma_addr_t dmaphysdest1 = 0;
0 J' O1 S1 D. G6 L9 \2 w* f5 h/ _ - dma_addr_t dmaphysdest2 = 0;
9 \9 v4 P |2 k0 h - 0 D2 x. b# q# ~/ Y1 f! f
- char *dmabufsrc1 = NULL;
8 ], T8 S d' V5 P - char *dmabufsrc2 = NULL;) ]9 x4 y- A2 r- Y9 z3 k: U; h3 @7 N
- char *dmabufdest1 = NULL;9 c. h# {2 O7 R0 r. q
- char *dmabufdest2 = NULL;% g _& j0 B( Q9 t" D5 M' B
! l7 |; r& u0 S/ Q- static int acnt = 512;; g; b! l x/ N
- static int bcnt = 8;
G8 O2 w7 F! D; m - static int ccnt = 8;
2 R) X5 T3 [- z5 t# @
k _* W. a! ^( S+ ~- module_param(acnt, int, S_IRUGO);
6 S# f' `' ]& E. c' o6 M0 A, f - module_param(bcnt, int, S_IRUGO);$ `- b m5 O; j+ ]+ i6 @' D
- module_param(ccnt, int, S_IRUGO);
复制代码
% H$ v' L5 v8 A5 ^/ `- U6 B% r( i- K8 ] ]6 o* z' c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 U& n/ `4 c7 `- V1 C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" E7 }# {8 r. p. N# F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。$ J' Y; [& _( W" l! l6 B
( X9 y1 R( f2 R0 U9 d \) l- _
2 i) L6 Z- Z3 Q- P7 u$ C" e |
|