|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* E" M: L" N! @3 K; C- M" S- [code]EDMA sample test application# B7 P @) T9 _9 l7 j
- /*/ H; [+ n% [) _* h1 z; T' n
- * edma_test.c9 B1 K+ ] m6 ` e2 S
- *4 d5 j5 L. q0 @: H
- * brief EDMA3 Test Application& M! _* q7 q* P& E3 r4 V1 ^
- *
1 e! a9 S0 L; J- M/ J - * This file contains EDMA3 Test code.2 n. n v8 Q6 t( p. ?* F% m
- *
# J, C6 O! W- u: r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; b$ V* {- O$ K, _1 W& j, C% Y4 H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( P6 ~6 J+ d) c0 v - * TO CHANGE.
; W) ~! v7 S! S) U$ e$ H! c* R - *
0 r$ l- p+ s' h4 W0 \ ` l - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 y1 Q0 ^7 C( |! L$ K - *; y# [$ W" g5 \
- * This program is free software; you can redistribute it and/or8 S* G" D. Q4 W' t- ~. W
- * modify it under the terms of the GNU General Public License as2 I: n! @# g, q" T V% m
- * published by the Free Software Foundation version 2.
" b2 _* x( Z/ A* h x0 U0 H3 m - *
/ E: e+ f0 S1 G9 N/ E" i* E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
P( v. x# T( l - * kind, whether express or implied; without even the implied warranty
$ f" D, U1 r4 X1 q7 ]2 q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% O$ J: n- n& f/ Q8 L) u9 G1 `0 e
- * GNU General Public License for more details.
8 A, o. b6 v* h+ [ - */
) s6 t& e( M8 w0 c+ N4 F$ J3 { - # d+ ~/ C. E6 N3 S3 \# q
- #include <linux/module.h>7 U$ L6 E c( R9 F6 o
- #include <linux/init.h>
6 H" d) u4 d" s' \. H' w - #include <linux/errno.h>
* A! {4 {' W/ y% b6 W4 l$ T6 h - #include <linux/types.h>; r3 O9 H8 T$ W
- #include <linux/interrupt.h>
* k/ R6 `+ I7 y" L - #include <asm/io.h>
7 u+ u j: y3 V: P! \$ w - #include <linux/moduleparam.h>" X/ n. |" }1 V9 u0 S( n
- #include <linux/sysctl.h>
+ g$ u- Z0 E2 Y/ O% j! q" j - #include <linux/mm.h>3 G2 {. C9 d! O0 q* f
- #include <linux/dma-mapping.h>
% D: R! i* i I5 [ - : W" m% g9 U Z( i3 F5 ^
- #include <mach/memory.h>
. p1 H9 {# Y; q: n* P - #include <mach/hardware.h>
$ _+ _8 h9 J4 ?( A, u0 @ - #include <mach/irqs.h>+ k0 [: {, i* P3 Y- w5 @
- #include <asm/hardware/edma.h>
' F8 o6 \, U4 I5 M( K8 K - + B1 q, a- K/ ^4 o* N
- #undef EDMA3_DEBUG. a7 N8 q/ W- b7 _7 o l! [
- /*#define EDMA3_DEBUG*/
3 r; F' s$ W0 W, ]% ? - 5 m9 G/ e0 D: h5 a+ P
- #ifdef EDMA3_DEBUG: e+ R6 v5 `% z# x5 _
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 K/ c" N p* n* }! k: C
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' I* l& s; d5 z0 u x4 j% \$ T8 V - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 F' @' ?7 q3 [, t5 i) A - #else$ }4 \. z7 N3 R x0 }+ \
- #define DMA_PRINTK( x... )- x, P, _+ h8 ^0 N" C! I; J" J* Q
- #define DMA_FN_IN
3 k3 z) T) `7 g, L: x - #define DMA_FN_OUT! C* ]3 q- {6 \8 U; r
- #endif
( S' x! c4 l' J( [, i9 a
$ Z, C9 _ ?0 N K+ p- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 c9 s" L9 Y' d0 e2 T3 S9 l5 A3 N
- #define STATIC_SHIFT 3
# {& x& j/ F: V; {' E5 ~% f - #define TCINTEN_SHIFT 20
5 Y' Q: d% w9 Z+ T2 }$ l0 R, j - #define ITCINTEN_SHIFT 21
6 F: b; O2 q3 s! k: B$ k - #define TCCHEN_SHIFT 22
4 U' r# z9 E5 x! x6 G; i+ C9 \ - #define ITCCHEN_SHIFT 23
/ Z0 [* D6 V J4 _- P - & R- Y) }8 T+ ~7 t4 U# y) A1 C7 O
- static volatile int irqraised1 = 0;4 f% H- \* n' W0 ]5 W2 C8 O* j
- static volatile int irqraised2 = 0;
% K( z( d3 |2 f9 A* f) N& B - , M$ S1 {; C2 E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ _7 Z0 y' O$ g# f - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& j" Q6 Y7 L: r9 x8 k1 e. r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- e, @. W) \; D1 c6 G5 f - 6 j5 N7 c$ z$ G+ g& ~1 `) x
- dma_addr_t dmaphyssrc1 = 0;/ f8 @+ K/ \: A! V
- dma_addr_t dmaphyssrc2 = 0;& l. D5 w1 A( ^* I8 _( _
- dma_addr_t dmaphysdest1 = 0;
- n$ }7 v# C5 c& \# | - dma_addr_t dmaphysdest2 = 0;
5 I4 N( w( E. [0 f* }6 E5 a$ m - - E+ ^. H w- K/ Y0 i- o9 W. n
- char *dmabufsrc1 = NULL;" A6 r" ^; u: X% D- r
- char *dmabufsrc2 = NULL;
1 `, E( q s, H' \/ b2 c) D - char *dmabufdest1 = NULL;
X; c* j& t% G1 V+ r+ \ - char *dmabufdest2 = NULL;# Z" V4 o+ w: o8 s+ m+ t3 n+ S3 y
" i( M6 b- V3 A8 [5 Z! M$ V- static int acnt = 512;( J6 V8 ?7 S5 s; j/ R9 @
- static int bcnt = 8;8 r: Q6 ~* l! g
- static int ccnt = 8;
( v8 v" \0 d9 j4 Y4 U q
7 u8 x1 w l7 V6 q8 w- module_param(acnt, int, S_IRUGO);5 h6 a8 y6 a7 c" M) @
- module_param(bcnt, int, S_IRUGO);
- [% s& U: @4 }$ Z; j6 B - module_param(ccnt, int, S_IRUGO);
复制代码
[: L o5 D. z7 u( R- J
' ^7 G1 k9 p& E) ]# C 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 J$ C; K& g! o U; D7 ?! Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 z& d0 @5 }7 Z' t4 o' W2 T. y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 t4 r9 ?, `3 N, N1 \5 L6 {
0 n; F" r4 d l5 o, B; H' t; J
1 S* V2 W. f' R; g |
|