|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) }7 a b9 ?% f" ^, @/ p
- [code]EDMA sample test application( f# @4 o2 O" u
- /*6 Z% ]4 ~" A" L, e3 n; k
- * edma_test.c
9 R) V; O+ C. g/ u: H% x - *
9 J' {0 V4 w! P$ l# O - * brief EDMA3 Test Application
; V! j, t9 Z( O - *
. F! S) |8 b' h4 H1 e - * This file contains EDMA3 Test code.
: i. ?7 f3 i) j# \8 E5 B ]0 [: K# ^ - *% k& m" y( u6 c. { V! Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ X3 ?- T. _, C4 w/ m
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 q0 r2 F9 i" p) D8 v
- * TO CHANGE.
1 K2 _: h @3 k - *
7 L6 ^ G# ?3 c, M j- l - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 t2 S4 K! x8 O* f/ A) G
- *
; E$ r. o/ L7 i! O% M- |3 |0 \- f - * This program is free software; you can redistribute it and/or
0 X. k8 R7 M, ^9 i/ t - * modify it under the terms of the GNU General Public License as
+ o( N# N9 H; C - * published by the Free Software Foundation version 2.
- \9 E& ~0 Q2 c* ^' i+ |, O5 D - *
) U& c! C8 {. J9 D/ [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: b+ h6 c6 M. \7 S3 j/ Z - * kind, whether express or implied; without even the implied warranty
$ j+ ^6 N* D2 [6 U, ?& W8 Z- d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" o7 p& ~/ C& Z* x: `; ` - * GNU General Public License for more details.
4 N. g$ S( B# z. ^' } - */0 `) K+ y* a& z. H7 s
3 f/ {. Q) \8 L" j e# c- #include <linux/module.h>
4 h3 W( C4 s; b' T. a - #include <linux/init.h>
3 t% K0 I, V+ m! t1 ^9 a, @* A6 k - #include <linux/errno.h>
w) u! G' b( ] - #include <linux/types.h>
0 W7 {) s( B" d' u - #include <linux/interrupt.h>
9 p6 t0 J6 L! g$ c - #include <asm/io.h>
+ D& }- x9 j' n7 W z) w - #include <linux/moduleparam.h>* m3 H) ^: ~" Z, S
- #include <linux/sysctl.h>
1 }4 L# b0 y- }. Y/ r/ a - #include <linux/mm.h>
" o- b1 s! Q, }% h& k) j8 Z - #include <linux/dma-mapping.h>- ?7 C- O: j0 h1 N
- 2 d$ S. n" t; K! ~
- #include <mach/memory.h>
1 L/ S& Q; {% Z" ] - #include <mach/hardware.h>
! @1 J8 `6 S: ] - #include <mach/irqs.h>
3 B$ J+ F" W q, { }: K - #include <asm/hardware/edma.h>
. w8 L1 E. l' f3 I - " [& S* h, `3 z- R& z0 S/ S' w. C
- #undef EDMA3_DEBUG' I( V$ J' M9 f: k, N
- /*#define EDMA3_DEBUG*/1 m3 P8 Q2 f7 G `. q0 R
+ S3 n; L! `* g/ X& S- #ifdef EDMA3_DEBUG
9 |; `6 f$ \1 X4 L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 ^1 }$ o' W; W, s$ b* G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& l; ]9 S c$ q2 y, p7 X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' f6 O, q9 {. b9 m# Y! T6 V! G - #else8 h) _! b2 W( T8 k/ H
- #define DMA_PRINTK( x... ): B% ~3 H" S$ p' P4 K
- #define DMA_FN_IN
) l) J; s9 H7 m0 Z+ |! ] - #define DMA_FN_OUT: ^- }" V `( R5 ]' [
- #endif; |/ K+ T. u- V# R5 [
; C0 `. {& [) @: M2 v: h. \- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 b( a) h& d/ V; {3 ] - #define STATIC_SHIFT 3# O% z2 U; n% W' N$ a) f7 }/ Y
- #define TCINTEN_SHIFT 203 c0 U5 v* v" c( }6 ^$ Y& n; B) u
- #define ITCINTEN_SHIFT 21
# S$ C* R& x$ [; b+ @ - #define TCCHEN_SHIFT 229 w: o# o0 H% ?' |
- #define ITCCHEN_SHIFT 235 M L( f; _9 y: q2 C2 N" T/ ]1 \
- K1 [6 X2 `" C
- static volatile int irqraised1 = 0;2 t: R, ^ w1 ~% f
- static volatile int irqraised2 = 0;( a! c; X6 P* G+ V( m$ _1 D
- % t* c- |1 h7 f4 Y" n% E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 m# m/ y+ A; R+ @/ I: v5 m6 m
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 D+ |! [# `, o) |6 l& k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! o. [& L- `& D; j. t6 C# r
# a) U9 G3 s4 ]) B1 T- dma_addr_t dmaphyssrc1 = 0;) m: P w$ r8 k& {. h9 k# I# _8 P/ w
- dma_addr_t dmaphyssrc2 = 0;
/ F g7 L" v& h7 \ - dma_addr_t dmaphysdest1 = 0;
6 c3 C W M! I+ k; X - dma_addr_t dmaphysdest2 = 0;5 N8 z% P' O0 ?# o
2 B1 W0 \. G8 v: f( E) q- char *dmabufsrc1 = NULL;6 O! \; h/ ]3 b
- char *dmabufsrc2 = NULL;
) ]# l, [8 s- s9 G" @ - char *dmabufdest1 = NULL;, R: f& O6 o9 R6 j/ O1 h5 i
- char *dmabufdest2 = NULL;( O8 Y! R! e5 |9 I( f
- " J4 J4 Y3 y" a4 P) K1 Q" {6 O
- static int acnt = 512;
# l' ], r/ Z( k3 E6 G+ k - static int bcnt = 8;; f- C" D# @; F0 c
- static int ccnt = 8;
! Y: U' i* A8 @& i' e& P - 9 B2 m- t1 y% t9 @( t* I9 f
- module_param(acnt, int, S_IRUGO);
* C, e% N K4 M5 z - module_param(bcnt, int, S_IRUGO);
8 F6 \, X% R4 V+ M8 { - module_param(ccnt, int, S_IRUGO);
复制代码 ; G* Y4 B/ G1 u' E8 P# K# Z
& r7 s6 W. J! U' a: ^( U0 x8 ?! ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 e; Z4 D3 l' h6 y( v9 barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' k% @% s9 r" d4 z/ |4 b! k 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( i8 A+ R* `* g1 ?
0 p7 D" o" t9 G8 E* }4 M P( v
) G. h# o4 v, @ |
|