|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 H) T2 [- @, K% E, `% Y8 B- [code]EDMA sample test application
" b8 w8 [, Y4 o, s, w @ - /*
2 x& m" b0 u/ N/ i; F - * edma_test.c
' U$ t: W0 g0 i% Q+ R# J( _5 I - *
$ [7 O3 I6 k) `& U - * brief EDMA3 Test Application
: C+ E% Z5 ?5 G6 G% E& D8 a3 A - *8 ?7 w! r$ |( w/ W9 m+ W
- * This file contains EDMA3 Test code.3 D7 |! k2 h5 N# `9 ?2 ~# r2 o
- *+ s& H8 {4 M2 B W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" ^9 U L; f5 n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 o/ U) \& ~: K- Y
- * TO CHANGE.
- C! h- k: I: B# H& b - *% y4 j3 `; D$ O$ n
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ v/ a, i- W" b7 O - *
/ p0 C o3 P I- e+ U - * This program is free software; you can redistribute it and/or
, z# E- Z0 n$ ^8 c - * modify it under the terms of the GNU General Public License as
$ U* ]5 t! K4 |7 u! V' x5 [ - * published by the Free Software Foundation version 2.
; Q4 _8 F. z K" b8 O0 B) O - *
/ z* ` F% h9 _7 }& f& m% n% p: g - * This program is distributed "as is" WITHOUT ANY WARRANTY of any K( O7 w; v: c: V( {
- * kind, whether express or implied; without even the implied warranty' w+ k5 o% h' ~3 u
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4 l; m( F- S/ x* u7 n: @4 V I9 B - * GNU General Public License for more details.
5 S5 a$ Q A( @& L3 U - */
+ R& V( W0 R, A- I; L8 n - & ^5 E6 ?1 U( W* N3 b6 Q6 e7 P2 f
- #include <linux/module.h>3 z5 U, U, o" U) o
- #include <linux/init.h>! t$ T% |1 [, O% U
- #include <linux/errno.h>2 E, U2 M+ q5 [* S
- #include <linux/types.h>
* S m5 I; P* C c - #include <linux/interrupt.h>1 z6 e+ I$ a! c% r* {
- #include <asm/io.h>
) ?0 X% X9 ` X" @" {3 [ - #include <linux/moduleparam.h>
4 j( K: W- R+ c0 p; Z% r1 R) W - #include <linux/sysctl.h>6 H' N; Q% J- ?, h8 t$ Y
- #include <linux/mm.h>
" g/ `& Z& U; B2 i& O; T. h) S - #include <linux/dma-mapping.h>9 f0 p* F) m. S
- 5 l( C1 K: z( D; D) `+ j
- #include <mach/memory.h>
: ?( T% e$ I. o1 H9 ]' M3 A - #include <mach/hardware.h>" G$ m% ~2 Y9 g2 ]* c' m# z
- #include <mach/irqs.h>
$ Z. \/ X- x# n1 t3 \7 V% U# J% }5 U - #include <asm/hardware/edma.h>& H4 t8 m1 C+ c! \+ O
- : z. X, a+ G8 ]" e* Q$ c
- #undef EDMA3_DEBUG
& o! t2 o9 p- l - /*#define EDMA3_DEBUG*/
5 _" I# n- k/ d3 }7 K+ j) @) z- D
0 B4 B7 X: ]( v& z- #ifdef EDMA3_DEBUG+ Y5 Q1 Q& _, R# V2 M3 l# ^
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: @: l# M% e% F$ Q6 @- [2 q$ V. K - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), }: ?+ o, ]/ X8 \4 a) m
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): u+ c1 D8 A6 l% P
- #else; O* P d7 S% m: S
- #define DMA_PRINTK( x... )+ p: t) O$ \, Y& n
- #define DMA_FN_IN3 f5 M" { T O9 t8 X8 ?
- #define DMA_FN_OUT
' J- I& @4 h: _0 `0 H - #endif* |. K9 q) x7 E: `2 T# s
- ; t) z+ [6 B3 a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" p* T X( s2 \ - #define STATIC_SHIFT 3
; l; O0 t- i2 [' D$ i; h d - #define TCINTEN_SHIFT 20
; }1 G6 T. `% }7 q" d$ g: Q - #define ITCINTEN_SHIFT 21# ^& Q+ o, f3 T3 L
- #define TCCHEN_SHIFT 22
k: I" G: r3 G% w5 j7 q3 \ - #define ITCCHEN_SHIFT 23
4 y0 c; y+ z2 o
8 V2 U( X; L, u5 d- static volatile int irqraised1 = 0;
: z6 p+ z7 r& N7 x5 i' r" } - static volatile int irqraised2 = 0;& p8 U# A! A; [1 M* o5 @+ R
- - ?' I9 y& Z) Y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. \" m6 ^& ]2 P; b& D
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ o+ E9 T: q! o9 b1 k8 X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: h0 ^. E" c8 Y' r& _ - 7 \7 R6 R* K1 N
- dma_addr_t dmaphyssrc1 = 0;5 c* u* L' B* W% c& C: B# D
- dma_addr_t dmaphyssrc2 = 0;
5 g* k1 I$ H" P0 } - dma_addr_t dmaphysdest1 = 0; o- t2 T8 l3 j/ b3 l
- dma_addr_t dmaphysdest2 = 0;( W1 i5 s$ x2 {
- ' Y* y& @7 b0 x
- char *dmabufsrc1 = NULL;
; l! }$ C" S4 i, O9 H% [/ c - char *dmabufsrc2 = NULL;
8 E7 u# @+ U( D! u, t - char *dmabufdest1 = NULL;
) L- D) H: s+ D; v E4 q - char *dmabufdest2 = NULL;7 G% @1 A8 D1 H- C/ o
- ( V/ n0 y- y: m4 u; [
- static int acnt = 512;$ q: c5 O- I; p1 f2 U' r
- static int bcnt = 8;1 g/ x# f5 X. u, u2 W. f6 k
- static int ccnt = 8;
' u, d7 `0 |* N) W* Q! m - K4 Q: h, x& ?4 O
- module_param(acnt, int, S_IRUGO);7 z& N2 K, g, x ?0 e* `) b
- module_param(bcnt, int, S_IRUGO);9 }, x7 i: N% n g& M( }: X E' I* I
- module_param(ccnt, int, S_IRUGO);
复制代码
6 P- ^3 R$ T6 g8 T: M6 r* K5 P V1 K/ Z8 w6 C
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用9 z2 ~* h/ W8 i# p$ k* p
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 q/ X2 K9 V) F4 ^# g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 j) r; {5 b5 @7 N5 u8 H n* F3 a
4 M9 B( M7 q7 V) @
5 k7 f0 V/ R1 y |
|