|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" H1 b( {0 G( N/ t% P) f- a- [code]EDMA sample test application
/ H5 @1 Z8 Z. y! U& | - /*7 \6 S$ g) M) W9 O4 a
- * edma_test.c
) I3 f& J7 c( G. Q" q3 I - *, i% x2 r, b9 T, C) e' O
- * brief EDMA3 Test Application/ M( v: |: k( k+ b
- *+ P: \7 P% u% R( j
- * This file contains EDMA3 Test code.
7 _8 X. H! K6 o+ c0 F - *
2 c H3 p/ P7 G9 U. E' Z) a - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 f7 l2 c/ s/ u5 v
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ u6 c* d" S6 p2 ~$ C
- * TO CHANGE.) ]6 i* C, K5 S+ \/ W
- * f2 Y; `: n" Y, i% O1 j$ d. u
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 a8 ~0 D" h" Z1 Y9 v! z1 P
- *$ \7 x3 V7 T L
- * This program is free software; you can redistribute it and/or
/ p! G# D6 h: h; q$ A5 p1 k - * modify it under the terms of the GNU General Public License as
4 C/ v! S6 s# }3 ?! D% T$ H K - * published by the Free Software Foundation version 2.6 g' i- L: r+ z. u8 J9 B' j( u
- *6 B" e4 R1 ]. \/ K: w
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: C8 ?# z0 _3 F- M& i1 ?# {2 |4 T# m+ D
- * kind, whether express or implied; without even the implied warranty5 ?% e3 O- n* O. }
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 |) j8 q6 \- x( J. P1 B - * GNU General Public License for more details.
" A( Q4 o% m' j& _( r: E - */
# X$ X0 E, E7 m" ] - ! e) M) M/ ~* c8 W- Q
- #include <linux/module.h>8 t; o1 F3 s% K f. f6 g
- #include <linux/init.h>* p" j G3 ]; ]. c# D4 e2 b, S
- #include <linux/errno.h> {7 ]' y/ T, l
- #include <linux/types.h>; h4 ?( h0 b5 e; F! k/ [# T
- #include <linux/interrupt.h>
1 [1 f# q( {2 M5 t2 q - #include <asm/io.h>" ? [4 Z( a# Z- d9 G: f! z
- #include <linux/moduleparam.h>
: p$ h( {$ Z: I - #include <linux/sysctl.h>
3 A9 |. O" u; _! y: n - #include <linux/mm.h>
6 U" T& g" d' D% r5 r3 c0 @ - #include <linux/dma-mapping.h>
2 O" V% J# w( H/ P! d2 m! M* h
9 S3 x5 b: P: j7 G2 [- x7 D- #include <mach/memory.h>
) k# U9 Z4 t& M - #include <mach/hardware.h>9 `3 D" _" j O7 K
- #include <mach/irqs.h>
! |9 s0 \9 F5 t6 ^- R - #include <asm/hardware/edma.h>3 `4 o! Q& F0 b* h& d! N& s- X* x
- ' V4 i% w4 d! M2 |9 ^3 R
- #undef EDMA3_DEBUG
. E( X2 D/ Q6 t; J" d - /*#define EDMA3_DEBUG*/# F7 e2 ]4 m- A! c% T6 z
7 b5 Q: p4 p ?* v7 T- #ifdef EDMA3_DEBUG
2 W9 w0 z8 D8 T2 z5 {* j- }: b, f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 A+ d! u6 c6 x( D- V
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 a* l6 e, U& `1 P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* B5 A/ X9 V' u' ?! ~
- #else: g v' x& k. M- Y( L
- #define DMA_PRINTK( x... )
3 w; H7 R% w% P, L1 X. { - #define DMA_FN_IN% @# A( B, g9 e+ n& G
- #define DMA_FN_OUT
& K4 }; ^7 o9 K2 T g3 m - #endif f+ F. \4 g }* s
z9 a3 m: r, E9 J- F- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* n- c: D* A" { - #define STATIC_SHIFT 3) b5 @% k$ b: J) ^2 k# F& q. z
- #define TCINTEN_SHIFT 20
9 D8 N$ O! n. `% ~# B& J - #define ITCINTEN_SHIFT 211 m( o5 f. `. H4 v, J" q
- #define TCCHEN_SHIFT 22
3 K" S6 r, {1 h; @; H7 ^$ o( [ - #define ITCCHEN_SHIFT 23
1 A0 o5 C4 [# C, A$ _+ s8 \& K1 v
, a/ N8 E! p1 m8 _- static volatile int irqraised1 = 0;7 d0 X3 f, W8 T9 G7 ?- j' A8 u3 j1 I6 L
- static volatile int irqraised2 = 0;
6 A' e- e' {. q
l1 g8 u$ N2 J4 b) b; s- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 z% ^9 g" w6 F; l$ m4 e3 D
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& b4 G& W2 l( Y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: v0 g: t4 @/ r$ X+ n8 L
3 ^/ L5 O7 q, ~% `7 Q- dma_addr_t dmaphyssrc1 = 0;" ?% h0 t5 c# _ t5 {( T# B1 m7 X
- dma_addr_t dmaphyssrc2 = 0;& O/ b7 q' b: U7 g
- dma_addr_t dmaphysdest1 = 0;5 K4 n; D4 b$ \5 ]$ p6 c5 C% ]9 Y
- dma_addr_t dmaphysdest2 = 0;
$ H! i) }. A3 y4 ]2 \" J s$ m6 W2 U
; U7 k# ]5 o$ g' V3 K- char *dmabufsrc1 = NULL;8 [7 J) }" J: J- f$ W I$ X
- char *dmabufsrc2 = NULL;7 P' i0 V7 J/ p" |+ z
- char *dmabufdest1 = NULL;
' G+ q. J9 F7 C! ^$ x2 \ - char *dmabufdest2 = NULL;
2 b0 i/ s2 \# F; [( L7 o# ?: A, a - ; h; b5 y4 u7 h$ K% [! j. x6 Q
- static int acnt = 512;3 q4 W: |5 ]) U3 x; [1 `' R
- static int bcnt = 8;2 b/ |# X. |! [4 ?; e( Y7 a+ T5 h
- static int ccnt = 8;
0 j: K/ o" M; [3 f! u' L
0 h4 }2 _+ L" u9 T' ~: Q0 g: @2 K- module_param(acnt, int, S_IRUGO);% M% c+ w) `" O; a% W+ i9 W
- module_param(bcnt, int, S_IRUGO);
# ~( r) l( F7 e2 @9 c( R - module_param(ccnt, int, S_IRUGO);
复制代码 4 J! r, Q7 _' B0 k
( k" a) q& s4 o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" h! x8 h! E0 c2 C- h0 C; ^$ Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 v% A1 a# R Y% l9 `9 r, ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( M0 ^/ B- U/ o% h$ H& X! w
0 s( U/ J C9 A- j0 m g* P; L5 J. |; l) ^4 _
|
|