|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 F5 ^& s" F$ @+ @' v- [code]EDMA sample test application
& p2 x' U3 D0 R7 {% D' Q - /*. C5 q7 d$ _: h/ ?$ ^
- * edma_test.c' \% j5 z4 }% N: h5 r
- *- @ [' {1 f1 V8 S1 T9 ]5 e6 l" L
- * brief EDMA3 Test Application! k, q' i) Y2 K6 D
- *
5 @9 R' f* |$ Z - * This file contains EDMA3 Test code.7 i9 t) a+ B3 T7 g! `8 v3 j
- *
& Z- N/ U6 g5 w* G: i& w Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) R i$ r0 U5 c) [- `$ V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 `9 A# i; D" p6 Z& v& m+ b1 b
- * TO CHANGE.
# \6 T+ r: a' P V$ z - *
. Y+ r! k; |& ~& u8 U* q- ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ V' w0 {# D1 @- R+ ~8 Z& m, P: M - *2 ]% @; T! n. {) R
- * This program is free software; you can redistribute it and/or* A% A, Z. l+ o2 ^' Z8 j! Q
- * modify it under the terms of the GNU General Public License as
+ N6 P' I* Z1 n; c. J( V - * published by the Free Software Foundation version 2.% p) T& f+ z+ C$ `5 A1 L' ^$ i
- *' U' ?# o6 }& i8 A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ U; W& p) R& t1 Y0 c
- * kind, whether express or implied; without even the implied warranty
( h% a5 |$ d4 |! V+ X' M - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( ?, P6 l8 F6 B) Z9 E$ M4 f
- * GNU General Public License for more details.2 [ ^3 m2 I6 l* ]1 [
- */. F0 N2 M' v6 L
- & q2 X# u" m7 |" _$ M
- #include <linux/module.h>
) @: g: S5 ^: m3 I - #include <linux/init.h>8 L9 k- g( U# ~) z
- #include <linux/errno.h>) y( t" H2 i+ C; H
- #include <linux/types.h>
" s& P# j+ o8 Q! F. \ - #include <linux/interrupt.h>
1 b1 `& t/ o, H/ m. I# e - #include <asm/io.h>
1 F6 p# U- B. ^$ ? I - #include <linux/moduleparam.h>( u6 a1 i8 D# I$ B9 B* {/ D
- #include <linux/sysctl.h>) K- n8 ]* L. g: |* h6 J
- #include <linux/mm.h>' J5 L. N9 W! ]$ n# A4 ?4 ?
- #include <linux/dma-mapping.h>
[1 e ^& J. c0 U9 |" c2 J+ ~" q, I: x
* y& M( f6 H* r! W% F8 M- #include <mach/memory.h>8 x: S- k5 c1 `* l
- #include <mach/hardware.h>
7 V% |" |$ W/ [" H" L/ g8 K - #include <mach/irqs.h>
1 [( ?; M: I0 l) B8 h K - #include <asm/hardware/edma.h>5 }; d; Y4 h4 Z; e" e
- : o' H: |0 ^ [ H: G
- #undef EDMA3_DEBUG# e% G) r% m* Q7 j/ A# S* \
- /*#define EDMA3_DEBUG*/
. {! s8 f/ V, h0 ?+ y
- H* G3 B1 T" N2 x7 X( o- #ifdef EDMA3_DEBUG
! k! x: T6 h( Q, F1 {. h6 T - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 e5 @' I7 |! Y* D W - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), s0 v7 O [0 g4 N7 A1 @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ P5 x( Q% C7 ? - #else
7 ~# e4 P* G4 v8 |+ w - #define DMA_PRINTK( x... )
8 R( r' n7 y) h4 a( z( V8 o b - #define DMA_FN_IN
8 q; V9 K3 |! V/ L( Y$ t) ^ - #define DMA_FN_OUT6 ]' c7 c3 M. p6 ?$ d1 m
- #endif
2 T- U1 b: w Q- x/ D0 H2 v- a
# I5 H/ |+ c( N- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 I2 R: X# L" Q! X5 [
- #define STATIC_SHIFT 3
- K4 p9 W. ?- u# a1 Z4 C' r3 l - #define TCINTEN_SHIFT 20
! R: i a9 e6 D4 }! m$ T; U: J - #define ITCINTEN_SHIFT 21 W& r1 n. k4 |6 k$ `
- #define TCCHEN_SHIFT 22
0 q$ C% k D2 R% G/ v - #define ITCCHEN_SHIFT 23
9 j8 h/ I3 w1 i6 e5 S+ ]) k5 X - 5 z8 L1 @9 G1 E
- static volatile int irqraised1 = 0;
3 k, W* }! g8 D/ @; M' X; R - static volatile int irqraised2 = 0;
0 k9 @- o& q, q0 d- m
- j" i$ h( ^2 \- M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 U1 E" }6 Z2 E$ j2 z8 U$ j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' q3 o' J5 J" W* N2 J3 M
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# ~) @5 M* A$ G; b% e- g - . d' T1 F% v' }: P9 e: C
- dma_addr_t dmaphyssrc1 = 0;
! B' t4 d$ {" M% q8 F4 v P+ P7 y - dma_addr_t dmaphyssrc2 = 0;6 B) @2 x0 ~6 n/ R% b
- dma_addr_t dmaphysdest1 = 0;
- m% M8 b+ ?: y" z3 C) P - dma_addr_t dmaphysdest2 = 0;
$ I' K2 d m) ` c; i% Z1 @, h
- }. l4 O3 S5 Q9 M- char *dmabufsrc1 = NULL;
! c; v! \7 C0 N3 N0 f2 g - char *dmabufsrc2 = NULL;
* `" n6 T4 P& H) t - char *dmabufdest1 = NULL;
! x* J, o4 O: x2 h" S - char *dmabufdest2 = NULL;
) E$ x; G/ v4 n
0 j4 v0 s& ?: S5 Y, e- static int acnt = 512;
5 i8 l9 ~0 X' m/ E5 Z - static int bcnt = 8;: {! \* M( X! f9 b6 G7 u
- static int ccnt = 8;
\8 f- S- a f( I& N% D$ O
: k4 l/ G% @" E( w2 @0 T8 i( `- module_param(acnt, int, S_IRUGO);0 ?" ^1 D7 N$ G+ A; X; ^( n
- module_param(bcnt, int, S_IRUGO);, g1 f/ w9 s3 Y+ j& u7 C8 W8 W/ i; x; L
- module_param(ccnt, int, S_IRUGO);
复制代码
# {1 I/ f* Y$ K V
3 ?+ ~$ ~4 G; i* d4 d, W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- c, F& M; K* B7 Z+ Uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- u: y. ?3 h/ V, _& g
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 M+ k' X- J7 K3 z w
* T! a# ` |( t, Q# z' v
* w0 ?$ j4 U0 X7 Z9 X- M5 h# N
|
|