|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! ^. L9 u# D- k" ?# x- M- [code]EDMA sample test application
% ?* \+ ]8 g& s% W* f# P( \ - /*
! o( P0 I! I$ ]# f2 J2 Q - * edma_test.c$ ^* W1 z% y5 U& d) W; X- Y
- *
8 }' L- {, m' R - * brief EDMA3 Test Application
6 y/ _5 Y9 v9 Y+ q; M - *
% a0 W" B2 I w' Q; C# k; H3 P9 r - * This file contains EDMA3 Test code.
: w* o$ B, h$ M R* ] - *
% y: _9 C# r4 M& i( {9 L2 z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 z4 q! s H. i* O
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 ^, u/ o' L+ x# h7 F
- * TO CHANGE.
5 x6 s7 \( I" Q) v- _5 t - *5 Y; e& e* L" ~% N' t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( |" B+ Q4 R/ I4 J7 Z& g - *8 E) Q6 ?6 @. Q$ R
- * This program is free software; you can redistribute it and/or7 C; s- [6 g% u
- * modify it under the terms of the GNU General Public License as
, j/ U/ F, i& H: Y. Y; ] - * published by the Free Software Foundation version 2.
8 o; ?0 P/ n9 z7 i: T& d0 F - *
' D7 I, _' `% W7 H' I- X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! F7 ?; ]7 ?( v! f: K - * kind, whether express or implied; without even the implied warranty
. C/ b' v1 q: |- M4 J: g1 t" O4 { - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: O* e4 m6 l6 T. C) Q! e3 i - * GNU General Public License for more details.
/ R. A! l! p7 y, `; ^5 G9 K - */& g9 J1 h5 m( L4 K1 [
- . w5 V) u3 P. k8 A. Z
- #include <linux/module.h>
0 K F% a* L: Q% c2 S+ _( ? - #include <linux/init.h>
. y ~& R5 R' e( E+ v6 ?' C - #include <linux/errno.h>
) O/ m. K: z$ r8 `& k - #include <linux/types.h>
! P7 W" i `: F8 w# t+ | - #include <linux/interrupt.h>- e8 J6 k$ m: x- C% Y6 M
- #include <asm/io.h>
/ [- R! T2 s5 G+ S2 S - #include <linux/moduleparam.h> B2 U3 p, [5 a4 I, |1 s( t
- #include <linux/sysctl.h>, E9 }. n4 M3 g U" P2 A8 Z9 w& t4 G
- #include <linux/mm.h>6 S: c2 j8 L* s) L2 v( F" N! w
- #include <linux/dma-mapping.h>
1 W& ~+ U* \& M6 Q# a5 {
5 `) b4 M! a" u2 M- #include <mach/memory.h>; H0 C: [' ^% @( H/ R7 x
- #include <mach/hardware.h>- B8 l S9 W# J4 n
- #include <mach/irqs.h>
/ u& B6 L* e7 F( l9 {5 [ - #include <asm/hardware/edma.h>
0 n4 h, L$ j; \1 f. x3 c+ D - 7 Q; b0 ?0 G! C W' m
- #undef EDMA3_DEBUG
9 R/ a# t+ e9 ^. R - /*#define EDMA3_DEBUG*/
: u; v9 K5 o9 y( |/ n& \& u - ' N1 k0 h0 Z" z2 v/ v2 S
- #ifdef EDMA3_DEBUG- Q/ r$ ]' g- C. R0 ~% V3 t
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% c9 {( j* w* \
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# O6 b6 C9 U0 r4 H5 ]
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- h" z& U4 `5 D* g1 f2 ~5 } - #else
) G; m2 A T& G: r/ \ - #define DMA_PRINTK( x... )6 w/ {/ m1 {7 l( x$ D& J) O
- #define DMA_FN_IN6 m" N" Z7 m7 A; K- H- p" N
- #define DMA_FN_OUT& Q6 I& T' Y$ I$ N% G2 l3 a
- #endif$ a: S5 H8 g2 u4 x8 ]( l2 D1 v
- ) C, W% O* G& c8 N/ r y0 q" S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" U3 K: a2 j0 ~3 c9 [. P! a4 c q/ a9 E) E - #define STATIC_SHIFT 3) i" r- V, t# c
- #define TCINTEN_SHIFT 20
; `" S0 i: l W" E& g" U - #define ITCINTEN_SHIFT 212 ]3 b! g8 {* S$ u8 m, e
- #define TCCHEN_SHIFT 22
' m! L$ ?4 J0 \; E - #define ITCCHEN_SHIFT 23/ t: c# P6 i, U* E
- 0 W' _4 B' v& R) ]0 k2 P% [# B& ]/ _
- static volatile int irqraised1 = 0;
" z8 v* Q- T1 a6 z4 i: A - static volatile int irqraised2 = 0;
6 v: U% w. I: Y/ I5 u0 o. s$ V - 9 } r2 v9 o, a. n0 n1 G; S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ q; g- j8 W3 b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) C! A/ s4 W5 n8 R, t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); R. P/ m. V- L
5 Y# S7 {% s: M! _( a. E- dma_addr_t dmaphyssrc1 = 0;
; g' B" U! h1 }% M2 j0 S1 t - dma_addr_t dmaphyssrc2 = 0;
( i2 {& V) J: { - dma_addr_t dmaphysdest1 = 0;$ T2 q9 X g! V" n1 T& L- D/ H4 ]
- dma_addr_t dmaphysdest2 = 0;
1 J) j' [! C2 K) @/ r) v& U - 8 ]7 V. g- Z# h1 k# Y& L
- char *dmabufsrc1 = NULL;, c7 d) D5 S. _( h+ N) M3 i! g
- char *dmabufsrc2 = NULL;8 Z( z5 b2 r. N$ i0 N
- char *dmabufdest1 = NULL;
& |) Z1 w- @3 |* c - char *dmabufdest2 = NULL;
; s% _; K8 t. k
- Z+ @2 t8 q2 T4 S' R; A7 D- static int acnt = 512;
3 j: @: z2 b1 n9 |6 B* X - static int bcnt = 8;' ^6 @+ {2 f M6 m& }
- static int ccnt = 8;
q9 D. Z6 `& S/ F5 w
" b; h- r5 ]- f% y; r: w: Z& X7 y( s- module_param(acnt, int, S_IRUGO);
/ v2 U8 B' _- O9 c, X* `& o* ^ - module_param(bcnt, int, S_IRUGO);, H% }: C& U# [) j, f
- module_param(ccnt, int, S_IRUGO);
复制代码
# Z, m$ T' R2 _8 l: j7 s7 Z* K7 |7 C/ i/ T" c3 z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! H. h6 o, H9 V- L {; aarm-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 \8 I6 Q6 |5 \0 @7 R x$ z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& d4 I+ q2 A5 d: N7 O7 H$ T1 @9 Q
& k5 X+ G9 C8 n! {- ?7 _; k+ j" N
|
|