|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 4 B* P& A- ?! c& L, O
- [code]EDMA sample test application
$ e B- ]/ M5 \. a& G3 v6 k - /*4 u3 e$ p4 b/ Y" K+ ]- A2 _$ l
- * edma_test.c7 ^, c T! u1 N; \
- *
6 ]6 F( u: K0 b( f- D, I - * brief EDMA3 Test Application6 c x' u/ Y" l- F
- *# B9 N' c% z+ ?5 `& ^# `
- * This file contains EDMA3 Test code.
' @, S. t$ p9 I - *
. x* q1 `: {: y/ p; g, X) }( o9 L* I$ k% p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
0 b" L9 p/ G6 [. Q% S+ s - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% d- y" c$ G1 E" t5 A3 ^# m, w1 Y - * TO CHANGE.
6 |9 s* ? |; o+ U' Q6 q - *
4 C$ |4 c( Z6 ~6 A - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. y( G5 Q u4 k% g9 U1 m. [& M4 R" s
- ** z4 n* S: X7 g! a9 }
- * This program is free software; you can redistribute it and/or
$ H/ c! I9 B2 Q' T. n: x- u% b2 J4 t* ? - * modify it under the terms of the GNU General Public License as- e o" Y. v- e; z& }2 }0 j% O
- * published by the Free Software Foundation version 2.
7 S- t0 s8 @2 z! ?' W - *
2 D& R7 _/ @/ d( ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ ^, i/ A" w9 F- p) f: O6 L6 K - * kind, whether express or implied; without even the implied warranty
9 c% O) k! o/ e" B6 |& e1 b2 H - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
& R- {4 p$ \) j% n: x1 T3 E2 K - * GNU General Public License for more details.
; \5 q0 O: y x6 A6 Y" N - */, h9 g2 y1 T7 M/ Q* [
% m2 |6 S/ z* q* H: g- #include <linux/module.h>
& v2 b( j' g+ c& b - #include <linux/init.h>
: N+ n: c; L/ j' q - #include <linux/errno.h>* I% Y/ a- c ^* ~: }8 c& R
- #include <linux/types.h>3 x. M4 t/ `7 z4 A
- #include <linux/interrupt.h>
. i. _3 ~4 N$ i z* H% o - #include <asm/io.h>4 S; t& R9 v: m" _! u
- #include <linux/moduleparam.h>; I; W, a; C3 {
- #include <linux/sysctl.h>/ ]1 S! k" S5 u9 d
- #include <linux/mm.h>% w8 x& W0 `3 u$ T5 m7 F2 p
- #include <linux/dma-mapping.h>
* F# G3 ?+ _) |8 f( I- k
8 i, D$ t- o5 Z9 [- #include <mach/memory.h>4 {( l; M/ z7 X/ C7 Z$ A
- #include <mach/hardware.h>' R" p% W9 E& I, K4 A* W
- #include <mach/irqs.h>
X7 E* N5 l8 M+ `( l y" \ - #include <asm/hardware/edma.h>
. N$ ?' @: z2 [! G2 C
0 m: x* ]" {4 E `; S- #undef EDMA3_DEBUG8 _+ M; G- c2 ^' E
- /*#define EDMA3_DEBUG*/
O0 c; z# e4 K; f# I - 8 [' _0 M& d( F+ S
- #ifdef EDMA3_DEBUG
! g8 g! w7 f" U% [ T7 N4 \ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" S( y+ _0 ~ E8 _- z; h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! v t: G& k# e2 P1 y; a5 A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- ]: R2 d) M* @; h8 z3 {6 k
- #else( r0 b% ~1 h) W7 \( Y$ a
- #define DMA_PRINTK( x... ): [- J4 `- n/ w9 K
- #define DMA_FN_IN
! _. K% i4 p6 L' K - #define DMA_FN_OUT- k+ \! _2 ?5 j" F, F
- #endif( R5 l7 ?4 J% X/ p: q9 o, I, E
- % `- y3 k W" X% y6 ^1 e& x! v- h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
# J% K. K- j# C5 y% Q4 I - #define STATIC_SHIFT 3
. s0 ^9 u8 w9 }* \ {" i% ]" z - #define TCINTEN_SHIFT 20
( ?' {, \, f5 T( o9 O3 B# k/ [- K - #define ITCINTEN_SHIFT 21
! b4 L6 r: r1 n! J - #define TCCHEN_SHIFT 22
g" ~0 W" C7 t: J! J2 {4 w - #define ITCCHEN_SHIFT 23
0 H1 H; R k+ H- o( _ - + w) a! ?' R0 ?, m/ U
- static volatile int irqraised1 = 0;
2 u& m/ v) i4 y# A% W+ G% E$ S4 d - static volatile int irqraised2 = 0;! a2 R+ o: B/ s4 U- d" y# e
2 i6 n; ? l/ m- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 t _& T3 P$ ^! t6 G: M3 g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 Q' f R) r. c* s6 D2 E - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ ~/ X6 K6 I1 i0 z
6 A) }4 o% u) H+ C9 ]- ` Y$ G7 K- dma_addr_t dmaphyssrc1 = 0;
) l! X- Q: L3 i& i7 H+ R+ V - dma_addr_t dmaphyssrc2 = 0;
( g; R6 c1 x9 u2 q/ w% X - dma_addr_t dmaphysdest1 = 0;5 u. [0 M8 f I! |
- dma_addr_t dmaphysdest2 = 0;: a9 y& p" ~0 u3 I9 { F
- $ \5 \- g* k: b# I! i4 ]
- char *dmabufsrc1 = NULL;0 _9 c! V$ V. s1 Z" x9 ?
- char *dmabufsrc2 = NULL;
, T+ T# K8 J& U' m7 ?" ?$ s - char *dmabufdest1 = NULL;# M q; f* H, {$ P9 v
- char *dmabufdest2 = NULL; q: h4 W) ?3 K) |
- , ~# B8 d/ L! e8 l1 l
- static int acnt = 512;1 G+ G% D/ `! M. U7 [# R/ B$ n
- static int bcnt = 8;
% m4 P9 n0 \4 g+ e - static int ccnt = 8;5 f7 H# }: F0 u/ ]# g9 Z/ t
& X2 x/ w! R4 o3 F! e+ F0 _/ M- module_param(acnt, int, S_IRUGO);) m; @( Y. J2 S5 D* S
- module_param(bcnt, int, S_IRUGO);
* }! Q" `5 C3 u( s - module_param(ccnt, int, S_IRUGO);
复制代码 1 ?" Z" {! P' j F t
) v: o0 B4 I" f/ y+ w* H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 D5 c( f9 s: n' R0 C( M
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 C$ \) [; W8 a# K9 j
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 K' j4 Z; I2 L( Q* _' Y1 l
1 K1 R, A0 c! |" m0 P$ O
- L" n+ L: K- X5 X9 O
|
|