|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
X+ d& ^- K3 l" J/ a& p7 I3 f- [code]EDMA sample test application
: X. U0 z3 N# x1 v, g" ~ - /*
0 O8 X: K) n5 e% V( A1 a - * edma_test.c
! ^9 z4 p! m& C - *
% c; u3 D* o8 `! J& c* t! ~" K ? - * brief EDMA3 Test Application; I4 U/ z6 v; O) ?! T3 d
- *
6 f$ d5 O. I' r" b5 O - * This file contains EDMA3 Test code.1 L D) @; |; Z
- *8 x0 _6 G6 \& c, k, G
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE s: z+ P Z7 E" ~- b8 @* q/ z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' o; |3 E0 `; J X" J0 y - * TO CHANGE.
$ G9 P- a; K% f - *7 P) e$ X0 R' D5 [7 `1 M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, q( \% B/ t7 b; c* a - *
/ t( `4 q+ e0 C$ h. A - * This program is free software; you can redistribute it and/or
7 ^ t& E7 H3 [ ]1 D8 | - * modify it under the terms of the GNU General Public License as1 M- e1 Y) I4 D6 d5 |9 p. f" ^
- * published by the Free Software Foundation version 2.
; I- d9 ~: R8 ^* q8 S; ` - *
. P3 \6 g1 ?& H0 E N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ c2 h5 d1 V, _/ c; F - * kind, whether express or implied; without even the implied warranty' m! s5 F5 `; Y6 l4 t* J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' U7 M; A% W; l) B - * GNU General Public License for more details." x5 \4 e( @) V" z8 v9 e
- */
! S% l4 ?. G9 L% o$ f - $ {. P" p" C# m/ H
- #include <linux/module.h>
5 t% x1 @8 T6 c, @+ p! X - #include <linux/init.h>
" U% \1 n8 G3 }8 C2 m/ O - #include <linux/errno.h>& N; a \. m, U6 r2 _) S
- #include <linux/types.h> X% k# ]8 P9 u" d/ c
- #include <linux/interrupt.h>
) E7 \' J$ `8 \2 W7 M( _- o - #include <asm/io.h>' l' v% b' i3 c6 `
- #include <linux/moduleparam.h>
- P$ E2 D& ]6 K2 m8 m+ l5 S- K - #include <linux/sysctl.h>
~0 o+ r+ Z* v( ? - #include <linux/mm.h>' ^: I. _" Q$ a# S8 k& M1 G. p
- #include <linux/dma-mapping.h>9 z9 P$ m4 F: B/ b# C& z
. \4 W# \2 v3 M- #include <mach/memory.h>8 A+ ]' j! O) _% g/ S8 b
- #include <mach/hardware.h>+ B$ I6 M& z/ C4 L" ]9 H
- #include <mach/irqs.h> v; @9 {- [# U
- #include <asm/hardware/edma.h>
7 G6 b4 O% O. h1 j s `% K6 X
& v- t+ A/ I7 Z1 s) H6 _- #undef EDMA3_DEBUG
, P( t6 {# R1 _* q: d5 { - /*#define EDMA3_DEBUG*/
' t d- M% n3 k O - . P, _6 i# T3 t4 R( w) [
- #ifdef EDMA3_DEBUG
X; s$ G( B: T5 @ C0 } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% ^, K! `" u+ v* L, r, h6 w4 j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
b" G" Z* k' ?$ Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' T2 N7 V, f8 V8 O! n. D5 J
- #else
" Z. X& t1 _$ [! X - #define DMA_PRINTK( x... )8 P, v7 c- f) H1 O1 d4 w6 b
- #define DMA_FN_IN1 ^4 A9 m, \* n @0 z/ z* T* `6 }
- #define DMA_FN_OUT
8 M& ?1 q! F6 r0 ^0 P/ \) C - #endif" p9 S* u& e, S+ E+ m
- - @# _; }8 ^- A! c6 D
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; I( p3 N9 e- r9 j9 c: }3 C1 j - #define STATIC_SHIFT 3
" l$ h( t7 E# x+ W1 h+ J/ u - #define TCINTEN_SHIFT 20
& ?" w( y* z# H$ j; E7 k2 ] - #define ITCINTEN_SHIFT 21
3 X, ~. W. }8 P z7 a8 Y0 `0 A/ u - #define TCCHEN_SHIFT 22
2 d, m* z" }- d% A" J! } - #define ITCCHEN_SHIFT 23, t6 Z" Y9 \! `. o2 I a
- " H: H$ L& u& `1 j
- static volatile int irqraised1 = 0;& Y& w) z$ ^$ V1 K. h
- static volatile int irqraised2 = 0;- ]0 q, ?7 d" a" L7 ^8 o
" ]! T8 B1 T3 r4 T+ h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; _$ m7 W0 V" C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ g6 B3 K x: u6 K+ C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' \# ^: }% {/ K5 p: b* g) c
- ; |) z. v; M8 Y& t4 B7 g
- dma_addr_t dmaphyssrc1 = 0;- a/ e# l: N4 N/ N1 {
- dma_addr_t dmaphyssrc2 = 0;8 L Y+ G! u3 b. G4 n
- dma_addr_t dmaphysdest1 = 0;2 L. Y5 `8 O; L$ ~( d) g* p
- dma_addr_t dmaphysdest2 = 0;; ]0 ^5 P$ N, i
- & Y. a) m. i7 t
- char *dmabufsrc1 = NULL;
7 e6 x0 S% z7 V" f, \4 a X4 v - char *dmabufsrc2 = NULL;" r7 u0 M% e3 |, f6 W. l3 N
- char *dmabufdest1 = NULL;* ^) j6 N" {: o9 q. n
- char *dmabufdest2 = NULL;
5 A' g7 D4 x. ]0 ^
- @3 V- H m9 H- static int acnt = 512;8 W% C5 i. ]% H3 B
- static int bcnt = 8;
' W t- \7 V% i9 U& A6 N - static int ccnt = 8;
: _/ t" H2 v6 }6 U( _2 B - 4 }- b* m: r+ d4 @/ V1 k U
- module_param(acnt, int, S_IRUGO);
9 ?/ `! I5 _0 H: P2 R/ z - module_param(bcnt, int, S_IRUGO);
6 Y# h) a7 I3 a! V+ E. m# u - module_param(ccnt, int, S_IRUGO);
复制代码 & G2 M' ]0 h0 ?
$ D8 Z; o' M5 @3 M% c% f 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. F4 ^- e1 ^4 \/ ?( H5 g) B
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" m- ?. d) p$ h2 A' e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% ~' x+ l" c$ H
* G' H) [$ P+ }5 W# o2 k
( A/ M+ D" _" L4 f$ n# f |
|