|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . Z. @% u) [% B% ^( t
- [code]EDMA sample test application
3 U8 e3 N* C" g4 X - /*
! {# W- A7 X) a: C - * edma_test.c; I W+ @* R( C9 i4 u! _" p
- *
! L7 s+ G" T0 L/ @ - * brief EDMA3 Test Application
( w) z2 @% J. K4 H. m - *
2 G- b; E+ R) s6 l - * This file contains EDMA3 Test code.8 r0 O9 S0 t( @3 {& I
- *& Y- x! L9 ~4 ?" I/ r! h A( s
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
d: l$ E7 K3 I0 l8 ~1 D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% `' ~* F* v; g: I9 q: ]+ G - * TO CHANGE.6 i# d8 i( ]5 U9 H5 o
- *3 w1 V! ?/ s" }% f/ E7 o5 B$ j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 e8 O0 ]0 C v2 r. J; d7 K - *- V( H+ q3 j' p8 W; t. p' L2 V
- * This program is free software; you can redistribute it and/or
$ A4 ^( _2 l7 L# f% d* X - * modify it under the terms of the GNU General Public License as5 M' I( a3 ]% u% P N$ [* k
- * published by the Free Software Foundation version 2.
: F; J. ?* I+ w9 c# m, } - *2 b4 u4 u6 Z0 I2 A2 ^- p. a3 t9 G1 P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% q. L1 g- Q* J5 i0 d* Y - * kind, whether express or implied; without even the implied warranty, q: M# h* D1 l7 M6 _2 `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! V+ g) k g! `6 F' j6 T! n - * GNU General Public License for more details.
( }$ V t5 @* R2 R3 R% Q - */
' M! e2 b6 w; l$ ^4 q" J - 4 U0 R [* ]1 G; @( ~6 r4 Y" p( Y
- #include <linux/module.h>
7 C- D6 ~5 e7 P, y/ J1 e - #include <linux/init.h>& w0 p+ i2 i5 P' ?) Z
- #include <linux/errno.h>
) H$ c7 N) R( ], g9 Q" v - #include <linux/types.h>
# n& n" T! J2 D' m6 c. q6 W - #include <linux/interrupt.h>
2 {/ b q$ P# ]6 E& L4 N$ j6 D+ j - #include <asm/io.h>
' Q0 T: [! h; \5 b" R: @6 X: ~ - #include <linux/moduleparam.h>. Z8 v9 ~9 Z" a4 u1 F) f) Q2 F3 ?
- #include <linux/sysctl.h>
6 w' d. X( \" E1 h4 h+ c - #include <linux/mm.h>- j) K |, w9 c) t" [
- #include <linux/dma-mapping.h>
7 D' r7 h& ?: p5 N: c$ u* T
( {. d" [, N% N4 O P( i$ Y: _ |- #include <mach/memory.h>
- h4 c( ^' q9 j8 } - #include <mach/hardware.h> z, R2 N( S. a6 _; z/ K
- #include <mach/irqs.h>1 F! T2 g# l2 [* x
- #include <asm/hardware/edma.h># h# d2 y8 n8 `3 r0 D& L' Z/ z
% K. x3 v& J& o% l) C4 G5 g% r/ z- #undef EDMA3_DEBUG' c" p7 q4 r1 z4 D1 k5 A
- /*#define EDMA3_DEBUG*/0 S3 y2 K6 @9 X& F5 ], Z' ?
- - J" |, j4 A. z- A4 M8 e
- #ifdef EDMA3_DEBUG
! s1 p; m8 i o% `4 T5 U - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( x' k: z6 R7 K1 c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 j3 O; @( w* {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) }7 b+ q1 u7 I3 K9 H. K, n0 k - #else
8 S: R9 P! c; W# E- g4 l# f - #define DMA_PRINTK( x... )
) o1 a9 g) v# r( ^% n0 o, S - #define DMA_FN_IN
! s( @+ ]1 _5 V! h' m - #define DMA_FN_OUT
3 m. S9 M# A" Q& M7 Q% k - #endif' N0 u3 s- Q* \; @6 b( o+ S3 p
- 5 C2 g9 \2 `, ^% W+ x, \
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 j( a! k5 Q; b% Q
- #define STATIC_SHIFT 3% v5 ^3 e* k# c7 C: P0 M
- #define TCINTEN_SHIFT 20: s) [! l C; r0 w
- #define ITCINTEN_SHIFT 21
1 n# I7 B/ |- F# r, v7 H p - #define TCCHEN_SHIFT 220 C2 i3 D$ A% q n9 y2 Z
- #define ITCCHEN_SHIFT 23. V1 k2 X" u" d# @3 x. z6 w
- 1 O( `2 Y8 F' N3 |
- static volatile int irqraised1 = 0;
( ]' w& A O0 F* N" k - static volatile int irqraised2 = 0;/ B! K( y3 i1 U1 b3 i0 I$ i
- ) D9 }- r2 o) k7 p! a. I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- M4 c/ x5 k2 _+ k/ A* W& t( K9 n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 n/ |- k% F9 A* M3 ^9 ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ y+ m- D4 T9 j" a) i: `
/ v2 \1 |4 k* e2 Q9 p$ B' ~" L- dma_addr_t dmaphyssrc1 = 0;
; O1 P8 m2 J/ X [ - dma_addr_t dmaphyssrc2 = 0;
3 L8 O d) [, q/ ^2 g* W9 \ - dma_addr_t dmaphysdest1 = 0;
) S/ T! U( J* d1 n* J, r& l - dma_addr_t dmaphysdest2 = 0;
! `. B9 L8 r- b( X - : h8 Y0 D1 P( I* @: q
- char *dmabufsrc1 = NULL;
o5 l: ?# @5 e6 T1 y& V - char *dmabufsrc2 = NULL;; N h# u- j5 M8 ]% T0 n i0 s+ A
- char *dmabufdest1 = NULL;$ o- g% F2 t* S2 v
- char *dmabufdest2 = NULL;
0 Q. z$ T' g ^9 U. _" _! Z - 2 H. m$ p& A+ ~% Y! s: m
- static int acnt = 512;
6 {& I7 U# n& ?! d - static int bcnt = 8;9 u. R- B7 p- I+ v2 D
- static int ccnt = 8;1 G: Y0 K+ U" n- [& I
* ?6 E J; l5 c0 R- module_param(acnt, int, S_IRUGO);9 S6 M) t# B0 ?+ y4 N
- module_param(bcnt, int, S_IRUGO);
0 Y( A+ m" ]% B- G% O: I7 t' i) ~ - module_param(ccnt, int, S_IRUGO);
复制代码
) E6 V3 C% q5 Q% G# i- w+ z/ B% u& K4 i9 i0 t. N7 L: B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. @5 K( S" Q e2 E8 E8 }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ M9 D" N9 ~' c2 V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
8 I9 G, L% `/ W" R; ^; P; {( t( Y, w6 O5 Q1 r! ]
1 v$ \ m6 Y, V# t |
|