|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; h9 I. H: v" v) H
- [code]EDMA sample test application
$ p* S( T0 R$ v) p4 U/ j - /*5 W. o5 [" x. {
- * edma_test.c
" T# A1 C W4 o4 ]# F - *
% l, [: T# ~0 J3 v+ J0 E - * brief EDMA3 Test Application' o" P: s+ U. Y2 G" p" t! c' @* V* U
- *$ P- `1 Y+ C+ I' g* ?" X( Q9 N
- * This file contains EDMA3 Test code.
9 f( ]7 F8 V- b8 H+ x5 e% [* g3 n - *
- y& l, e+ c% _9 X - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE o# A& E0 H! I6 ~. y* R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. G! v, x* T* F. n - * TO CHANGE.! a$ A9 s' H5 t
- *, j! T& h& r: K0 J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 M) `+ C2 I/ U6 p3 s; x
- *
$ t' x' h' q1 Z) D) p - * This program is free software; you can redistribute it and/or
9 W; R! x2 r1 u B- n - * modify it under the terms of the GNU General Public License as
+ y+ D9 I/ R+ t% h' v; C- s - * published by the Free Software Foundation version 2.* I% G' h9 a9 W+ h- F5 ~. m+ h
- *! [ z6 b7 F/ Z1 T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: H3 U; l/ F+ d9 @) j
- * kind, whether express or implied; without even the implied warranty8 o* {: i5 H' C' O8 n6 Y1 f3 s+ J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: H2 a4 [. |5 R, [2 P% {! y - * GNU General Public License for more details.
" u& f( h! S1 p4 p/ u# M9 D0 D - */4 M( H$ G1 w. ~; ^# j3 _/ h
4 w# v j8 o6 _, B' t! b- #include <linux/module.h>) ^3 m6 B/ H- H2 q0 U S
- #include <linux/init.h># t" G5 o% S z) V/ j
- #include <linux/errno.h>1 V) ]: ~7 K4 {( g6 s" c' i! `2 d
- #include <linux/types.h>
/ x- U( v) N- N: ?# u - #include <linux/interrupt.h>& l3 z5 H7 w% @5 z. n. G8 T2 a
- #include <asm/io.h>
0 |: D; D% ?% @! c - #include <linux/moduleparam.h>4 z# H& Q9 |0 d
- #include <linux/sysctl.h>- P5 e2 {- X3 |$ ]& H
- #include <linux/mm.h>
( w# x8 t: I" u8 P - #include <linux/dma-mapping.h>
- W; q9 K+ T0 _' M8 s - ! G- \0 B0 @" T4 C4 i$ m
- #include <mach/memory.h>
$ O* ]3 }) F' b4 K2 w - #include <mach/hardware.h>
, m) Z# c1 b [8 ]8 s7 I& y - #include <mach/irqs.h>8 @. j- O- q, [ A' q
- #include <asm/hardware/edma.h>
3 L$ ~: k/ K' E* i% X# ^8 ^ y* x2 I" P
/ Y, M' A3 W$ b+ K. \/ l, }- #undef EDMA3_DEBUG) h5 I" d6 O8 V, c
- /*#define EDMA3_DEBUG*/& \2 H; z1 e( Q c2 P4 U; X0 C
' h$ ?0 L. w0 I0 T% m; m2 j- #ifdef EDMA3_DEBUG
/ r8 r7 _% d( e" c4 n! ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& ]% |, A C7 f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)( u w% I0 M) w( }# R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): T: k8 F0 U" c4 X$ R" y* U
- #else
+ {! E( e, p1 h9 [" h0 t# C - #define DMA_PRINTK( x... )
" _$ p" i0 P: ^ - #define DMA_FN_IN
% F }* I2 J5 U5 a7 ^! S+ A- q - #define DMA_FN_OUT
& t5 E! b |0 U( }& J9 C6 `: O4 E9 \6 Y - #endif4 \& K$ l3 o8 m! x) L
* K$ P! ^7 g* X6 `# f( \: Z- #define MAX_DMA_TRANSFER_IN_BYTES (32768), i% C; ~$ x) d1 E
- #define STATIC_SHIFT 3
5 u5 L% L7 C8 D- P% b" \. U - #define TCINTEN_SHIFT 20
! e# _+ j0 G# g( { U! r - #define ITCINTEN_SHIFT 21% J/ x2 `1 F9 o7 Y& ~2 X7 `6 G
- #define TCCHEN_SHIFT 22% ?5 y0 M1 n$ A; P( O
- #define ITCCHEN_SHIFT 23
7 T# q2 t. s; f1 O1 J% p - . C ^4 @) P2 P' R% g) o6 S4 e s! a
- static volatile int irqraised1 = 0;
- ]; Y( q0 S2 T" F2 W - static volatile int irqraised2 = 0;; A: w( o$ n: @5 m
& `1 L3 O6 V/ J; Q; D' \- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 m6 Q ^; s& T$ m. p8 C - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! v4 l9 L: P) Y3 D: {
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# C7 Q3 R! q. A% M$ J
, W5 P5 h! e$ l B+ b+ S9 n- d- dma_addr_t dmaphyssrc1 = 0;
a+ t3 N0 \/ u- _- W7 n7 _ - dma_addr_t dmaphyssrc2 = 0;
! j1 H7 o. y) I7 [' ` - dma_addr_t dmaphysdest1 = 0;- b* X1 O9 y6 A- H
- dma_addr_t dmaphysdest2 = 0;, z5 ?, a; `4 d5 S% g
- 3 g4 F! U) c( `2 O
- char *dmabufsrc1 = NULL;
/ `* v4 u; }$ J: S - char *dmabufsrc2 = NULL;
. J2 H6 U+ E! I6 \8 y - char *dmabufdest1 = NULL;
0 S8 S/ p; W( M n; K - char *dmabufdest2 = NULL;3 T [0 h/ f) Q a [/ {0 b( G
0 B0 Z T+ c9 I' v U5 s, E3 l- static int acnt = 512;$ y! i6 v5 p4 I" Y4 Q2 {; U
- static int bcnt = 8;4 n4 E- F& Q* S3 n1 D( l- q
- static int ccnt = 8;
; t5 `6 W' f. Z; N2 C- q& F" H! F" p" R
2 z6 Y ]: Y$ [- A2 K4 v- module_param(acnt, int, S_IRUGO);. j8 y) K! E5 `! d9 Z) i. E
- module_param(bcnt, int, S_IRUGO);
7 {( ~9 U- K7 t+ }+ d& H+ P - module_param(ccnt, int, S_IRUGO);
复制代码
7 g! K1 t3 s3 L) {% l. W- i `/ F& P" j7 s& A0 z: |* m3 W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' d& z1 S; B7 e8 g. M/ qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) G- o4 ]* S. Y$ Q% j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* `; c/ P3 F9 ~+ w5 n* M# Y! Q- \* Z( a1 D% j- |! ^
! g3 Y) |4 }, G, ~
|
|