|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) M; Y6 C s! t! ?: E/ i% L
- [code]EDMA sample test application
* |/ |# j; v z% ~ - /*' @) d4 _' H- z
- * edma_test.c! D# ?4 ?4 e* S8 d0 S
- *
7 s, J6 x$ U) f8 T( f; L - * brief EDMA3 Test Application+ S ~0 q3 M: E% m
- *" G& R; i' J' L: i; Y9 \: J& v
- * This file contains EDMA3 Test code.. z0 `+ B! Q* b; Q+ f
- *
8 G" p7 T- r; d8 R7 O& j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: N( S# @8 ?0 k% p3 h9 J
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 p8 X) \$ h! ~; c r
- * TO CHANGE.
- Y2 M5 v8 U, J) z - *4 U; H# w* M) C, [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 ?2 o$ [0 u0 H& X$ v7 | - *. O! |2 V4 W2 d6 O9 o( U: C
- * This program is free software; you can redistribute it and/or
" \4 Q6 j( E4 u; X; `1 r - * modify it under the terms of the GNU General Public License as
! x* `6 ~+ b" H - * published by the Free Software Foundation version 2.
" Q7 }* M7 P+ A+ q) f" y - *
3 h0 M2 ?7 N3 a6 u - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 ]4 g T. s9 _$ d- z4 T! d6 b
- * kind, whether express or implied; without even the implied warranty
) p0 I0 Z j6 x: R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- y' c7 {; k$ a6 R - * GNU General Public License for more details.
' _' V2 O# j j5 Q3 l T' E7 K* | - */' W4 x, n+ L! f7 D% X
4 T, E$ d4 u, w7 y; x: V- #include <linux/module.h>3 `1 K$ l+ o1 q1 B- h
- #include <linux/init.h>( d0 x+ [* B3 \& K
- #include <linux/errno.h>/ \; l# n& E2 c2 N
- #include <linux/types.h>
( r9 q [. n# E2 _) S6 ?9 N9 p - #include <linux/interrupt.h>- O. ^( ~+ ~& y( ]1 p) Q; {0 ?
- #include <asm/io.h>
& \. y: D6 @$ n - #include <linux/moduleparam.h>0 ]( |9 W" X, C) w, [; p
- #include <linux/sysctl.h>
' @4 f4 M0 }7 K0 T. y, p - #include <linux/mm.h>2 _5 ]3 M5 [+ L& n# t
- #include <linux/dma-mapping.h>2 Z2 K& w( Q7 L/ A3 w& B
- 9 V& e7 a! {& h3 n9 A4 Q* N' }" {
- #include <mach/memory.h>
' W0 D9 \2 w' H6 d - #include <mach/hardware.h>, C, d+ g4 L+ @, S
- #include <mach/irqs.h>
8 ]4 }; K" U2 P2 n4 W4 N3 v - #include <asm/hardware/edma.h>
1 m& t6 G1 X' C - : l* S. u; H" x; S- Q
- #undef EDMA3_DEBUG
- P: J; |, j5 @+ _. M% s" s - /*#define EDMA3_DEBUG*/
' I+ m/ z" M. B4 y% m
% K* t/ M- L' s% B1 Q% n- #ifdef EDMA3_DEBUG5 p8 p+ ^8 K# ?$ ~1 x
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- H( q6 q6 H5 @0 `/ L3 _9 J6 O" n4 Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ }6 Q$ z. C k6 S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( C9 \9 ^1 N% U* H6 T3 W/ Z7 x
- #else* e4 }" Z; [" g2 u7 V. L3 t
- #define DMA_PRINTK( x... )
7 ]+ s% N& u# F5 ]0 Z4 S1 t - #define DMA_FN_IN
' D3 A" C6 n! p - #define DMA_FN_OUT0 E% j" m, @2 T- `4 Z) R( ~ P) c
- #endif( ^# u+ ?6 w" K# f
- 1 p" T( d# K# v* X( ?+ i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ g$ {7 \4 U/ P" t
- #define STATIC_SHIFT 3
; Z6 _; Q( j" s1 k - #define TCINTEN_SHIFT 20
' |8 O& V+ L+ y& V& [* O) K9 f - #define ITCINTEN_SHIFT 21
% V( _! g5 R( J" D# j - #define TCCHEN_SHIFT 22' J4 O( I+ `3 G0 a) F/ I& b" e7 ?
- #define ITCCHEN_SHIFT 237 e* B$ r O/ e% ]
9 c S( J" e; H3 [- static volatile int irqraised1 = 0;. m/ i2 K2 A2 R6 e5 S1 A- ~
- static volatile int irqraised2 = 0;* U3 F, D% }* U7 @
6 C4 T6 W) }1 v1 _- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! [8 v! j" o; i1 X' W& o) p& ^' x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" a4 H' S* V. w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
I- L) z) g5 c9 [, a9 _- A
# O# J! M/ i) \1 l+ S' K- dma_addr_t dmaphyssrc1 = 0;
. W! d( h$ s; R - dma_addr_t dmaphyssrc2 = 0;
- O+ H* T, x2 [' f" }3 l2 F - dma_addr_t dmaphysdest1 = 0;
7 N" g; m# Q2 _( Y - dma_addr_t dmaphysdest2 = 0;
& X3 {# \& M: |1 ?9 p) T Z
6 `7 x- ], a- R$ e6 d$ |1 S- char *dmabufsrc1 = NULL;% {. O0 R4 z/ E5 p7 X3 O! \7 t
- char *dmabufsrc2 = NULL;
+ {/ R5 x) O) ^% |7 ?# A - char *dmabufdest1 = NULL;* t6 V7 w6 N; y4 x5 L* M6 \3 }% O
- char *dmabufdest2 = NULL;
! E9 e& I" r2 b6 M0 o, M3 D - : l& u+ W2 _) r8 j/ U4 N
- static int acnt = 512;, K% m# W; s/ ]8 Z" w" K, p
- static int bcnt = 8;9 Z6 Z1 u. _( P @8 x I, J {
- static int ccnt = 8;
2 O# g4 D- @' V; c) R2 f( h0 m
( U& I# g, _3 ^( O- module_param(acnt, int, S_IRUGO);
; c6 P! G. J' M1 N9 ]+ D/ }0 M - module_param(bcnt, int, S_IRUGO);
: J; E" D. b8 y+ ~7 O - module_param(ccnt, int, S_IRUGO);
复制代码
# S3 z9 a0 F m
]: u& M- g |- d4 L }- ]/ }7 t 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" u+ y7 \$ ^) L( u! |. m
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。7 y8 {% ?, H0 s4 x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" Z5 S- a! p0 ~0 K# c
/ r( E g4 `7 v( e' \" R7 z9 U: P# A& Q4 A
|
|