|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
' E& @- ` B) B7 J; y! ]- [code]EDMA sample test application7 O7 f- K* ?8 Y) s3 p7 @
- /*
8 k: o( o/ f* A- }6 m% [9 u' ?% |4 Z - * edma_test.c
! K$ G( _6 M, e% q - *
! t) |+ u. G' E' I - * brief EDMA3 Test Application8 n$ q2 u T. q
- *$ R* M) a* t3 i1 O" s; @
- * This file contains EDMA3 Test code.4 S8 Y0 h8 p9 h
- *
T9 o* _# h9 S) ~5 O" q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ I; E5 F0 l- [0 G F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& f6 T! C+ j! G5 P' u1 Y- A
- * TO CHANGE.: u' E$ m) I) q5 L. k t
- *: I7 G8 |' \- y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! b0 _) B: I# ^2 l% t4 F9 h0 r
- *- ^. p+ ~' A/ C! M& h b
- * This program is free software; you can redistribute it and/or% `2 V5 |3 n! B8 R
- * modify it under the terms of the GNU General Public License as/ S- \" d8 V9 ]& n
- * published by the Free Software Foundation version 2.3 s! [3 g. X" A, n' l) E7 ?: q
- *3 |/ f- J6 Q ^8 B+ i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" @( \2 Y |# D u/ l$ k) y - * kind, whether express or implied; without even the implied warranty
+ X( V9 a5 _1 k0 Z6 \# z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 |3 V' l* p' q" d+ R8 E - * GNU General Public License for more details.2 j9 h" s6 M; D& b1 H O# c
- */0 q: C% [$ x) x! B
# ^' H; d0 k& W9 Z5 M- r- #include <linux/module.h>; R( i4 W+ _3 O" }1 M# z/ v
- #include <linux/init.h>; q X) `0 @1 u' ~
- #include <linux/errno.h>
$ L d( W% O; e8 o% ]9 n0 v+ L5 D( z - #include <linux/types.h>4 \; R5 w$ q- M2 A9 H
- #include <linux/interrupt.h>2 ~" l4 u" L) V7 s1 g
- #include <asm/io.h>* P9 W l/ t! }+ j! U& q2 v
- #include <linux/moduleparam.h>7 B1 C6 A7 Y- d+ _/ x
- #include <linux/sysctl.h>2 \; {1 u6 @7 l7 u
- #include <linux/mm.h>
% \% T* w5 u5 L9 E4 I+ D/ S6 x - #include <linux/dma-mapping.h>$ h: ?" I, B* `! d. i D
3 Y& ]0 v; P1 Z( D! f) Q- #include <mach/memory.h>/ ?3 w( e# q. `5 C0 m$ C2 s! { K
- #include <mach/hardware.h>; X4 p: T% {* H3 `$ c" c
- #include <mach/irqs.h>8 r) m( W9 V$ e! ` p3 r
- #include <asm/hardware/edma.h>) u1 x" C4 E! N$ n/ c
- * m( I" P! T# ]* u4 U
- #undef EDMA3_DEBUG
) {, c C6 Z0 X& \' i - /*#define EDMA3_DEBUG*/' i2 u1 ?* b: \3 U
- 1 b& n( h' ?. G% X# c3 J8 |; e
- #ifdef EDMA3_DEBUG
, e6 e( J' m6 I- n: L - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 a8 A w9 M6 |
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
& _5 i( Y3 h+ r6 e' `% g' m - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# b6 u3 J) G! a/ \0 c8 d* W - #else" S( f0 c% I( e9 C
- #define DMA_PRINTK( x... )
% q4 W) w. p3 J% b8 F+ w4 L8 B - #define DMA_FN_IN. f$ k4 K: N' |0 X
- #define DMA_FN_OUT, `2 h6 F0 [/ {
- #endif& x* Y, }: |& j0 F) x' z* F
- 0 a! b( U9 B0 f1 E8 a& J
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% t; A9 D4 o; G; b$ y& F - #define STATIC_SHIFT 3
! b3 K, C# A0 `* D/ o7 B - #define TCINTEN_SHIFT 20
: F( F# W4 u6 e( k! n0 N" P - #define ITCINTEN_SHIFT 21% u+ ~# a' H: q/ D# ]7 g+ H+ [! T4 F% v/ |
- #define TCCHEN_SHIFT 22
: |( H! k% g1 G& [8 p% ?; Z - #define ITCCHEN_SHIFT 23( f! j) ?# p' F3 X9 e
% x- z; h/ f( i# M. i- static volatile int irqraised1 = 0;! S( ]( }# v2 S3 Y$ C
- static volatile int irqraised2 = 0;, P" `3 Y' M+ p/ y
- / X" X5 s8 H/ A! Z; I! ~# G
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ J$ o: Q$ w0 G - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 w2 r+ \! r& @! o( g5 _, J4 E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 N1 x `" x3 {0 A
- ) J3 U. r r& V. \$ F
- dma_addr_t dmaphyssrc1 = 0;1 L, Z6 V, Q/ w+ W& g9 S, `
- dma_addr_t dmaphyssrc2 = 0;
1 g( A8 G4 K) \1 s" g* S - dma_addr_t dmaphysdest1 = 0;
' U# C" v7 }: A! c* X - dma_addr_t dmaphysdest2 = 0;( L) A( p- B9 J: q
- ' k. E4 r z. [
- char *dmabufsrc1 = NULL;. m" H8 r: a" c- v( Q5 @
- char *dmabufsrc2 = NULL;
* H' h0 ]+ N$ r" N" ?3 s+ i - char *dmabufdest1 = NULL;: q e1 Z; a- a4 h; G9 P2 b
- char *dmabufdest2 = NULL;9 z! M, f/ |8 x) y8 l9 _' Z0 a
& q( G$ o8 V4 f* |- static int acnt = 512;
: J, |0 u. }# i: _% b: d6 p; r - static int bcnt = 8;
0 D* A9 P7 M! Y: i8 T' {& U - static int ccnt = 8;
0 M, }5 A7 L2 Z
% X8 x5 H+ D0 q4 y+ Q# H' M V- module_param(acnt, int, S_IRUGO);' b6 s8 G; ^9 N8 l. e
- module_param(bcnt, int, S_IRUGO);( {6 S b0 E+ N, Q
- module_param(ccnt, int, S_IRUGO);
复制代码 , V- ]' O" a& Z: k0 Q* v! Q7 T
# u6 ]0 J* e3 }4 b; H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# R% _0 s' B5 t; Xarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! l6 ]1 f, S" e% O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! m- S! A, c/ A3 l1 ^8 } J4 G
, H! W7 z( T3 ?# t: H/ I! k0 M& ^
& n6 P }. D7 F4 n |
|