|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 d6 D5 | {- M: {' z% S& M( `- [code]EDMA sample test application
# ~1 [3 Z. u/ B9 _ - /*
7 _" X Y4 a; @ J$ \& m" h - * edma_test.c
* }& I" C- C0 K2 n8 T5 g% T - *
) G+ Z7 W1 r2 p& p3 Q! _: h - * brief EDMA3 Test Application$ T' a, o9 j" o" s
- *4 g4 x1 _+ v3 g+ ?8 _" s% m9 I5 K0 h
- * This file contains EDMA3 Test code.* d. L4 D( c, o; m
- *
, _9 N. ?& r) T0 E - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% A, S: L" t' a* z! ~/ B. H3 ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" t" l) @9 b/ B5 U* F
- * TO CHANGE.
9 ~( `; `( M& A- z W' R4 D - *
) J: j4 V4 V3 x! k( v - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 |8 J4 v5 u, k5 C { - *! k9 d/ M; t. {, K: E9 m
- * This program is free software; you can redistribute it and/or4 U9 D+ @, A' |9 N, a& C
- * modify it under the terms of the GNU General Public License as
: j" P" d1 Q4 ]3 k - * published by the Free Software Foundation version 2.; M1 r0 ^0 B0 t- B# x
- * |7 G ]; U4 B9 N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 X7 |; |! x' g - * kind, whether express or implied; without even the implied warranty" o( j& N6 C$ O Y! C5 W/ s
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. h' X2 ]6 Z; i4 W
- * GNU General Public License for more details.0 i* w6 ~# Z5 R$ K0 h1 M3 K8 B t
- */: P6 I7 z* b$ O6 X% q
/ E* ~% B% `5 j' y/ k- #include <linux/module.h>
9 @& c% c: o( X7 t0 G# n - #include <linux/init.h>3 ?/ t5 q" ^: M, d2 }- ~& K) Q0 ]
- #include <linux/errno.h>% D' D |2 T- S. \* W) y) k' S
- #include <linux/types.h>6 e( o1 ~" { k7 n* S$ x& |
- #include <linux/interrupt.h>8 k) O* S! X) `0 ?7 Y9 [( j- q
- #include <asm/io.h>
; l8 \1 q9 f9 @8 @# {0 T: K# d - #include <linux/moduleparam.h>+ N7 l" }6 Q v8 t3 D( y8 v6 K, [
- #include <linux/sysctl.h>
$ i! L3 k0 \; Z! D( O - #include <linux/mm.h>
! L# V) d. K5 y( ]! ^: m - #include <linux/dma-mapping.h>
/ _- l7 J; w- }; a6 h3 n! ? - 1 V' D5 a5 F( B
- #include <mach/memory.h>
; B' H3 X* M% p) } - #include <mach/hardware.h>
o- W. K/ ^3 V4 j - #include <mach/irqs.h>8 x. N* W0 W4 R: M) c; y
- #include <asm/hardware/edma.h>3 U. C, [" k1 v& [0 ?- o2 i& f
- 5 N" n3 B3 ~ x
- #undef EDMA3_DEBUG
5 \) y0 ^2 h) w6 F/ k - /*#define EDMA3_DEBUG*/, x0 E6 I! F/ v& w {
4 W6 U0 H8 J) Z- #ifdef EDMA3_DEBUG
5 ]% L! C( I: L5 W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! ~5 a0 }9 Y6 u D6 K/ S& Y" [ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# o5 j. T3 J! \+ ^6 R4 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ j& F5 S' Y1 q3 d5 S/ d' H
- #else
' O2 n1 u+ s6 G R - #define DMA_PRINTK( x... )
, v& _# \" z+ e- e - #define DMA_FN_IN/ @: C$ @/ ~! ?
- #define DMA_FN_OUT& h( L9 y, f) Y P+ g( h: n A
- #endif! T: r( j2 ~1 ^: h- i* M
- 0 B. c# M! i- l) u7 B
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# Z7 n3 [+ s4 R$ a, W! V+ H
- #define STATIC_SHIFT 3: `6 }, | t7 E; @7 H% g3 B" p
- #define TCINTEN_SHIFT 20
! E( Y. ^# D) p - #define ITCINTEN_SHIFT 214 x ^2 s- @ [6 U$ ]2 g
- #define TCCHEN_SHIFT 22
4 z/ I9 w; I2 \( R+ ` - #define ITCCHEN_SHIFT 23
8 s' x# ^* ?# y9 b7 z- m: T* N - + A7 P0 \% s4 i4 s$ |; \ S
- static volatile int irqraised1 = 0;
$ N% `4 f) I$ V8 J3 a$ P& L) W' w; q - static volatile int irqraised2 = 0;
7 W* W/ y3 c6 `7 Z/ Q5 m
# F+ j# b" s$ X6 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 b; M7 f1 v4 C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! a. V. o2 C7 `- U% r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ A5 P7 M3 e; m! d# W6 R
2 o. @6 q/ [9 a- dma_addr_t dmaphyssrc1 = 0;
$ e8 e: y1 B, H( C" F. W- |6 k - dma_addr_t dmaphyssrc2 = 0;# Y# ], ~* T% r8 a
- dma_addr_t dmaphysdest1 = 0;& U% O. n: m/ @8 R& R/ ?* f
- dma_addr_t dmaphysdest2 = 0;
+ s$ A" K& a# z z
: m9 ?* z. c( w) }1 N6 U5 B- char *dmabufsrc1 = NULL;5 l9 {! i ?( l6 N! z3 F3 v
- char *dmabufsrc2 = NULL;! c' n. w+ g& R0 `
- char *dmabufdest1 = NULL;( |, n f4 M: J, ]0 V
- char *dmabufdest2 = NULL;& J7 u+ X/ Y5 e2 O: y1 L: q0 |
- * V/ t9 }, o* ^9 g/ J. Y, J% s: `
- static int acnt = 512;
% t0 U, z0 d8 d - static int bcnt = 8;0 c3 X* O/ w, i2 T K3 a
- static int ccnt = 8;: ~4 J# j3 N2 U- ?, D' \1 h6 x6 g
0 u; b0 T6 |+ A! C1 U- e3 L, A, a- module_param(acnt, int, S_IRUGO);
7 ~; T$ Q$ c( H4 { - module_param(bcnt, int, S_IRUGO);
' b$ s) o1 {/ l$ v0 h- c) b - module_param(ccnt, int, S_IRUGO);
复制代码 ( i" y+ ?7 D5 g7 P8 a, ?. }4 f1 t
: L1 u0 q7 J$ B9 T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) M3 `1 y' k1 E6 yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 s) j. n% ?9 {9 p6 z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 r* ?& w7 b; m$ X; w( R3 b! V0 h# G' `$ C- t0 B- A- T8 h
7 U4 X+ M4 Y% ?- J5 S0 M |
|