|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 s% O. C/ D; O- a |% X7 L; g- [code]EDMA sample test application
/ k: f# Y5 b/ @3 r7 c7 U - /*' M: C6 z# f, J* p' d2 E
- * edma_test.c
$ t9 h1 r/ Z. B+ c5 ~ - *
+ w! d' p; w- H# z6 i - * brief EDMA3 Test Application
, g, J4 U; D) \; J7 k. u6 \2 B - */ d- Y* R" O" T, }9 ^2 \
- * This file contains EDMA3 Test code.
( g; e3 V- u7 i$ _. Z- z4 h; G3 R - *
6 H2 |1 D% i0 K4 l) O) ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, H' t3 i3 k1 W3 i - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 L' U2 a+ j" E( s# O# {+ ~& n2 c
- * TO CHANGE.1 x3 E7 F$ V( d9 r
- *
! c7 F5 n A; T% i% R4 P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
G2 j8 J4 R% u; e% M3 C - *- K' [/ v+ S8 S
- * This program is free software; you can redistribute it and/or
5 H( N& I# v2 O# ^( ?/ F - * modify it under the terms of the GNU General Public License as
9 [. b6 g; V( m5 e5 l h# U - * published by the Free Software Foundation version 2.+ i% e# H) s& ^5 _
- *0 a3 P$ W, L( b4 F
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ j+ Y i6 C, @/ N9 C) N - * kind, whether express or implied; without even the implied warranty- N3 z; |4 O5 g% Z- p
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& E! b' x+ e& E
- * GNU General Public License for more details.
4 k5 M5 X( g: n- w' |. t* j - */$ z* H5 T8 F/ m; M0 b
- # D* n* L: ]$ H2 W; D2 h4 z. }
- #include <linux/module.h>% \' z0 u) K0 {& f# Y+ Y
- #include <linux/init.h>
3 [5 x# u( ]$ P2 |; S0 V- N - #include <linux/errno.h>3 B: s( P( B4 ~6 D9 t5 }6 E
- #include <linux/types.h>! D9 g9 q1 k7 I9 s, Y
- #include <linux/interrupt.h>
2 S3 j" F6 H* m* H. S; ~ - #include <asm/io.h>
$ u: H2 s2 p1 U1 J9 ? - #include <linux/moduleparam.h>
/ x3 f- @4 h$ A; M4 S - #include <linux/sysctl.h>( O9 U$ U% W0 I- ~ M9 l2 A5 K8 \
- #include <linux/mm.h>' ]2 ], \4 N3 T
- #include <linux/dma-mapping.h>
7 S' A3 y" C0 m$ D* H8 _
9 E1 {9 q4 B6 \( V, T2 ~* t- #include <mach/memory.h>
- j, Z' V; }; @5 P - #include <mach/hardware.h> S& g# V) o5 c& F0 t9 H
- #include <mach/irqs.h>
8 }6 C, T, z# G4 R4 s - #include <asm/hardware/edma.h>
: Z2 R0 a: f3 f; s
5 ~0 ~7 `* \$ g. F5 y( @- #undef EDMA3_DEBUG
* \9 n$ P/ D" S6 @; A - /*#define EDMA3_DEBUG*/
" v0 X/ m3 i" C - / T& r5 _0 v# D9 T) @3 n) s
- #ifdef EDMA3_DEBUG
* P* o$ K1 i6 ]/ {' H3 v3 u - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& Y U3 d4 ^- J- h$ E6 ` - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ G! f/ O- t# T! d9 K2 y0 Q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% ]$ ?" F! f. c3 N5 q+ t1 R$ }: ]; O0 I
- #else8 b4 i3 F. Y. g" u m$ ~5 X
- #define DMA_PRINTK( x... )% U9 k5 X% n W1 y; Q$ [' m
- #define DMA_FN_IN
# [4 R4 K3 n; x' O; Y, v& p: c# o - #define DMA_FN_OUT
2 {, A/ v* n! H - #endif3 B: \4 X0 m+ N' P9 H$ w
- % T0 w9 c, a! @7 e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 |; w6 f- |3 o7 S/ S3 }
- #define STATIC_SHIFT 3
8 j- b6 A6 m8 @' U0 O- o* M! p - #define TCINTEN_SHIFT 20
. M& ^4 b) ^% L9 c* l2 b: i) ^ - #define ITCINTEN_SHIFT 21
3 X/ S+ K- F- K A( t - #define TCCHEN_SHIFT 221 G( n( j. G. l$ p1 }
- #define ITCCHEN_SHIFT 23( Q$ {/ o/ W: |- `. c, C0 X; W8 f
: L2 a, c6 h5 o$ t. b* A* i( @- static volatile int irqraised1 = 0;
7 _8 C+ @9 R- W - static volatile int irqraised2 = 0;
0 L9 V0 [) s: k: a" a
/ T6 N8 e/ E0 p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 H+ x2 ?# V! T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 ~8 l, v7 j/ u4 Q' M1 @ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' L$ E; ?/ Y! @, S) w) h3 p" d
- " O# u' U; f* i' P
- dma_addr_t dmaphyssrc1 = 0;
. b W% x& r$ p" r, q3 R$ O. Q- C - dma_addr_t dmaphyssrc2 = 0;
3 E/ L+ X* h4 l! Z7 s) H) j" ]' J - dma_addr_t dmaphysdest1 = 0;1 h5 f* k6 z6 L2 i0 w$ P6 [
- dma_addr_t dmaphysdest2 = 0;
! [; M% H3 O! o5 y( B - . u) j; |7 u7 ?1 M% ]; R8 u
- char *dmabufsrc1 = NULL;9 @$ L9 O! [. f& i
- char *dmabufsrc2 = NULL;6 \9 i r: U" d1 V. R
- char *dmabufdest1 = NULL;
" Z# ?7 ~6 Z. l; @$ R1 U5 g- S - char *dmabufdest2 = NULL;+ z" H) w% [, b" t) E, \ I$ u' B. { b6 \
- * d* t/ P4 ^5 V# r: o1 S0 k: m* Y
- static int acnt = 512;; V9 i6 ^; g+ r- J3 n
- static int bcnt = 8;; X7 M$ i% |) t3 w' ^
- static int ccnt = 8;* A$ ]# Z: S& f' E0 _ B
" x: B4 B" j& _0 V% k- module_param(acnt, int, S_IRUGO);$ `7 Q( P6 F4 n& i) D% l g
- module_param(bcnt, int, S_IRUGO);
- Z; I/ [+ x1 s+ Y - module_param(ccnt, int, S_IRUGO);
复制代码 % }7 L' d) U+ |( P0 p9 G
* U% R0 v) m- z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ U% Z4 p. v3 U& W' p% ~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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。! W9 Y7 S+ V# G. y2 ^# w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, }$ M7 A* g% N6 z6 t: \7 K" L
1 @2 a2 x5 M$ ^0 V+ f
1 k1 J0 m; K+ ~4 C- m5 r |
|