|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # v$ D. q/ I- p4 m
- [code]EDMA sample test application
: \$ S% w/ i6 ^) t3 c t - /*
, p ~& J- ?- M/ B1 A - * edma_test.c
' [) m( q; T8 c* `2 E+ J5 | - ** C7 b) l/ S5 T- h' k- l
- * brief EDMA3 Test Application
5 ]8 j1 n3 y0 n, Z - *
4 W4 h- A' }9 r5 M$ R, n8 A - * This file contains EDMA3 Test code.& v. x3 t5 Y$ z4 Q+ D4 R
- *: [/ F' u0 ?8 K$ q% ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* g! U1 s, s! D. i. b8 B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 a* Q! }3 o5 B$ N" ~5 y - * TO CHANGE./ U- m+ [+ S. P
- ** f( v2 H- t( c+ B) G- w
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 }- u6 P2 d( H$ R' D, o
- *
0 O# S( x+ {/ G! ~+ V - * This program is free software; you can redistribute it and/or3 x; \! D4 M6 M7 ~
- * modify it under the terms of the GNU General Public License as
$ f# D, N# E& l H# ~- X1 p; p - * published by the Free Software Foundation version 2.# l' w& W8 D' v$ V: U
- *3 y2 ]; n Z$ t( w9 B6 c$ T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 k( ?4 e$ }! ]: `
- * kind, whether express or implied; without even the implied warranty9 O" x& S- J# ~0 w9 n
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
M. {( a$ i& G - * GNU General Public License for more details.
6 _0 p# [6 \" a& L( |2 C. G _ - */
$ j8 v- F$ I' b; F; W$ O
0 n4 D: b8 ?+ Q- #include <linux/module.h>$ R' f" W& e! O! B1 Y2 f
- #include <linux/init.h>8 ?3 F; B, Y3 V, h- [4 c
- #include <linux/errno.h> D5 o" D1 c' P& n* I7 Y
- #include <linux/types.h>3 V, M8 l( v/ k# K4 g
- #include <linux/interrupt.h>
# \; c4 f2 x8 n; j - #include <asm/io.h>% z% q) _% i* Y% I; G4 F6 E" w/ o
- #include <linux/moduleparam.h>
' p) }! W3 h. @1 C/ z - #include <linux/sysctl.h>$ R1 d) f: \6 {1 I `- R
- #include <linux/mm.h>
# d) }$ H9 J l - #include <linux/dma-mapping.h>
$ X/ S: t& R& s - - R+ K1 w3 M2 [- u9 H* r% C% Q
- #include <mach/memory.h>
, a7 Z5 W" r' U" E0 v+ d. {; u! s - #include <mach/hardware.h>
: K, \' A5 l0 U8 G* L - #include <mach/irqs.h>2 N% X6 E/ Y7 S
- #include <asm/hardware/edma.h>
g8 }. F9 S+ R4 `; X9 b - 5 y$ H9 f/ P+ C5 e1 M4 i
- #undef EDMA3_DEBUG- w; C: c# t/ L4 T8 o; V" f
- /*#define EDMA3_DEBUG*/
! Q! X$ v0 l1 g
g' L( U8 t/ e( i) f$ \4 K" x6 Q- #ifdef EDMA3_DEBUG
3 d0 }- }) z7 e. Y$ D0 e1 V; K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* _& b7 X6 e T3 u- ]" o( b: O
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. p" B7 T! Z; z8 ~2 G3 J" K+ Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" q7 C1 X4 M: Z9 e( {9 W) { - #else
5 u4 Z9 z- f3 r5 A: W* q - #define DMA_PRINTK( x... )
' @5 ]* F2 B6 X( T - #define DMA_FN_IN
* t, J! b9 n6 ~ - #define DMA_FN_OUT
2 y+ I, h" M/ o4 q) w$ |1 V - #endif
4 A" Y3 A( a7 D5 L8 m# X# ? - / b* T' K* i H/ G
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" Y! S4 U1 W5 u8 {& v( t" s# r7 A
- #define STATIC_SHIFT 3
7 X8 d9 [0 l! Q& M2 i# o8 \) d - #define TCINTEN_SHIFT 20, e, _% X; O7 t& g/ h$ U; M
- #define ITCINTEN_SHIFT 21; ?2 ?! A5 g9 C G! ?* K
- #define TCCHEN_SHIFT 22$ s& y7 ~/ r0 ^1 P( j7 R
- #define ITCCHEN_SHIFT 23
" } A8 l% d) g; I V- K* ~& I - 2 l7 ]" O6 b+ o2 ~
- static volatile int irqraised1 = 0;
/ i2 d# A( v7 @2 T& Q6 u - static volatile int irqraised2 = 0;
! B7 Y$ \3 C G# U+ ?9 e
, H2 j' z1 @5 n$ n; o- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 ]$ ~( y8 ]) C( I' ?- K' }5 x3 d
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 x3 Z- ]: Y, j% ?: _$ ^7 r8 o
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: ` \* k) M* {
5 Z9 _+ l. R8 w. |+ q, S6 `- dma_addr_t dmaphyssrc1 = 0;
: Q9 z4 s' ~" R+ Q3 q4 i* D. L - dma_addr_t dmaphyssrc2 = 0;
. r# t3 Z: {# y; ? - dma_addr_t dmaphysdest1 = 0;6 S' ?, I4 Z8 U
- dma_addr_t dmaphysdest2 = 0; ?+ K/ M0 s2 t& G0 K5 z3 Q
- $ w) E) H6 }) T# z* g/ b2 j4 K
- char *dmabufsrc1 = NULL;
# @. _0 w8 V+ C2 ] - char *dmabufsrc2 = NULL;
5 m/ ?" D+ E" w - char *dmabufdest1 = NULL;
4 W7 l* \% k! }! _- b - char *dmabufdest2 = NULL;
6 v8 z' K0 m* z6 f4 z: h3 a* o
% X9 n' G" B: k- static int acnt = 512;
5 v1 K, x: U8 k$ r6 ~" N - static int bcnt = 8;
# ?. T1 q- x8 `6 w - static int ccnt = 8;
5 h% N7 @7 x2 f! m* _
% a* v9 f! d- k' ?+ |- module_param(acnt, int, S_IRUGO);
6 B; ] L8 Z3 O6 e, y) K - module_param(bcnt, int, S_IRUGO);
4 h1 c8 `2 F( y: l) H$ T9 _ - module_param(ccnt, int, S_IRUGO);
复制代码 j0 e2 t/ _! C3 X5 C
) v4 W# v( I) M6 d 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用! d6 T0 r, F* z( G
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! z0 j7 Z8 T+ c$ @" j6 Q8 w 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
}1 P# Q/ p$ h9 [6 v! f8 S% \4 A
* T# S) {- i! Q- f+ b5 t) l# k/ U* d
9 @. c1 f2 |5 i3 [8 E |
|