|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' `' B) v3 z+ {/ w! A8 W- [code]EDMA sample test application/ u, |) U0 G7 a/ y- ^
- /*
0 C: I3 S @: }1 k9 q/ n7 y% Q* I9 K2 R - * edma_test.c, t+ Y7 i3 Q3 x" K A8 S, N8 I3 V# U
- *
; Z7 I" C! c; v- }" B0 @ - * brief EDMA3 Test Application0 W& j4 h1 ~9 m/ ? o- B
- *, M: c" K+ u' L/ t6 j
- * This file contains EDMA3 Test code.
' O' ~& b& ]+ R- U4 m - *
4 P5 ?# ~* K G4 k( O3 d7 c - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- X3 }# S* E, y$ J - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 E4 P* D1 ~. N7 [( o1 n$ B - * TO CHANGE.# J# V' R4 I4 B9 i0 ]; f
- *9 x! w1 }% o5 O& M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ V+ Z1 _9 @2 Q( L- U h - *6 _. M+ t+ R3 {- K B x
- * This program is free software; you can redistribute it and/or# s: C/ T7 v* j5 a6 l. l
- * modify it under the terms of the GNU General Public License as A( D; V2 e( S1 w2 x" L, w6 g
- * published by the Free Software Foundation version 2.
0 ^. K" @1 W) \ - *
4 f9 ?) l7 Z; D& L/ f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 `( v. E/ r' Q4 ]! U5 }+ b
- * kind, whether express or implied; without even the implied warranty- F& ]- O' @$ P E- Q8 [, v& u' F) C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 }! T# V. l3 w& J0 X - * GNU General Public License for more details.
$ u% q2 U9 K7 G2 H - */
3 T, F( z N9 e% b7 X( O
& B) l7 Q1 l+ g. y+ o& _; g; |- #include <linux/module.h>, m* r+ D; e, q6 k8 _& I
- #include <linux/init.h>
8 ?! h5 M$ S U: | - #include <linux/errno.h>
% f% C# i; Q' y0 _ t - #include <linux/types.h>
: ^$ ]4 W9 l) M2 F5 y - #include <linux/interrupt.h>
6 Y6 C# n& `5 d* u" o* l - #include <asm/io.h>
/ P& s0 x" E; F. T$ S# @9 n | - #include <linux/moduleparam.h>
) p: r. H: M8 Q( @2 u2 E- I: ? - #include <linux/sysctl.h>7 a! M8 A4 v$ _" R$ [
- #include <linux/mm.h>
6 l7 m. {3 d- v - #include <linux/dma-mapping.h>! e0 E4 X, Y6 L/ l
- - |) W9 r9 N0 {
- #include <mach/memory.h>% X+ a: [+ h8 K# S
- #include <mach/hardware.h>4 \9 D" K" [, M
- #include <mach/irqs.h>) H. K/ N$ M0 ~( q# ^2 a4 e( u/ m! q
- #include <asm/hardware/edma.h>
# Z. n, c' g; N$ v/ e& E7 _0 p - 9 ~. @" Y$ J5 H" @
- #undef EDMA3_DEBUG! t+ q; G5 y& C/ l3 H
- /*#define EDMA3_DEBUG*/( B* O/ S0 A6 v9 F/ s3 `& r0 z/ W* g
! x: ^+ k$ o5 |6 U- #ifdef EDMA3_DEBUG- f# x' v9 l$ l( r: _5 |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& W0 O2 Y/ w/ L% _( \2 d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 V' @1 E- w$ k/ G: r' o* i8 V q4 ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( r8 N1 g( s) @$ O. L
- #else
' S: @( j" U6 Y. V8 ] - #define DMA_PRINTK( x... )
8 F9 r) \, B: r8 G% @& @2 K - #define DMA_FN_IN+ I( Y/ v. R. f, |0 V
- #define DMA_FN_OUT
) s, r/ [8 o* n. B - #endif
3 O8 S s' N6 K# c8 f
2 A( G \ e9 p) N- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 U6 l9 }) n/ N' k0 {
- #define STATIC_SHIFT 3
+ e" c- L. b7 }# s4 v - #define TCINTEN_SHIFT 20
2 J, z6 p3 r. y6 _4 `! I* P - #define ITCINTEN_SHIFT 21& o4 F; y" m/ t; a, J, G3 q
- #define TCCHEN_SHIFT 22: Y3 i" y4 l( O; B
- #define ITCCHEN_SHIFT 23' p, Y& H% z& K7 E; K# O5 @' F6 m
- 8 m" n) @7 b: Q. h! M" e
- static volatile int irqraised1 = 0;
4 V9 T2 G7 V" h" J9 p+ s1 x - static volatile int irqraised2 = 0;3 H+ \8 @( r. x- g7 g) w& f
- U; j! `: Q7 A, V. h+ p
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; O- \0 g3 k4 \8 }) O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 J' y u; \% K: U5 k1 I* q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 a" R) B0 ^) W: o+ y# y
: l& T0 B# O2 l5 T: y- dma_addr_t dmaphyssrc1 = 0;
' I4 L3 t9 n7 `( t* r0 \6 v9 Y - dma_addr_t dmaphyssrc2 = 0;" S& \" e9 i0 c7 K0 p
- dma_addr_t dmaphysdest1 = 0;# b. Z. n' p: x0 W" n8 S. s& \
- dma_addr_t dmaphysdest2 = 0;( t- w2 U! m% j* `
0 d1 } ]4 D# q3 Z6 \, N5 k) V- char *dmabufsrc1 = NULL;
9 e' F7 p3 l7 d+ w, Y* r1 l* `) h: Y - char *dmabufsrc2 = NULL;# m/ h9 X( z T8 Q3 J
- char *dmabufdest1 = NULL;
& ~. H- ]# t& F" n- Q4 \. ^! K - char *dmabufdest2 = NULL;
- A2 K' [$ A: ?1 F
+ b6 V# A2 O3 F3 k. Q& q* @9 a- static int acnt = 512;; K+ c9 {3 R! H# O' [
- static int bcnt = 8;3 F0 Y2 ?' B/ T( P
- static int ccnt = 8;3 l' ]* ?/ o+ K0 S& y
- 7 A7 d0 _ C" R. T/ a% \% x3 R: Y/ m
- module_param(acnt, int, S_IRUGO);
9 Z' R9 W- {6 F, K4 c - module_param(bcnt, int, S_IRUGO);+ I9 a3 `% ^- n" A6 H" l" r
- module_param(ccnt, int, S_IRUGO);
复制代码 . h5 V% E' _3 q) D
9 ?+ w7 X ?% d+ F% g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
}5 L q0 l+ j# larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- ~7 F3 T- U6 H% u3 i* Z, b 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- G. p( c$ z j- n& F( w7 V
9 b, @# H- o. R' p7 R. x
6 O2 ~5 x; a2 e0 Y- J8 @' X |
|