|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : W6 ?! b* D( T+ j
- [code]EDMA sample test application& d) K( Y- [+ n$ j0 `6 D5 ]2 |3 n
- /*
+ C7 s' {6 v8 f% | - * edma_test.c
' w$ d1 {$ d% A6 Y, a- l9 h - *. U0 Y# \: a4 `1 H) a$ r
- * brief EDMA3 Test Application# p5 [' y- ^2 Q
- *+ a0 r/ R+ |0 y* r: d) k0 M
- * This file contains EDMA3 Test code.
" z3 s: p; S9 t- J/ C: P `& Z& M0 [ - * o, E: p/ c1 q/ c( d2 b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ P; P8 u( q# J6 M/ B
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& ?% h; n% @6 g" M
- * TO CHANGE.
8 S6 {3 a1 t! ?: l* _8 x - *
* W7 @. |; h7 h3 \9 f' o0 ` - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" d* N$ x# @/ {( M# b4 C
- *
& l$ W* r# W7 n) w: B - * This program is free software; you can redistribute it and/or
+ _. p8 [3 D& A4 B# x- M - * modify it under the terms of the GNU General Public License as6 L4 @- P) S$ b* u u* ?9 `6 C& P
- * published by the Free Software Foundation version 2.( B- Q9 o" v" O% H0 ?
- *
$ k7 i" P2 r: x$ E$ {% j* p4 ^- c3 T% U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 W( j7 q, P9 U& l3 ^ j1 B - * kind, whether express or implied; without even the implied warranty/ \; S6 X# L: Z& o" N$ ^8 J( R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: ?4 `/ L! Z! K' H
- * GNU General Public License for more details.
) c- M! u4 D3 I" X9 Z( Z - */
* }. O1 M1 @. I% k; B - $ |3 ^7 X& `. y; j1 H) e
- #include <linux/module.h>2 ^2 z' P e1 o/ W
- #include <linux/init.h>
% W b& m3 `3 g" W - #include <linux/errno.h>1 c. H. `0 D0 ?
- #include <linux/types.h>1 U. _3 W, I' m8 X: v! G
- #include <linux/interrupt.h>
6 K* |% \8 S$ g( F0 Z - #include <asm/io.h>
. B; Z5 D% u1 w - #include <linux/moduleparam.h>$ A4 L7 X; Q% M0 W+ X" W
- #include <linux/sysctl.h>, j5 K; `" V6 x5 p* q
- #include <linux/mm.h>
# Z! \. v7 b+ q% U" h: H8 ? - #include <linux/dma-mapping.h>- s: Y5 G; p/ U, k
- : G, j; K# u# J+ ~4 v- V
- #include <mach/memory.h>
1 Q: T- u: f9 f! |" H/ V, e - #include <mach/hardware.h>* `, b1 w/ V$ E! S; L" |* X
- #include <mach/irqs.h>) |% O2 N8 p0 U1 ~
- #include <asm/hardware/edma.h>( P6 `5 C5 h8 t- M8 V
! ~6 `7 t" G% s1 ~- #undef EDMA3_DEBUG
. g7 u2 p" p# b2 l6 S8 x- X/ o - /*#define EDMA3_DEBUG*/
8 E8 G5 @* z7 j8 P3 E% J6 Y
0 L* k, X5 A9 N- #ifdef EDMA3_DEBUG7 P6 J' i i$ a3 c, }" ~0 V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 u9 M, u( o# F( T5 w* s; J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ d' t9 k. w/ J5 j( W2 s7 g- |
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
" j' j6 D( b" I: A( _+ w" s - #else" V1 \+ Q! F$ w8 N( P% E
- #define DMA_PRINTK( x... )
( M$ o+ l+ l* G9 I; S - #define DMA_FN_IN2 ~- Q6 E7 T, [
- #define DMA_FN_OUT! W8 u6 S! g/ ^9 W' v9 L
- #endif) K1 ~4 M. U5 q$ s# V% }
4 y& n9 H0 O# _/ e3 F, R* {- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# [2 v! \: s/ e3 h: ?4 p
- #define STATIC_SHIFT 3. T! O! g, {; t- m& {
- #define TCINTEN_SHIFT 20
3 Q$ K& v8 H3 [% \) o- \ ]3 F - #define ITCINTEN_SHIFT 21
! Q- d1 Y* u; v/ I' ] - #define TCCHEN_SHIFT 22
7 H- Z' p/ S( ^! C' m0 w6 K6 H- k - #define ITCCHEN_SHIFT 235 O' k7 o8 y2 ?* S% T+ f% t
! \& b" n* T" v- static volatile int irqraised1 = 0;
; F6 m. }6 W! S, g6 D - static volatile int irqraised2 = 0;
4 B: z4 o: }: g0 z8 t3 B3 @8 o - 4 H1 o% ^0 a) ~6 y" y, F
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' ?" l" s$ y/ V4 h( i/ m
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 Y/ ^( D3 h0 F+ A' M0 ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# w1 U+ U8 S0 X2 y
- 4 b' l$ Z& r- t0 c# r# B
- dma_addr_t dmaphyssrc1 = 0;: t' e9 O6 F' G3 _, |7 r& ?+ ]
- dma_addr_t dmaphyssrc2 = 0;
& M8 `& a% b3 Y0 T3 R. G' s" k - dma_addr_t dmaphysdest1 = 0;# x0 q, N" F8 {/ y1 b% ]* {2 w! A
- dma_addr_t dmaphysdest2 = 0;9 I. O% R8 ]6 E* b/ y) |
- ( S- J9 x. G/ b# ]
- char *dmabufsrc1 = NULL;
) k3 x- y: U! v$ T1 w8 r: N - char *dmabufsrc2 = NULL;( \( g3 U: U+ z
- char *dmabufdest1 = NULL;
( w% g4 G; R% P' }4 S - char *dmabufdest2 = NULL;
: l& g: t/ U8 s+ n: E4 |& c
' U( L% c- m4 R/ a$ E- static int acnt = 512;! y+ A4 u! |6 f7 w, I$ l% D. o
- static int bcnt = 8;
" F/ x2 ?, `0 d0 x - static int ccnt = 8;/ }) I; F7 n! c2 v' K
- 6 s5 a' [; o2 K2 `# X! }
- module_param(acnt, int, S_IRUGO);
T# F: ]1 D7 H) g2 L - module_param(bcnt, int, S_IRUGO);2 r( ?% H: `5 |
- module_param(ccnt, int, S_IRUGO);
复制代码 4 z! s# j9 u. o) k$ {$ D7 b
# y# z9 R& Z" W3 Q$ R& N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ m6 O9 w- Q. ]2 W* W' darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" A/ F \ O. c l# K 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; M9 q, V! Q" i' Z X: u! L; B7 \8 B1 A
a8 _& c- B1 b x/ C
|
|