|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( z8 I' B& E. t% L- [code]EDMA sample test application1 [- c: R& @ S
- /*
8 Y! o$ y/ g* }% g. k0 [. A - * edma_test.c$ z( c; T N! x( l# e
- *
8 V* }. _1 k; k1 A. B6 w - * brief EDMA3 Test Application
|, r/ T k/ Q: ?3 t2 Z - *
8 ]4 J4 H x0 `7 ]0 Q - * This file contains EDMA3 Test code.# f4 ]# c' }% ~+ \
- */ I' T8 S8 l' f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
H- t$ r6 O1 ~. e# Z# p# v' T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
' F; H: H! \0 d, b z - * TO CHANGE.) e c1 ]1 I6 v5 p# e
- *( a4 B; X$ h# b# f# s" ~6 |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com// }' @+ U# D( ^6 S' |" I. |
- *) L- g9 z6 B5 W! ~5 u, i4 g
- * This program is free software; you can redistribute it and/or
/ M1 P# ], @' O0 j8 z( u" Y& h- ~ - * modify it under the terms of the GNU General Public License as& P! R1 y& l/ I3 \. w
- * published by the Free Software Foundation version 2.- x2 i8 |% ?2 }( |* ]
- *
* R2 V) Y* T( `$ J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& i- S# ?( \+ d7 U - * kind, whether express or implied; without even the implied warranty
3 V' ?( p1 G8 [% y; U; l - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. q% Y! a, n1 E3 _6 B' `% L t5 \
- * GNU General Public License for more details.! C# [3 b8 a( b/ k7 k+ ?: T
- */
8 O7 O6 @$ N; T0 @5 Y2 A
" c- s8 e8 L& n( x6 I+ z" S- #include <linux/module.h>+ s, [8 T3 o4 T1 \$ K
- #include <linux/init.h>3 d1 i3 k0 W6 u6 g4 q" q
- #include <linux/errno.h>& O ?& d8 w* N; E! S
- #include <linux/types.h>
: U/ i; U- ~' V - #include <linux/interrupt.h>
, f/ G- }8 g2 p - #include <asm/io.h>
1 e0 X7 C: e( f" O - #include <linux/moduleparam.h>, @' q( v1 p2 v2 i1 Y+ E `7 ?7 `
- #include <linux/sysctl.h>1 A8 s( y" b1 B
- #include <linux/mm.h>
" E, F6 {+ M; A2 W% W% r - #include <linux/dma-mapping.h>- o1 c3 x& f, Y' W
4 O3 G. q/ e3 k3 R: W- #include <mach/memory.h>
0 X4 E. F% P0 A F: H7 |3 I/ k! Q: e4 ? - #include <mach/hardware.h>6 i! U: V: Q* T* V+ x/ V
- #include <mach/irqs.h> H* J8 P. K- O
- #include <asm/hardware/edma.h>5 ]6 E! k+ a8 I# l* w5 m2 D
- $ i8 i" o" ? L/ d: q$ O3 a
- #undef EDMA3_DEBUG v6 V3 S: R' q+ w5 j! b
- /*#define EDMA3_DEBUG*/
( J4 E" }9 [* |! i# W1 y
) v0 J h9 X9 L) V0 N6 [( D- #ifdef EDMA3_DEBUG
: U g5 h" m1 N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& P% E7 ~ _# R; |( J" k' g2 N
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 x. V1 Q. Z7 Z& L7 `( e5 B9 J
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- Q7 |& \2 S' o& A/ ] - #else
7 u0 X1 r( i; J5 a- D% N/ e5 | - #define DMA_PRINTK( x... )
K1 E( Q+ ]2 g! q% S* O) L - #define DMA_FN_IN
: h5 B! M1 l1 R/ M5 g( N/ P' y - #define DMA_FN_OUT
+ v: R8 O7 a9 R7 P - #endif
5 c/ j M2 G7 j- j) `. n
& l0 w, W# ]( z7 B. Q/ U( a- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" O, t! p2 d: N* m) V - #define STATIC_SHIFT 3
6 M' f5 u5 O. q( `, i% W$ _, Q - #define TCINTEN_SHIFT 20
7 h! B5 A# \; O! ~ q - #define ITCINTEN_SHIFT 21
4 C' \7 g. r6 L) d - #define TCCHEN_SHIFT 22
; E' O6 g1 v4 v( U# B, { - #define ITCCHEN_SHIFT 238 Z% h' P. x; M3 u9 ?: o0 _
- ) v R* O3 H) L/ ]8 S$ }
- static volatile int irqraised1 = 0;; o5 X5 Q: Y& K' R% ]
- static volatile int irqraised2 = 0;
/ w# _/ R7 o/ h6 z) Z
+ A" T& a/ t! t0 m/ Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 ^: ?+ W( F0 N5 e) b4 ? - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ G+ Z& h& t8 C( [+ g8 Q9 k. d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: ~6 \$ m# O6 \) v9 O - & e* ]( D7 y1 F: ?& D q( t6 f* I
- dma_addr_t dmaphyssrc1 = 0;
: V7 N; H4 f. n* B7 N/ V# i6 ]% Z - dma_addr_t dmaphyssrc2 = 0;
' f8 C9 c: }& Z8 d% O/ y - dma_addr_t dmaphysdest1 = 0;
5 j* T5 N- @( l3 Y% { b5 K - dma_addr_t dmaphysdest2 = 0;2 j- j# \! ~7 ^ A$ K( H; D$ e9 r
0 u# X- [6 D0 s6 z9 ~- char *dmabufsrc1 = NULL;0 c k5 [& E7 [6 @/ H" M9 O
- char *dmabufsrc2 = NULL;
7 { m" Z+ @1 D& ]; V - char *dmabufdest1 = NULL;1 M# c8 E( l- h; x, n
- char *dmabufdest2 = NULL;$ o; [2 C5 s+ {& {% |8 @
- " C5 a" I0 ~2 F9 O( X- K( j
- static int acnt = 512;6 [3 x8 z4 H" {% A5 d6 P8 F
- static int bcnt = 8;
- s2 a2 _/ I* P/ c- j6 D& g - static int ccnt = 8;8 \1 h( s, X v- o5 M
- B8 ]. X! r! O- module_param(acnt, int, S_IRUGO);
" v7 s2 t9 }; Y2 B3 W- j$ k/ q - module_param(bcnt, int, S_IRUGO);$ ?; j; X7 s3 x; t$ n0 P5 c: U8 A
- module_param(ccnt, int, S_IRUGO);
复制代码
9 l, Q s! r; E% o* Q E/ s
9 k9 a. q$ a& o. e3 l0 M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( O3 C7 U, _3 O, ~8 `% e 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 F( E, v& L1 n3 o! ]5 j! b' n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: I9 C# Y; f t& k
6 N8 W z" \8 i
' i" T( t6 ^7 z" c |
|