|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 x$ i9 s+ u. F- Z
- [code]EDMA sample test application! u% F* r L8 r
- /*& M% w/ C, ^) G- O9 R S9 D, J) o
- * edma_test.c; L* y% Q" l4 T$ U; }3 G
- *
; x* I8 g" ]7 v: H$ V0 | - * brief EDMA3 Test Application0 k4 D- `3 S ~0 r% ~8 ^! m- V' k
- *7 `& y5 w% @: x5 C' W3 o& s
- * This file contains EDMA3 Test code.3 h" ~% L' f5 G) _% g7 T
- *
, c! w5 l7 Y* h# T1 k - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 w& Y+ _' O" @5 H- |0 m6 S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 n2 B1 ~% h4 w- s; Y2 l1 [2 k6 [
- * TO CHANGE.$ R- W8 P0 M0 o8 t6 A; a
- *
. Z) `4 D- m! k1 J$ m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. B5 N( t9 E) _* j$ |- k5 r - *- q2 u% R" K8 U& K
- * This program is free software; you can redistribute it and/or
- Z; f3 R+ \; G3 m" Y' I4 j' J - * modify it under the terms of the GNU General Public License as; u% `4 R7 k# G* K8 E Z+ b8 q
- * published by the Free Software Foundation version 2.
8 a& E7 z6 t, j y; X: } - *. I' k; k4 V* s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' @" \9 J' a8 u% U- N+ G3 a
- * kind, whether express or implied; without even the implied warranty
& q- |, E ~: @" \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% A t4 T' _& I( O$ K* E% c
- * GNU General Public License for more details.
0 V& D1 u0 _% X' X7 a2 E) ?# ~ - */
0 J6 n1 n, V$ K( t" a - , C6 z r+ y& ]6 p3 H$ M
- #include <linux/module.h>
$ c b3 x' H: @: {3 T4 N) m - #include <linux/init.h>
3 S' w3 P2 D5 D3 p( ~ - #include <linux/errno.h>, i/ W' ^# r6 A' u: G
- #include <linux/types.h>
- w2 f# d1 C" B7 k _) d - #include <linux/interrupt.h> B* a1 P$ A3 G
- #include <asm/io.h>
! g7 i3 ^% T' G' i% Z; [( I: g* q - #include <linux/moduleparam.h>
@- \: e: n& m$ W7 u. S! l - #include <linux/sysctl.h>
! d( H- D- K1 P% j - #include <linux/mm.h>
& U1 k% r+ F. x# J7 l. e$ O - #include <linux/dma-mapping.h>
; V: c3 R7 m% O2 ]4 S# w; _
+ j4 R9 W% R' B9 K- #include <mach/memory.h>
6 L, O# p7 A1 T0 s+ S - #include <mach/hardware.h>% V4 U* ?% \8 X, h. ]: z! u
- #include <mach/irqs.h>
5 s1 [+ y, T, T6 \2 P0 |7 u - #include <asm/hardware/edma.h>
8 E/ b, e! ^; g
' B; m% W! n( Y/ `$ m; t- #undef EDMA3_DEBUG2 Q/ H4 @; w/ I; m6 G2 d- I
- /*#define EDMA3_DEBUG*/
! h! y+ i; M( W' U - - ^$ B: B( X) o6 E6 h2 z
- #ifdef EDMA3_DEBUG3 l% o( \/ ]8 G$ B4 l
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 P3 x6 n/ U5 U& h \; j' \) W) `# _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% u |8 U u9 s. w/ p* f; O: `
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 N" B" ]- l; M2 n: x& @ - #else
6 B; O' t5 t; a0 R - #define DMA_PRINTK( x... )
V2 r. A: G( o; x% Q" }( k - #define DMA_FN_IN+ H9 J* d$ u; l# C; w( n
- #define DMA_FN_OUT
- e# \) H/ d) c$ K' Y - #endif! V z8 ^/ J- X4 U+ E
8 S2 Y; C9 h8 A: I0 `4 Y1 m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
q2 A: z6 o' F1 S: Z# F, [# A- V, ` - #define STATIC_SHIFT 32 s7 I* n3 ?9 I/ L" h4 J( h% U
- #define TCINTEN_SHIFT 20
' b" T- \+ v, L- f5 r; }, C - #define ITCINTEN_SHIFT 21; W* [! x) \& H' X0 e
- #define TCCHEN_SHIFT 22
5 }5 H( _* l% c" f2 v$ t - #define ITCCHEN_SHIFT 235 f4 R* F0 a( s; z( ^$ d; w# {
& h2 I7 P( y5 f3 v3 ~% { p- static volatile int irqraised1 = 0;. u. g2 W0 I8 O; j" O" Z" R
- static volatile int irqraised2 = 0;
; U8 b+ l7 R6 q% f8 }
* }! Z! y2 o+ B5 Y7 R- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 r9 K9 b6 R7 D/ [' H
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ B- c, B. d O% U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: M* J. q d- _* n* Z
- 8 [6 q7 l/ T* ]; Y
- dma_addr_t dmaphyssrc1 = 0;3 T+ F7 L3 g9 E# }" k( R
- dma_addr_t dmaphyssrc2 = 0;
, C' q: n- a0 Q6 D: n) H1 M - dma_addr_t dmaphysdest1 = 0;
/ o: l4 L" z$ k& q1 y1 U! _ - dma_addr_t dmaphysdest2 = 0;& L) x) G7 K7 R5 g$ p
- # r% K2 v) d& ^9 q5 n1 u
- char *dmabufsrc1 = NULL;. ^# ^& @; F# c% O, Z( w
- char *dmabufsrc2 = NULL;
3 U a. W% `' x) G - char *dmabufdest1 = NULL;
5 Z6 G: _! P6 m5 @7 m - char *dmabufdest2 = NULL;
# L. U7 L! ~/ P4 \
- Q$ H @5 Q4 V5 A# r0 z- static int acnt = 512;0 Y) W( ]5 G1 Z4 n
- static int bcnt = 8;! B& a. J& Q6 {& R3 Z- ~
- static int ccnt = 8;6 [; W3 k" K6 ~0 v W, X) f$ n: |
- ( B, q2 G4 @4 U1 }, Y
- module_param(acnt, int, S_IRUGO);
0 a" z) C( z. c) M1 D - module_param(bcnt, int, S_IRUGO);) |& f( E- ?+ F- N: Z( H
- module_param(ccnt, int, S_IRUGO);
复制代码
x' G# ~. D; W* a' \
, Y/ o) c. {9 d% U9 }$ w 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" Y9 E# @$ b' u0 P9 G( R$ |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 F3 Q9 H8 m# }+ ^4 s# }! L
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ t( `: X2 t5 _" o2 ~1 q5 U" ~% J! U
* }5 ]: A% y$ G6 w/ u4 C3 `: j! T7 b( K$ W- U
|
|