|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 B. h& c; ^$ C- [code]EDMA sample test application) O% i. n* l' T" r4 B# m3 i, Z3 t
- /*
1 \4 i3 M+ Z! Y# A( e - * edma_test.c
3 S7 ^" [: v1 d. ` - *
$ o4 j; O P7 ]6 y - * brief EDMA3 Test Application4 y V$ u3 j0 S0 y. w4 G# }
- *( h- f. X. E* c4 q
- * This file contains EDMA3 Test code.
& r" |$ T% e) |: V; P3 e: d - *3 w( n/ H+ n# {0 Y: T K0 A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 c3 ~7 @) A, A4 _' T5 q. Q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 A' @0 C9 ~9 y- ?4 D - * TO CHANGE.0 k: B6 o$ E$ h$ s( L# \; w6 y( _
- *1 v6 r4 w/ J0 ~' l* r2 O% X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 v' r/ d5 v3 Z# k* Z
- *
' @0 M) i! ?* b. q. u - * This program is free software; you can redistribute it and/or% p, W7 i, } _0 H. z8 C4 }
- * modify it under the terms of the GNU General Public License as# Z2 X' H# [$ |: @% v- S- F
- * published by the Free Software Foundation version 2.
2 J. Y$ p+ `* h* _3 J( u - *9 I; U2 v0 X5 k7 l
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any/ [- {% i6 l: m% U( c
- * kind, whether express or implied; without even the implied warranty; n1 M3 ]9 X7 z/ H% s* H6 m/ U9 @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* t# n( M# q6 u" [7 @ - * GNU General Public License for more details.
r/ J0 ^* G, {$ H - */% c# t" J& T3 V. ~3 m6 {6 z: L
- ( d, n8 @# {: O+ k" Q2 @9 R) q; U
- #include <linux/module.h>7 u" C5 S- v/ B
- #include <linux/init.h>
Z$ R7 E5 _9 U. G6 C, {0 E- n9 ` - #include <linux/errno.h>
% e5 A5 k) t, u1 z& _ - #include <linux/types.h>( a7 x4 E$ F/ Y0 u
- #include <linux/interrupt.h>: S7 ]% T% O' m) L
- #include <asm/io.h>
" X! v, R2 v* b6 r2 ]7 \ - #include <linux/moduleparam.h>; j: @* f0 J E# y: V4 p
- #include <linux/sysctl.h>" E% n* q' I5 A& H) Q7 U
- #include <linux/mm.h>3 q- a- s& _, D$ S
- #include <linux/dma-mapping.h>
$ y% |8 a# o6 v% Y- \ O4 j - ' a% ?9 c7 y% \ d
- #include <mach/memory.h> V6 F& A% K3 b% R8 Y. Y! ^* G
- #include <mach/hardware.h>1 k0 A7 ~- i( r/ |. z
- #include <mach/irqs.h>; b# G8 E; I$ x: B0 j0 H6 w0 W
- #include <asm/hardware/edma.h>
9 ?" i+ Y( Y) T! d" q- @ - 9 D/ k l2 j. `8 v
- #undef EDMA3_DEBUG
! H+ e( `. O! U3 _ - /*#define EDMA3_DEBUG*/& V5 [, m5 _: R
- 1 j4 [* X( r3 l* t2 M
- #ifdef EDMA3_DEBUG. J% d: [4 c N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- c$ @# _. U' L* |1 O7 i; P
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 c2 w( w( q/ Q" b3 Q4 j - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 x5 e% H9 P: X - #else( J2 ?, f+ J4 L& U8 q# D
- #define DMA_PRINTK( x... )( O1 r3 B. C: e0 \8 |3 \
- #define DMA_FN_IN
% x$ F8 {' ^6 O: ~0 d - #define DMA_FN_OUT
0 i! ?, ^) M* {0 V7 { - #endif1 |& H7 i, ?7 W+ L2 v e
- & E/ B+ @' F; y4 e8 O7 [; ?
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 ~) @1 d( x# A$ @ - #define STATIC_SHIFT 31 L- f9 x8 f& _/ x# ?+ _ c
- #define TCINTEN_SHIFT 20: t: V& M5 {; K6 p
- #define ITCINTEN_SHIFT 21
. `7 j% I# ~! h$ B6 E1 l0 K! M - #define TCCHEN_SHIFT 222 k5 a% q( l" N" U q
- #define ITCCHEN_SHIFT 23% P8 e3 V7 ^7 ]+ g" _8 P
* @: @0 E2 k4 M* Y- @4 w+ S) S- static volatile int irqraised1 = 0;
5 {) z4 V! P: h2 x4 G8 u - static volatile int irqraised2 = 0;' e: b) |# t( Y9 f/ p J
- 1 r4 _2 v6 Y {+ i+ a
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! q# `& i& s7 w3 z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* K3 o4 ^% i* s# N! h p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. A* _; |; ]* W3 a6 A
& @# i8 o5 H# S( P- dma_addr_t dmaphyssrc1 = 0;! W+ w. \8 w( s( Y7 \" T8 y
- dma_addr_t dmaphyssrc2 = 0;
0 x- ~, A3 Z/ ^6 R+ f3 o0 [8 W - dma_addr_t dmaphysdest1 = 0;8 f* ]; Q, n9 p! S
- dma_addr_t dmaphysdest2 = 0;
8 F8 C' M+ ~; W( g3 S2 V - + ?3 u' u9 w5 ~- ~8 d
- char *dmabufsrc1 = NULL;
/ M \: o; A- K% q( e e% h - char *dmabufsrc2 = NULL;2 ^, ]# p/ A+ T
- char *dmabufdest1 = NULL; `+ o' l8 V. S
- char *dmabufdest2 = NULL;
1 |0 d: D8 ~2 C w9 m7 R. }8 L
( ]7 w6 P2 O- P6 e; S! n: `- static int acnt = 512;
! x! d4 W* y ?9 g6 {$ r5 } - static int bcnt = 8;
: v r1 U6 S! c! C: v# ^1 e) d5 E - static int ccnt = 8;0 |: g/ C$ x6 {3 o: ^3 Z
& q- C" x. t1 e6 G0 e; g6 A- module_param(acnt, int, S_IRUGO);6 c; L, U' ~* y, @" |; F& G
- module_param(bcnt, int, S_IRUGO);- f# D1 ?- T+ c1 \" l: W
- module_param(ccnt, int, S_IRUGO);
复制代码 H. f/ u$ I( ]1 h
0 U) A2 P; l7 l0 z: W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 I/ X6 P' T" S/ I' t! O
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- R) Y L8 n4 ?$ ~) d8 x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" H) M% H0 q `* T, w
3 l! @/ x1 N$ p N& ]2 d. s9 t( W9 h; C. d
|
|