|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! |* m2 t3 s! M. x; A- [code]EDMA sample test application
1 f3 T$ i# }; L& ?7 ~: L4 q - /*8 h+ F; t9 ^0 m3 J# s
- * edma_test.c/ g& J W2 n! |7 a2 e; j/ P
- *
- z* q: C4 |9 d - * brief EDMA3 Test Application
$ o0 |, d+ F5 i! f3 d; j; l) q. h - *
, B) S k c, r* b% [- j - * This file contains EDMA3 Test code.2 ^1 V- x; c0 ?- h% `& x' u
- *9 Z, `/ s* B* z" _+ p. ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- j2 n( w x+ z8 W2 W' u - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 B+ x8 O$ O2 J - * TO CHANGE.
9 M7 i( |: l6 a8 C; ^0 c: i& j - *$ m2 u! n$ V, O7 n1 u7 U/ p' D% h
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 t) Q. X5 {0 }: l O
- *9 ~' \! R; R0 L; s/ \
- * This program is free software; you can redistribute it and/or' K( W4 ` @: L* F. P
- * modify it under the terms of the GNU General Public License as3 @- t# U. ?7 F9 Z& E0 x; e
- * published by the Free Software Foundation version 2.8 J/ I/ N" l4 B
- *2 v! F, s: x ^
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 b& G6 Q+ E; U; X3 B# F
- * kind, whether express or implied; without even the implied warranty) ]0 |- s2 s, P! u; U0 H
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- Z/ o/ j+ A( d4 q/ l
- * GNU General Public License for more details.3 V8 f, f( w& \3 r$ [4 l
- */" g0 D, U& y- M# C" ?
- ( U G8 V# o# h& o" t1 C
- #include <linux/module.h>$ v8 _" E* J# E: d% F
- #include <linux/init.h>
& O; P" J0 S2 L$ ?" E* t/ q - #include <linux/errno.h>
- h' q4 b) |* m; H' S$ o% T! _6 c3 f - #include <linux/types.h>
( h7 j# _; G- k+ u4 s - #include <linux/interrupt.h>. h6 b& o; w+ q. x7 _5 x
- #include <asm/io.h>% o+ M! _- `1 N; w0 q! M% }
- #include <linux/moduleparam.h>
}7 A- f" _+ C# y - #include <linux/sysctl.h>
0 p- M; r( Z$ A, g - #include <linux/mm.h>' M- H' M! T* x* M- T2 F9 `
- #include <linux/dma-mapping.h>
7 \$ U P4 {" F! t
$ s* z1 [9 t: Q2 ~0 R8 ~2 @) H- #include <mach/memory.h>3 w! ^5 ~5 F0 Y& N+ f
- #include <mach/hardware.h>
. X" s( y1 B& [0 G, i$ y - #include <mach/irqs.h>
: Q' y5 d* f! w" n - #include <asm/hardware/edma.h>
9 O; `* J+ V3 }' P - ' r% u* u8 p% U; Z9 \2 y6 f
- #undef EDMA3_DEBUG+ R( J6 x- E ]3 F( G5 y6 d
- /*#define EDMA3_DEBUG*/
5 @( ]' Z. _5 f, H+ N
$ b# ]6 K3 b- z0 E+ L9 o" B4 h- #ifdef EDMA3_DEBUG, @) T1 ~+ l; [
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 e" m2 _$ b% n# P! o. k
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% h; E" j( J2 m/ c! O4 t - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ a9 [" m, ?) B, u3 K2 K
- #else" B2 |8 a% W% E' @. ~9 s, r4 b
- #define DMA_PRINTK( x... )4 _+ w5 f v5 d f% W" O1 t1 ^
- #define DMA_FN_IN
. f6 v' P X5 B2 Y# E/ ^" @ - #define DMA_FN_OUT
4 Y9 `3 Z% G; e7 r8 J - #endif, M; I0 M4 \( } N% }! B! \( r* ~
) ^* D2 A8 s' ]% A" u2 L# u1 B- #define MAX_DMA_TRANSFER_IN_BYTES (32768); P ^# e) G+ E* q" g( {/ _
- #define STATIC_SHIFT 3
0 v( D$ S' }) C- A$ w- T2 v2 { - #define TCINTEN_SHIFT 20 ^8 B1 v+ H% ?1 a
- #define ITCINTEN_SHIFT 21
% f8 I' U) F6 l- J0 n - #define TCCHEN_SHIFT 22
Y6 l- c4 P* q, B! C2 O5 @% n" E* { - #define ITCCHEN_SHIFT 23, l+ F2 _/ d( s7 B, W+ n/ V
; k$ U6 Q6 S" [# f" z$ v4 y- m: ^- static volatile int irqraised1 = 0;
7 R8 {8 P. A* T% p - static volatile int irqraised2 = 0;
8 t- w% o2 d' B8 A0 h - 5 b4 Z& ? p! \6 S$ Y/ A! B" V
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 l/ j2 k2 c4 j; `5 ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: t) Q) h3 d% D& K) c
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 e7 x6 ~" t3 A* u' s
- # }! D! C! p2 d3 B O% U
- dma_addr_t dmaphyssrc1 = 0;& F% W/ l& {6 Q U Z* I
- dma_addr_t dmaphyssrc2 = 0;3 c& S+ v; u- k$ }: A9 G
- dma_addr_t dmaphysdest1 = 0;
& o4 I9 n0 b/ Y- f - dma_addr_t dmaphysdest2 = 0;' \% Y1 V3 C: w7 B& [, B, T
- ) O4 o, U* w# C2 y
- char *dmabufsrc1 = NULL;2 I2 _3 d- o8 ]+ R+ d
- char *dmabufsrc2 = NULL;+ x, f6 v1 M& U# z3 c! n$ B
- char *dmabufdest1 = NULL;
5 z# }% C( I: f0 [) S - char *dmabufdest2 = NULL;
- ~, r. C. O) I# N4 A: B
9 ?( r& K+ s% V+ A9 o; P5 V- static int acnt = 512;0 _. [" z4 Q% @# j9 [
- static int bcnt = 8;
) h, J* S, X( Z - static int ccnt = 8;1 G2 o0 R2 m2 }( u& |$ f$ Y$ S
" n r1 K" r8 G- p/ S j/ G% E/ a- module_param(acnt, int, S_IRUGO);' u8 F+ q F4 ?9 y/ q7 @: j
- module_param(bcnt, int, S_IRUGO);
4 U# d0 u! s' U7 H# M6 I - module_param(ccnt, int, S_IRUGO);
复制代码
) }' ?: q' P' A& j5 i7 C% I* o$ `+ T1 c" k' {5 \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) A4 Y- z: Z7 ?# f2 t M( U0 carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 V: Q& n' e; q" X* i# }8 c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' d0 B1 P; |1 B" N
8 ~4 f! o8 v, E- r3 Q8 t( r* I
# I$ k# l8 ~' P) y% h5 ~ |
|