|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - u# E3 D5 c1 S2 c' q
- [code]EDMA sample test application
% l0 F; l! L9 ]% R! I, Z; y - /*" n1 W# ]/ N4 W0 Q! S% E& C" ]( s2 O
- * edma_test.c1 I6 ^ a5 S7 K
- *
. ?" ~% Q# z0 J1 \2 U: n8 ]( v7 h9 P2 [ - * brief EDMA3 Test Application3 Q" M: P( b( T1 f N
- *0 }0 a/ T4 Z! s$ T# H' b% p* ~! V) k
- * This file contains EDMA3 Test code.6 X' K1 O! Z/ }- r) h
- *
9 g& s# f4 t! O# u, I4 ^! R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 r& G1 S$ W6 l9 q3 A' E - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 b" _8 C( |" M9 J
- * TO CHANGE.
( u0 B/ Y6 X0 } - *
1 L9 q9 I0 n/ O# z! U' m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& a4 |! v# W( i - *6 {% j+ M- f" |+ V
- * This program is free software; you can redistribute it and/or
' e- \) X1 H/ Y8 K8 v' ] - * modify it under the terms of the GNU General Public License as
% u/ ]* K7 c* i" G$ y - * published by the Free Software Foundation version 2.
8 j% C9 u- }4 [; u7 a$ _ - * _# v' _8 p' {8 {/ \+ F
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ @: W/ t6 `: O' |. Y4 _ - * kind, whether express or implied; without even the implied warranty4 {, [/ Y k& i+ l/ T1 C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the; g) J- d* c+ p6 n, e8 c* l# q
- * GNU General Public License for more details.6 \% T. `. G! e2 w, ^& L% H
- */
! ~ r" L1 [/ V( y4 |4 Y: I$ L - Q4 [% Y8 C ?: M, I1 h
- #include <linux/module.h>9 C, I1 q j7 f) b! s" v1 Z: N
- #include <linux/init.h>& @8 ?# O& @4 u1 a& z/ g" U
- #include <linux/errno.h>, l h( X9 n, |0 [
- #include <linux/types.h>
! _! i! ~7 v0 a1 Z8 e - #include <linux/interrupt.h>
9 k z, y0 |, X1 S4 J - #include <asm/io.h>7 `4 H. o' e, d" y' r7 u
- #include <linux/moduleparam.h>4 N: q$ w1 T' R
- #include <linux/sysctl.h>5 e' x: L: I! M5 \% n# G5 G
- #include <linux/mm.h>
( |& r) U6 `8 F8 A - #include <linux/dma-mapping.h>
4 i0 s& }) h, f% m* @ - 3 g) [. j# g& F& \* k
- #include <mach/memory.h>5 E- p" b, `! K! {' m
- #include <mach/hardware.h>
( H- ?' B0 a q y% u7 c( f. e - #include <mach/irqs.h>: K2 V3 m5 G" P: b: z
- #include <asm/hardware/edma.h> ^6 p$ E0 ^8 e4 B) a" H' e
g7 t" y8 X" E7 @5 X- #undef EDMA3_DEBUG, s4 z3 J8 o' r1 T `1 \
- /*#define EDMA3_DEBUG*/
! v& ^. L" ^% q) x
/ p9 j2 s) @# o$ j& @- #ifdef EDMA3_DEBUG( B! x( Q7 p d0 ?: V% ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% B4 ^- s: t `
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 K$ K+ r3 q: P3 b8 v- X3 D
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) J7 S# J, c( M: M. u
- #else4 f" @. i& J2 Z9 t# B9 I
- #define DMA_PRINTK( x... )- g4 }* t- L2 b; l
- #define DMA_FN_IN
) P W, }4 Y8 C - #define DMA_FN_OUT& k# i4 n) S9 p7 a; u
- #endif _- Y( p, l- u8 F% A
- ( j Q {* D1 S# A1 }; o, s- L
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; j/ `/ X( u4 x1 O& v9 f - #define STATIC_SHIFT 3
- S- m( R( B u/ h6 W: _8 v - #define TCINTEN_SHIFT 20
2 v& O) p4 ?$ w5 D: ?, X/ m/ w - #define ITCINTEN_SHIFT 21
9 t7 M7 q: \2 C4 U - #define TCCHEN_SHIFT 22( E8 B* B# K( B8 _
- #define ITCCHEN_SHIFT 23
. L: p) J& q5 \$ r4 S! R. d
@4 {8 W* ]2 E6 ^- static volatile int irqraised1 = 0;- D( V* @. t8 `' `% P8 N. ^
- static volatile int irqraised2 = 0;
4 ^) g- z* t5 `8 e- J" V
+ K8 k$ Z) K2 g; X9 ]8 I- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' f2 L4 n. P, p' ?+ w, b/ J1 Q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! r* ^& y( e, | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 A* x# h- Q$ q/ _
7 y7 |9 V6 S9 T1 j% {1 x. _- dma_addr_t dmaphyssrc1 = 0;3 W. v- B: e$ t1 Y, m! t
- dma_addr_t dmaphyssrc2 = 0;
) k& d3 S+ r/ B4 C) J+ k% l - dma_addr_t dmaphysdest1 = 0;
H+ I- _3 r$ W1 k! R3 F# @ - dma_addr_t dmaphysdest2 = 0;
7 Z& E/ G4 g# N
5 {# P1 s3 h/ x- E q6 P H9 l- char *dmabufsrc1 = NULL;( q m/ h( Q. `3 l2 ]. o; R, b
- char *dmabufsrc2 = NULL;
) ?# j0 _# c* J& q z% P/ L - char *dmabufdest1 = NULL;
' g5 u0 Q1 W$ d0 o1 d1 h - char *dmabufdest2 = NULL;4 a0 g! U6 w. ~# Z
- " T# Y; \" ]( |
- static int acnt = 512; H' a! ]- Q8 [( M1 w. d g1 ^
- static int bcnt = 8;) E8 E4 `% @0 P6 ^' c) Z
- static int ccnt = 8;
9 D. v2 b* v- {8 f6 | - / e$ U0 J% O) i& y
- module_param(acnt, int, S_IRUGO);
' @$ @* L2 k' z5 R+ L - module_param(bcnt, int, S_IRUGO);4 d2 d+ W* B5 I) S
- module_param(ccnt, int, S_IRUGO);
复制代码 # S- @+ G1 v9 w, C
% V# E$ `' Z( U, I& q" d 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' Q5 d' [/ F. X, Earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, S6 p2 R! u1 f3 ` 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. y' s F( r& r. u3 o6 R0 E0 t
% r& p; F; ~/ T6 i7 [
" \' P6 q2 k: S5 g0 Z; a% M |
|