|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# d- v( }, l, A6 R. y& \- [code]EDMA sample test application
( ~+ J' K3 V0 M: i! g - /*
$ @9 D* A& f( U9 d1 K# ?1 v0 W - * edma_test.c
! T0 L* w1 m/ ^1 Z; ^, q% n - *
7 _( R/ m; L/ ]' _( { - * brief EDMA3 Test Application% x9 [6 Z4 b- j; F; P j2 f1 K3 ~
- *9 |, m; m r; a* D) c# L
- * This file contains EDMA3 Test code.
) |4 K) a& W3 u' ~$ G - *: U. G n9 l$ w7 }( B+ R- C+ Z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- Y8 t @( W: e+ ~ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 v5 K# T5 T. p% m8 n
- * TO CHANGE.
3 U2 [. U, b. P - *6 r% t0 x* a l7 A; d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 a; d2 V( |( s0 q: b P4 H9 X# q
- *6 o- X4 s( f% M' z% R
- * This program is free software; you can redistribute it and/or
7 S' p+ c, p4 S& A - * modify it under the terms of the GNU General Public License as$ [1 K( Z( R, o; L+ J' K
- * published by the Free Software Foundation version 2.
# Y4 O1 ~, ]9 d) Z2 }6 @( U8 t - *- X/ q E5 R6 F0 Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any( O) B4 P0 H T7 z$ ~
- * kind, whether express or implied; without even the implied warranty
3 c) Q+ I2 f7 d* u9 ?, |+ s- x M" x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 Q/ Z& D7 ] c: L
- * GNU General Public License for more details.
+ u* v' g+ {4 e! Q& o8 r9 p( ^0 q2 _ - */
( I: s% s6 Q: J/ r u0 { - # a q$ g t8 N5 T4 ~, M# F3 |
- #include <linux/module.h>
# h( P) U3 T4 Y2 V2 P( { - #include <linux/init.h>
$ Z3 q: ]7 }1 b, B! _ - #include <linux/errno.h>
6 i* u5 h* S5 k! X. ~' l7 X - #include <linux/types.h># U. ~/ n$ i. Z/ D2 ]
- #include <linux/interrupt.h> Z. J1 t8 m% L. c% x& o
- #include <asm/io.h>! G3 q$ k" w6 w1 L7 }
- #include <linux/moduleparam.h>, b' y; S3 L/ O% a# Z0 Q) p3 Y; c
- #include <linux/sysctl.h>
+ c5 |* `( ^5 B& M' i4 R' ? - #include <linux/mm.h>1 ~' b( }, k) J& }: Y( K
- #include <linux/dma-mapping.h>
* v6 \0 F7 A# f' N - " \& D, u) @" `/ e3 ^, ^
- #include <mach/memory.h>0 U1 I% r1 l! Q- }* t1 Q
- #include <mach/hardware.h>4 v; o! K" M i7 N7 s! Y
- #include <mach/irqs.h>
$ R$ `8 H, W# O+ H n - #include <asm/hardware/edma.h>
( G8 c8 Y8 C( V! p; T F2 s - 4 `) D- h+ @4 `6 n3 ~6 V
- #undef EDMA3_DEBUG
7 _( u0 j" i: H P6 _+ Y3 T0 z I- a - /*#define EDMA3_DEBUG*/
0 m6 X- \8 \7 Z0 p; B% k - . N7 U; D6 J3 ~ Q3 w" F0 q0 s
- #ifdef EDMA3_DEBUG3 J7 h& i& S/ [* ? d& s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' } n) I. ]( s& G# |( x
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- H4 k n1 U8 T3 V& @/ Q" @ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 ^. }: p6 D; A6 K, b% x2 N
- #else" H' C7 p2 U1 _6 ?# j& V
- #define DMA_PRINTK( x... )/ n9 D8 M. v% [" e
- #define DMA_FN_IN# @! i4 [# e) r. {: s1 D# z
- #define DMA_FN_OUT6 i+ Y4 o. w @( r
- #endif
4 ^: K' ~+ Y& ~0 B: \: o* ^: t4 I
/ K$ } }+ K* ~: I6 V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 }6 p# e* _5 U3 Z1 _0 Y* q
- #define STATIC_SHIFT 3
8 O* c2 W" k" ?" X) Z - #define TCINTEN_SHIFT 20
]0 p3 l8 X( i. p0 Q% `3 @0 C" I \) E a - #define ITCINTEN_SHIFT 21
- V3 q: u/ E8 D( i9 n3 g - #define TCCHEN_SHIFT 224 I! M) R6 S) v0 d
- #define ITCCHEN_SHIFT 23
" r# i. ?6 k) `3 n$ E4 I, P" ~
4 |! l5 z. p9 O3 F X- static volatile int irqraised1 = 0;
8 K& x1 m) a. G+ ] - static volatile int irqraised2 = 0;
2 F: K2 Y; f* O$ C& _ B6 t - : W# `5 {& l+ F {! D7 u* [' K) s
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' k4 P0 d6 G2 r) ~- E: z$ i. @ [
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 w; g! S( Q. Z8 C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" \) G4 s } p2 ], ]0 d
5 ^5 h- Q( R0 Y& o' V1 Y- dma_addr_t dmaphyssrc1 = 0;2 Q, N, B! t& }) X7 w; C
- dma_addr_t dmaphyssrc2 = 0;
# U- Y: a* i+ \$ K; O - dma_addr_t dmaphysdest1 = 0;
' j( \( H& q3 H5 M7 t - dma_addr_t dmaphysdest2 = 0;5 }0 b1 h1 z% r( l+ m$ T! v
- 0 E6 ~- ~% T6 _7 }# G2 j$ F5 s
- char *dmabufsrc1 = NULL;& q4 j1 c6 ~! j: [0 b7 ~ u& }7 b
- char *dmabufsrc2 = NULL;/ h6 z" h" z% k' e9 ^+ v
- char *dmabufdest1 = NULL;
& v7 J( A+ l) u5 b: f8 I% Q' d - char *dmabufdest2 = NULL;. P9 |. q$ N& O n% f E6 Q
- 0 R( f0 z* _6 q- {% e, b
- static int acnt = 512;1 ~" c0 [2 @; K! Q" z2 |
- static int bcnt = 8;
8 S! j( s+ j" r! S - static int ccnt = 8;4 F9 l+ L9 P! t& [1 B
- 8 g# F5 M2 U- [
- module_param(acnt, int, S_IRUGO);
. I @, I4 c0 ?, E, f" k, v- ]+ J - module_param(bcnt, int, S_IRUGO);! [' `, p, K' @* X; ^) b5 ]
- module_param(ccnt, int, S_IRUGO);
复制代码
. {4 D( C8 Y; T8 Z/ _9 U8 i
* F3 E1 F( Q5 V$ @4 f 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& t: D' _4 Z9 I+ p/ m* F! iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) h$ \/ h9 I q% u7 [: l* y- S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* |. G: J) p' C& ^6 i9 ^% G5 [+ M$ C: B, d) C2 X
$ x [, H# ?2 a7 J+ P0 ^
|
|