|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 O4 Q/ ]4 _" [7 m6 g
- [code]EDMA sample test application
$ g1 O+ _' h3 p0 ^ - /*
" V5 l2 u2 X- W - * edma_test.c
# I7 d1 K; F* j& j" H) m! } - *
) c' a. a6 \6 i: j3 R/ Z' F" }/ [ - * brief EDMA3 Test Application
) [' v" w! W9 \ - *
) ]0 ^; f+ S3 c5 K - * This file contains EDMA3 Test code.
& L) U4 y" p0 \ - *
4 x- c% ]( z0 m1 @8 [* {& ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ R; j2 M8 q3 E$ a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 p6 g( |5 F! } - * TO CHANGE.6 _2 ^1 u. }1 Z9 d; @! i
- *
. L$ I' h( x! \' i: p- j/ J) ]. T* T - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- M- \9 J3 Z: x% a% P$ ]4 c8 z
- *
7 a5 ]7 r" G; ^4 z4 j - * This program is free software; you can redistribute it and/or) J% B2 V7 H( o) s8 h
- * modify it under the terms of the GNU General Public License as& W& h2 [' B& S( s% ]6 r' C8 s* [6 [
- * published by the Free Software Foundation version 2.* r k- X" ?/ x$ C1 Q* U8 g
- *
; F: P* L; w! j' _* [/ X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* M& r/ R1 _5 i: Z- u# x2 E - * kind, whether express or implied; without even the implied warranty
4 \) U9 b' [9 k, e# x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* K2 m; F5 i$ W6 { - * GNU General Public License for more details.6 R! j2 M" v% w! w; l- |1 }; v
- */0 s [ \$ g) U) h' m
- 0 f. k4 Z! U! g8 k
- #include <linux/module.h>& F- m; i! S1 P$ r8 ^) k5 s
- #include <linux/init.h>5 M8 s1 @: V! H- o$ H+ a/ d) M
- #include <linux/errno.h>
! q$ j3 P, I( r$ A; B - #include <linux/types.h> W8 C" W! F0 q+ ]8 j" n$ V
- #include <linux/interrupt.h>
4 Y0 ^; E9 r) i+ |7 P7 f - #include <asm/io.h>9 w+ V) J* T* _) B
- #include <linux/moduleparam.h>
5 F) r3 t! K! h# ^2 h/ J2 U - #include <linux/sysctl.h>
1 u) r' v9 [$ ~/ s+ z - #include <linux/mm.h>
- `4 n2 g$ E& e - #include <linux/dma-mapping.h>- @; o1 v% f" M, p8 Y, `
9 {9 N H: V4 k8 c9 u# F- #include <mach/memory.h>+ ?0 m; ?' d+ {0 g# x3 m
- #include <mach/hardware.h>
$ e* `1 l7 J+ W5 k) h' w* A - #include <mach/irqs.h>
/ E* r# _! R6 S+ \# a* r% e& G - #include <asm/hardware/edma.h>
0 w$ F5 X8 d, `8 e1 F- K& F0 [
; `& F2 c" b- d9 r, b/ n. ~- #undef EDMA3_DEBUG
+ Z0 c5 l$ N4 D0 ^; c - /*#define EDMA3_DEBUG*/
! e7 Z3 c5 y& i - O3 j, i6 a( |- }
- #ifdef EDMA3_DEBUG" y. q- x' O* |& a4 |/ B) r( y+ o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' L( M- X! x5 T
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 a! j' m r3 N - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 U0 V' F& w1 Q. K; K; R - #else
( v9 x$ h' T% Z( n; I! J0 [; x - #define DMA_PRINTK( x... ), L6 o* Q7 |6 ^1 K+ D/ y4 m! c1 R' u
- #define DMA_FN_IN( Y2 A( {! Y6 G6 F+ I+ x+ }7 i9 G
- #define DMA_FN_OUT
: s7 m6 X |& s3 W# I& K. [3 M - #endif# z+ F6 B }2 y3 g
% F0 ^$ d) O# m3 H& ~& F- #define MAX_DMA_TRANSFER_IN_BYTES (32768): ? U. b$ {0 P/ W2 V* P) ]* j
- #define STATIC_SHIFT 3
: [; o# d9 i* @; ?$ j" ]# a( f3 u - #define TCINTEN_SHIFT 20
9 j' ~ V$ x/ ]. N - #define ITCINTEN_SHIFT 21/ |( d$ |* \ t( Q) g
- #define TCCHEN_SHIFT 22' b$ b% a0 e1 Z& V7 k' F
- #define ITCCHEN_SHIFT 23
! B2 f/ L8 L0 _( H' Q1 o4 g7 {6 R4 Y - 1 \1 ]: ?& R% V
- static volatile int irqraised1 = 0;
& ]+ |" _, u. @( I+ a. v8 V - static volatile int irqraised2 = 0;8 k% c2 w l' w: n: @& s' C
: ]- n4 w+ N4 R9 w# ^- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) O/ q7 ^0 z. c4 f$ R) i$ n - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# e) `8 F" U' R+ e+ z" e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ i$ ?7 N. ^1 p) p- X9 N; \
- - }6 a& t+ }; q9 A: G+ @
- dma_addr_t dmaphyssrc1 = 0;! [- x# I) w: |& ~0 K) b6 c
- dma_addr_t dmaphyssrc2 = 0;
1 E& O* p# Y/ R% v9 l: s - dma_addr_t dmaphysdest1 = 0;$ m2 E9 K3 ^9 P& B
- dma_addr_t dmaphysdest2 = 0;
' n& [% o3 E0 k Q- A+ U7 {9 _6 o4 i - 3 c0 K5 y1 R/ [& t' k3 j! n
- char *dmabufsrc1 = NULL;4 P# f+ N3 b( F# B
- char *dmabufsrc2 = NULL; x( ^1 I4 e. {; z: n
- char *dmabufdest1 = NULL;
9 x, }- \* _) h& c3 g - char *dmabufdest2 = NULL;
+ L: d$ ?: T& N3 G - + X- x: S2 \. Y$ F. J
- static int acnt = 512;# m/ ^( w# l% l" z& Y l5 U$ T
- static int bcnt = 8;
1 f6 Z8 j6 C. W - static int ccnt = 8;* }, t! {- z9 I1 b) t7 F" e) X
/ b5 G8 ^6 g3 {- module_param(acnt, int, S_IRUGO);
3 w- d7 Z! k0 C" v, T5 o& g$ f - module_param(bcnt, int, S_IRUGO);
( h+ g: b+ d0 D& N) x - module_param(ccnt, int, S_IRUGO);
复制代码 6 i1 L3 g% E6 f, D
( r4 f5 x3 m3 y: ^* y
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% {) x: B& u( w( }+ m5 z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ q! l5 [; \ N: N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( E: l# S$ B4 X! X, V% I( T, W
4 ^: T k! o5 M4 j H& ]6 Z! Z. O; a# `
|
|