|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , ^' N. K- V2 z9 V$ f Y% G
- [code]EDMA sample test application
/ U4 f8 n* O6 e: G; K# n - /*
4 N7 }7 c9 ~) m& T' @* T: V' f - * edma_test.c6 N# j y& I& Q, o7 N- }
- *2 q y5 B5 v0 D5 ~* j7 C
- * brief EDMA3 Test Application2 j9 i5 ?0 h+ p$ W
- *
+ ~1 A7 Q- [1 w' @ - * This file contains EDMA3 Test code.
* T& I7 ^% I: X - *
! Y2 A3 e, V3 P! _3 b1 u - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ X" @, M% v+ ~, Z. a; y6 Y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 w8 F: V6 \9 A, p8 A
- * TO CHANGE.' h& y: D9 ^- o% k8 }
- *8 M" r; { i! z. P# M, E
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 |$ Q! z. p+ l
- *, P9 Y( f2 B \: @! c4 P! A
- * This program is free software; you can redistribute it and/or
$ Z1 G. N l. P: ^9 W - * modify it under the terms of the GNU General Public License as: @- Z: i s$ f
- * published by the Free Software Foundation version 2.7 O$ z8 t( S# e( ?- M, j2 g/ o9 c
- */ i* {2 Y' L; Z! U# L! F4 ~0 E
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 e. g1 |" W9 x
- * kind, whether express or implied; without even the implied warranty
$ M: ?$ V# I/ o# @# e: o w. w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ u2 s; o7 t! \% c1 G. k5 l - * GNU General Public License for more details.
/ F6 R8 ?( j' l- `7 P - */) h" a5 H1 I$ ~( `8 f) L! X
- J& C7 I9 E2 i! ?- E3 y- #include <linux/module.h>1 R/ Z1 j# }3 }9 W! O
- #include <linux/init.h>
) y5 z- Q* S$ P& A - #include <linux/errno.h>
1 ~8 o8 ]* o5 u! P6 P R2 T- e - #include <linux/types.h>4 V: p) }- J% q1 Y1 b, d5 ~% |
- #include <linux/interrupt.h>
$ r% [0 l0 J/ V' W) Z: S - #include <asm/io.h>
. ~, ~, l) U M) Y: _5 d9 x7 B - #include <linux/moduleparam.h>2 k0 T$ ^' I) @" V1 |
- #include <linux/sysctl.h>
6 J5 d1 ^ v5 P: p, q2 m" f. V - #include <linux/mm.h>
! p4 | K% e! Q& j$ e# n& I1 p - #include <linux/dma-mapping.h>
+ h/ P& y5 n, x
6 y. @& A4 s2 [. H- #include <mach/memory.h>
1 l+ [7 p8 W8 j - #include <mach/hardware.h>' v. u. S& G. l
- #include <mach/irqs.h># f( e) k3 _0 i6 Z! V
- #include <asm/hardware/edma.h>' H' U1 B* v% M u' L3 B2 C3 D$ B
- : o- L: |, K/ T
- #undef EDMA3_DEBUG7 L( A5 K) X! o2 H, D
- /*#define EDMA3_DEBUG*/6 }: w6 w2 X/ J( @+ @8 o7 u6 \
- " N- }# z: x$ n% U& R- @
- #ifdef EDMA3_DEBUG$ m) L4 z7 e2 y1 g& W& ^% |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 z( Y) e% n, [( D, C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. u h$ h* B; H2 j0 _! W3 ?5 \8 _, [ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ Z1 S3 e+ z" D - #else- t0 P2 Y- C: {' N% p
- #define DMA_PRINTK( x... )
5 V7 f1 b3 v, P% k( A - #define DMA_FN_IN
" j1 I8 z. c+ D - #define DMA_FN_OUT
* I+ G+ t, a% A - #endif+ [. c8 G7 L) `' o
- $ Y0 E- C" l2 [
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 r9 }9 i) T {1 ]9 q" x
- #define STATIC_SHIFT 3
& u* `5 i! u1 O& x - #define TCINTEN_SHIFT 20
9 M7 v9 g6 s" b$ r3 y: m - #define ITCINTEN_SHIFT 21* r% a* k8 D, B% a# z5 p
- #define TCCHEN_SHIFT 225 a: o3 X& v! f2 l
- #define ITCCHEN_SHIFT 233 N' i# c: X' u- G4 U( M. B/ c) B
" Z# Y+ ?- ~7 C0 {- static volatile int irqraised1 = 0;5 k$ f/ w: n* L2 q
- static volatile int irqraised2 = 0;& k. f5 e2 D5 C% }9 ~9 `
- 0 W* _" S3 w: b* a/ J) a# k( r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, n: M9 c, y5 m G2 R9 j7 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ ^$ s# f1 ~1 h- _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ S9 }5 j7 o% u m L6 j - ) r. X0 C; L4 }( f1 {
- dma_addr_t dmaphyssrc1 = 0;( O* Z; g( \0 g- A2 X- K R
- dma_addr_t dmaphyssrc2 = 0;! [9 W/ f4 _* h- h
- dma_addr_t dmaphysdest1 = 0;+ x3 ` x7 M; A& A/ q
- dma_addr_t dmaphysdest2 = 0;4 R; d- m. d1 [( R2 ~
) [; F" `2 e n* d8 f [- char *dmabufsrc1 = NULL;
3 m1 p5 W0 |: q$ W2 @ - char *dmabufsrc2 = NULL;1 u: b! u( T E+ c
- char *dmabufdest1 = NULL;
3 E1 y! g" u3 q/ h - char *dmabufdest2 = NULL;
z5 A( j6 F5 \6 F5 L( R' a
! I& M1 Q4 q: W% R6 B+ y( R- static int acnt = 512;1 ^- f- u" M; @) L- h m/ H
- static int bcnt = 8;0 ]3 I2 A7 o2 C
- static int ccnt = 8;0 X; M% e5 w8 {% @/ C; _
- - p# k @( ?& ~
- module_param(acnt, int, S_IRUGO);
" S1 F9 y/ r v# o! _/ y1 s - module_param(bcnt, int, S_IRUGO);- Z* }4 f3 ]; K! p( h
- module_param(ccnt, int, S_IRUGO);
复制代码 . T9 n, \4 B5 F3 N$ |
0 y5 ?# a3 X: G6 {2 ]( s: k 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- g1 A# P- q' p# r! h) y
arm-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 {8 P" x% N/ _" a! R. G# E/ b 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* r3 V1 i$ L; k9 ]' b' a$ J% A y- U" B3 K+ a
! C W! F: E k: O$ J, b5 k' Z
|
|