|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # ^ N& M/ C. f( n9 [
- [code]EDMA sample test application0 h" k, k$ T' E2 L0 ?' U
- /*7 u6 r2 t. J; j0 U2 U, X8 F6 z' D
- * edma_test.c
" m8 M V |9 X- f. ~ - *
5 \4 Q6 t1 h9 Q" a - * brief EDMA3 Test Application& F) Q# k% K5 R1 E) q/ e+ g
- *
( e4 a: @' X3 n5 R - * This file contains EDMA3 Test code. ^# |/ p: P+ r- A1 M
- *
6 a& h3 R' m( N+ G x - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 I9 r/ p% H9 U' x% A& I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) d1 ~- l: x0 v
- * TO CHANGE.
# G8 @. C& d/ g ]: j" i - *
& M$ p/ Q* H3 k/ `/ I) Y: F% ` - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/5 t$ H( I& @ i( i* U' G% Y/ H1 S
- *
U" P0 e2 u2 d3 n4 p, A - * This program is free software; you can redistribute it and/or
7 g" t }. x; e8 C5 ^$ s; n - * modify it under the terms of the GNU General Public License as+ h, F4 K. D3 }' a/ e% m1 z
- * published by the Free Software Foundation version 2., V6 d0 `6 c$ _% H0 e) m
- *- x E9 f/ n0 I8 g4 l
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 H+ M: B9 X: L( Z8 U* Y
- * kind, whether express or implied; without even the implied warranty
& v/ z# N C5 U; ]! B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 L/ b) {& x/ B8 Z( P# S
- * GNU General Public License for more details.3 K, f' R6 f0 t/ ?- Z. R" @
- */0 V. X0 L1 L& B5 s
3 E$ | C# p7 o1 `& h" q7 a- #include <linux/module.h>
& M% j' v F+ H7 j3 y - #include <linux/init.h>7 |/ p* I) G9 b. G3 w3 @8 e/ a6 E: l
- #include <linux/errno.h>
7 q5 ]5 d4 t+ R' V- @ B0 i - #include <linux/types.h>
3 U4 G' \5 }! c' G: w - #include <linux/interrupt.h>
f9 R) t3 `8 C3 O( K - #include <asm/io.h>4 F: C! G4 G' X& l' ^) H9 L
- #include <linux/moduleparam.h>
# `0 t' E7 ^& }2 P% p: H% F' J' m | - #include <linux/sysctl.h>; H+ B# @6 y$ ~* J
- #include <linux/mm.h>+ O6 F7 E3 X1 d
- #include <linux/dma-mapping.h>
q0 C( P# L& ~; I, C: q( H2 [$ E% y
4 A& x7 \' |! v3 m$ b# g, D( a- #include <mach/memory.h>
* K; G# [3 W i: l( K$ F) x' b - #include <mach/hardware.h>
/ n5 j1 t& i, H& E: W/ \6 }4 \ - #include <mach/irqs.h>
% W0 Z+ o# Z0 u9 { - #include <asm/hardware/edma.h>
; y: L- g% W4 s1 m - 5 p; r+ d y5 k9 r
- #undef EDMA3_DEBUG
- k6 A3 m7 c; p% H- b/ l - /*#define EDMA3_DEBUG*/
) A, o; x& c7 b8 U, W - ) p* \5 j( N: ?+ ^
- #ifdef EDMA3_DEBUG- p- ]: ]: N# i- q# o3 E; \. |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% Z# g+ ?2 V) \) m$ F$ m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 a; }9 g6 _+ Y# K. Q, V
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% r( J0 ~& D" C' M
- #else/ a3 U+ l: @! R. _
- #define DMA_PRINTK( x... )" D0 q8 L9 {! J2 F0 ` [# v: T. k
- #define DMA_FN_IN' T6 ~! J7 O8 q9 l0 y7 z
- #define DMA_FN_OUT
% _ J2 h: M) q, q - #endif
) `9 U" ^0 H- G. D) c1 ]6 E
: z/ t' D6 @, U; q! }- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; T$ E( l5 \5 s9 B! J. q - #define STATIC_SHIFT 3
" e9 ]) e" a; l/ O) | - #define TCINTEN_SHIFT 20
( t) N7 ~# h$ B& l* v; U - #define ITCINTEN_SHIFT 21
7 Z( m* h) J- k* G7 _ - #define TCCHEN_SHIFT 22
" A$ _1 X- ~' r2 m+ w+ m4 K - #define ITCCHEN_SHIFT 23' r4 }5 Y/ _* X$ y$ K+ V0 Y
- " i( O$ Q! ?7 ?2 b
- static volatile int irqraised1 = 0;1 U5 M3 S+ m, [- y) q5 S
- static volatile int irqraised2 = 0;5 g; `3 P% ]7 t; p; Y$ J y# K' h
5 s/ y3 p* [- \/ z* n: u3 w- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- e* I! e! Z4 D/ D7 C/ U' d* F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* S/ H, I) g( D) v$ j; l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, d8 S- ~6 R7 T$ ]7 J P
2 W- F, L* [0 n% V' }6 y- dma_addr_t dmaphyssrc1 = 0;
0 Q' @$ X- S: @4 p - dma_addr_t dmaphyssrc2 = 0;
* F j: u) j5 }: s$ t) E2 m* m6 z - dma_addr_t dmaphysdest1 = 0;" O: n3 i6 w" i' Z) c; |
- dma_addr_t dmaphysdest2 = 0;: P6 B5 i- a7 |4 o1 K' l: Q
' p; @7 ^5 O+ d4 S0 W- char *dmabufsrc1 = NULL;
( s" J0 {) v J7 \' e3 a/ i - char *dmabufsrc2 = NULL;
; V- B! Z$ T4 K8 j# a: Q4 R& G8 f3 L - char *dmabufdest1 = NULL;5 W7 l4 O! L, t/ \7 T8 ? o k
- char *dmabufdest2 = NULL;5 w- E& h* \4 B0 q; C7 r2 Q
1 w, d/ _( {8 l" V/ b: ?8 k- static int acnt = 512;
5 C6 }" M0 M. Z1 V, a, W - static int bcnt = 8;* V+ e! M' ?' S! F% J
- static int ccnt = 8;9 B( d% h& r" P4 G
- * @+ ~) B$ I0 w2 v. I- n6 N
- module_param(acnt, int, S_IRUGO);
# H( Y1 i3 g6 ~9 \ c - module_param(bcnt, int, S_IRUGO);
: p- Y" S- g3 p7 c. X6 @ - module_param(ccnt, int, S_IRUGO);
复制代码
# f. E a2 G* X5 P- n
' P' E1 Q7 A; l, E) ~ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
f. H: w, v3 H; {! Y9 Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) S% d7 C4 J$ i/ F8 E3 ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; {; o1 ~ y7 c/ P5 t
6 {" l2 h n& v- \; I2 ?/ F
: c' K# _5 c; a |
|