|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 6 e. v }0 i, w0 R' E1 S y
- [code]EDMA sample test application
7 ~3 N- \- V$ q H" x% z+ d: s5 D - /*: N! ?* ?& u7 j7 P6 [ F3 V/ \$ X
- * edma_test.c
7 g& Y& p/ c/ ? - *
( A; E l: M2 C- L7 i) N7 i L+ M. r - * brief EDMA3 Test Application
1 Y4 x! o% p$ p/ Y& [( \ - *
# ~- k$ e0 l9 O8 l5 G4 Q; G - * This file contains EDMA3 Test code.% f0 `' o6 ?- M3 J/ ]
- *8 u7 E) L g, s M3 Z ~6 W0 W( r
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ {" Q, E, h0 P6 D& h
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT h0 s8 f' A7 X+ W8 ~' l3 Z0 t7 I
- * TO CHANGE., H" {5 j0 u4 F+ P- I: V
- *
$ ~' D1 C- W2 s) p- _% a$ T/ H% l/ I - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ u i& |" H7 Q2 w4 j2 W
- *3 o) ]6 A. t5 E- r" s
- * This program is free software; you can redistribute it and/or
( }% r% l& c7 g% h# } - * modify it under the terms of the GNU General Public License as
\& ]% w& W: f% S% w% z - * published by the Free Software Foundation version 2.
$ p4 P% L" d, u& {6 x$ R - *
* x+ B' C8 z. D- p - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) p3 _# E3 D% P/ A. w" Q% }2 B- {
- * kind, whether express or implied; without even the implied warranty* I5 l5 `: \* C3 j# p
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' f- O! K: Y" [' L8 [# }
- * GNU General Public License for more details.* ]) A9 k6 E" F
- */
/ s+ N( w+ k: I6 `6 s6 n - ! ~0 y$ G2 U1 d
- #include <linux/module.h>: o; b; m* t2 i3 o2 T; s0 r$ {
- #include <linux/init.h>
' G( |5 u8 k& Y, w# P - #include <linux/errno.h>: A' v' ]: `+ v- ]+ R( @3 @
- #include <linux/types.h>
) n. S6 H8 P7 h B: C$ L+ g - #include <linux/interrupt.h>
1 Q8 G8 s: J& [- N - #include <asm/io.h>2 f6 f; A- e: w: j, d# o
- #include <linux/moduleparam.h>% U( ~6 z* [( U% |/ I+ ?* K/ u
- #include <linux/sysctl.h>
% b0 f8 ^) U- U1 Y6 J F - #include <linux/mm.h>% q g8 _& G; E( ^ }0 t k
- #include <linux/dma-mapping.h>, n- W0 N* G2 h/ u0 O
8 l; P4 d3 t9 ?) I3 W9 d- #include <mach/memory.h>$ t" m- D: ?- s* m- L9 x
- #include <mach/hardware.h># c" Q' F7 T3 f3 p' E: `6 {
- #include <mach/irqs.h>* Y3 w% C1 @ O
- #include <asm/hardware/edma.h>
2 C0 i* [- E2 X6 X
( r; J8 f6 k8 o- Z- L- #undef EDMA3_DEBUG$ i# Z1 H, g/ o# D
- /*#define EDMA3_DEBUG*/; B, I4 [5 b' [# z# W1 A4 a' m" f
- % _' ]/ N: K! ^, \7 X- i
- #ifdef EDMA3_DEBUG7 M2 Q% A8 x& V" m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& {2 Z" [) q1 m$ B& q% D - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* H' `. R5 z1 l9 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 A1 O9 w8 ~, t& u1 q - #else5 x1 }: G8 K) o1 [0 R: f9 n
- #define DMA_PRINTK( x... )
" S0 x+ M/ @/ t' y- \ - #define DMA_FN_IN
' N0 ?$ x: ~) V% U: @ - #define DMA_FN_OUT
5 i7 F% W" o. k$ o8 v$ k( L0 s$ r - #endif
/ t( Z5 S$ O; e7 e- R7 O$ |9 N - " G" r. J2 p. h0 f% J4 L5 s- S7 i
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 P* @! d! j- o
- #define STATIC_SHIFT 33 Q; w8 F; h$ h
- #define TCINTEN_SHIFT 202 X5 f. b# \" p* u2 j/ V& A( H H) p" C! n
- #define ITCINTEN_SHIFT 21. e. H' y! @7 T. X+ ?! y; \
- #define TCCHEN_SHIFT 22
' B: q5 Y4 V6 L( O - #define ITCCHEN_SHIFT 232 U9 ~8 q2 X4 P0 d
+ S( v0 `0 P {, O) M& z! ?- static volatile int irqraised1 = 0;- U* c* l- A( |1 }# O$ y
- static volatile int irqraised2 = 0;; Y- h0 M8 z1 x4 C2 w$ }
- ( L+ H6 P7 j% r' k' L
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( Z, u7 V( j3 F; q; p b. R. s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 ^2 S2 R8 O7 d" N - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* W7 G2 Z7 m7 l1 T1 _ - + ^& `6 e+ v$ ^* |7 \
- dma_addr_t dmaphyssrc1 = 0;3 X! B! D: y4 b+ j9 |* P: X
- dma_addr_t dmaphyssrc2 = 0;
9 f* T, q' H/ P5 h - dma_addr_t dmaphysdest1 = 0;
* B2 u* G6 I, I7 s2 A- z - dma_addr_t dmaphysdest2 = 0;
& ?$ J( h- L6 d5 T8 r1 Y$ J' V - $ g3 S6 ~- o: C A
- char *dmabufsrc1 = NULL;5 \6 n) N& c) c6 S. ~! Z
- char *dmabufsrc2 = NULL;5 R! s4 m* n. R
- char *dmabufdest1 = NULL;
( X2 r. f! L. l* g - char *dmabufdest2 = NULL;
5 A% R% O: S3 u' D: T
5 o$ x* ~2 g: p9 y& A8 H# g8 Y/ n- static int acnt = 512;# @9 v( Q g5 S. [$ D: u
- static int bcnt = 8;1 G q$ l( X8 l8 `: d; J
- static int ccnt = 8;
; t" t' e/ e, r6 i3 t+ c l
/ R* o3 {) ]4 b) L& i z; o- module_param(acnt, int, S_IRUGO);
$ E- k4 m$ u4 \. Q, y, \. n - module_param(bcnt, int, S_IRUGO);
' M% R% u/ p6 U1 r+ f4 \ - module_param(ccnt, int, S_IRUGO);
复制代码 ! K0 S* ^) M5 e& @' R
& W" g6 m0 n5 a
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% A( _, @' j p- J! X, garm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ _1 o( _! t% ^7 Q& O( Q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 p5 _' B4 `3 M, F8 Y' Y
* x$ V/ b- w) g) {2 U& A2 M! ]4 R% n1 A+ k ^1 g+ V
|
|