|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % p; }& u! ~$ J5 {
- [code]EDMA sample test application
# y* H# G" w5 R! y! g( n- z% O - /*1 E1 G8 x8 I) L7 C
- * edma_test.c
" y( d% O0 ~7 z1 t% M' N: h9 I - *- F/ {5 I# H- `" C3 I4 S2 N% v2 ~
- * brief EDMA3 Test Application
_4 r7 ?7 E( }1 J& p+ |1 ` - *. \8 C0 I* r8 v) x1 U
- * This file contains EDMA3 Test code.6 R$ I% a: l3 l& f% k* y
- *$ _5 Y# k% p' ^8 } U! f) Z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" M! M7 Q! C. c: r2 B* n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 Q) P0 m5 I' \( [) d) M8 H/ `
- * TO CHANGE.
5 ^; r' r( h& X! e( N \! @. \ - *
7 Q, d) E. r2 n3 q% a# I4 c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( r# M+ ^% W2 n3 U" X: M3 v
- *
) [% m0 b6 w% J& J - * This program is free software; you can redistribute it and/or2 l: R1 G3 H- u3 a7 T3 ?3 W9 i4 h, ?
- * modify it under the terms of the GNU General Public License as
# w, ~8 W2 I c) e6 F - * published by the Free Software Foundation version 2.
& v( m# I' U5 A: L+ x - *
' l4 `$ F" \4 C6 t3 Y+ t3 i" |* Q6 g! E+ f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! n# l( R" O* q4 e) D* x8 `, c
- * kind, whether express or implied; without even the implied warranty
: l+ o G/ z9 G, z8 G7 ]4 U6 C1 q0 l - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 b" Q. y+ A& K, I+ H
- * GNU General Public License for more details.& o- U+ I/ ?' Q. `/ h& L, t* F
- */" v7 h7 g, w/ e. {( m
- + p7 ^" ?# X. ~0 U% O( u! x8 s
- #include <linux/module.h>, ?3 Q9 s2 X7 _( L
- #include <linux/init.h> ?3 Z- t# N9 n( l
- #include <linux/errno.h>
, M7 B |$ u( t - #include <linux/types.h>
* j( H# N1 ]) F' I* q - #include <linux/interrupt.h>9 Q" m- g1 Y7 T' |
- #include <asm/io.h>
- g8 G& r X2 a& U$ P% p" M( i8 N- J$ y - #include <linux/moduleparam.h>8 \) b" V ] j) L
- #include <linux/sysctl.h>
1 A0 P% J5 I6 X6 P/ a - #include <linux/mm.h>
5 g/ Q" O `- y! i4 q' ~# C0 _ - #include <linux/dma-mapping.h>
$ {9 P# A, k5 y/ f0 l
. m7 F: J# n1 a/ a5 A- #include <mach/memory.h>5 t% R: F! e( T2 d
- #include <mach/hardware.h>+ M% c* x: w' z) |% F
- #include <mach/irqs.h>
+ K( f9 q+ |$ ? - #include <asm/hardware/edma.h>2 ~! q0 @! B3 Q0 y+ p
- / D* H5 }: U; C( V
- #undef EDMA3_DEBUG) W* f; T" F. ^3 g4 W0 L
- /*#define EDMA3_DEBUG*/
$ F( m7 D/ g u3 L' b. [( O' K - " H1 [ [. E# k) K- W
- #ifdef EDMA3_DEBUG0 ^. ?8 n7 t1 \' k5 Q* K; q7 Q8 h
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 J% }3 J( ]! l
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ t# o% {; L r: L1 C( p8 u$ { - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& E; }3 ~& L+ P" j - #else
H! u0 r: h0 F+ j! Y, e - #define DMA_PRINTK( x... )3 p; \8 w# U$ {! B
- #define DMA_FN_IN! ?9 O' K* D% a( c* B s
- #define DMA_FN_OUT
3 U& L- w7 i/ }2 H& n. y z) o - #endif. @/ j4 K& J" l7 Z% z) Y
- / p7 v; C$ i3 C- G; E% q M5 b' N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# G% A, z5 i* R5 A
- #define STATIC_SHIFT 3! g. ~# v+ i0 Y) Z/ |! z G
- #define TCINTEN_SHIFT 20
9 o' u& z0 \9 H- J - #define ITCINTEN_SHIFT 21( R2 _9 u' k% C& s
- #define TCCHEN_SHIFT 228 x" W( A( e) b& C- _- ?3 J T
- #define ITCCHEN_SHIFT 23! ? y7 K& y* A, i$ B
/ `0 d O' N' Y) C, g1 y- static volatile int irqraised1 = 0;. f$ B; g, O3 h. L/ v9 c! ~8 N
- static volatile int irqraised2 = 0;, o: W, n5 J; ]9 o" P0 ^- B, v* E8 x
- 9 R& f% P/ n r% F
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 w" V- j$ p; v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 y& K5 K2 ~+ [ j1 [# Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 x5 E, I" ^1 n( e) ~ v
J$ D1 K ^# ~/ q, w1 W- dma_addr_t dmaphyssrc1 = 0;
$ s- P I4 p, D1 t- O/ q - dma_addr_t dmaphyssrc2 = 0;6 L8 C: S6 ]# k+ S8 c
- dma_addr_t dmaphysdest1 = 0;3 C# Y$ l1 S/ w& o. j6 w9 ]
- dma_addr_t dmaphysdest2 = 0;& N) S# x, W) O
- 2 `( |4 @" D# E- k6 [+ h
- char *dmabufsrc1 = NULL;
; T/ w. g9 Q, t; g - char *dmabufsrc2 = NULL;
K" M& i, M1 N9 w - char *dmabufdest1 = NULL;
: B9 H: R0 j' { - char *dmabufdest2 = NULL;
5 @8 a) c2 b0 Z+ g3 S; j
( X9 [# N: y: m/ U7 S9 ]- static int acnt = 512;; ]6 K' M' u* a1 w a" G
- static int bcnt = 8;
$ t+ [2 @+ J5 H$ b$ n% Z- \0 D - static int ccnt = 8;
4 u4 Q% r5 ^5 v* B8 D4 Q1 w
( w$ n! M& P9 ]8 ]; {; y- module_param(acnt, int, S_IRUGO);/ n2 T5 j% k% H4 t2 p
- module_param(bcnt, int, S_IRUGO);) n. |. T" @0 X9 H: [ u
- module_param(ccnt, int, S_IRUGO);
复制代码 6 L/ J5 P9 {8 E& @& e) H1 B& r
8 ~* W3 o3 F- I6 i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 h( H: r' T: h% V9 i/ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 ]7 m. ^& T$ m. ~* r/ S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( N# |/ a5 p& B& f; m% M, ]" x
. I/ }+ A# @5 W) |4 s% Y* b1 \+ P: k4 g) W4 Z
|
|