|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! ]5 c( C- p, u3 l- [code]EDMA sample test application
5 l. P& C$ ]1 C3 |# v3 J" v- W - /*0 H) T: }5 N0 a& t$ q1 u5 z
- * edma_test.c
1 O4 [$ v) v9 q; o - *& y8 ]& N# Y2 Y. \+ O0 F8 r) }/ H
- * brief EDMA3 Test Application9 B l2 [2 N$ ~
- *
4 w6 } }- g5 `% y& {: ?% i2 V - * This file contains EDMA3 Test code.& g' j! ^$ O+ f+ b$ A
- *! f, w( S. Y9 Q& J/ [0 N1 D
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 z' f" X6 p& u6 R J7 i
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ H6 x l, g, ~* B' t/ {# u# v - * TO CHANGE.
4 Z7 n1 J9 W. f- ?5 g, o, R - *( h- ]3 @& M, h/ q: {7 V9 d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' e' {' ?* X2 Q$ B9 n - *+ G& x% C* N. [$ \
- * This program is free software; you can redistribute it and/or
# T U* Y% K* b( o - * modify it under the terms of the GNU General Public License as; O/ r2 V4 |9 H. c6 q4 S
- * published by the Free Software Foundation version 2.
. ]. X& B8 u. v - *
) V* x6 I1 [% R1 M, [ J" F- _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 s7 j& T: F3 M( t" W# O/ o f% L - * kind, whether express or implied; without even the implied warranty& J/ K9 G, [# r+ c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
U0 S. o8 v Q1 x - * GNU General Public License for more details." D W# _8 c* C4 S; X0 i
- */5 O2 R* g$ O R
! Z) e8 g# }6 }- #include <linux/module.h>! I3 m7 ?6 s! w
- #include <linux/init.h>
) m6 o y$ s" i' c7 f2 w% O - #include <linux/errno.h>
9 h a+ u' S0 ~5 a - #include <linux/types.h>
# X$ f$ s5 t7 u# O - #include <linux/interrupt.h>
6 \# @! p6 X4 T& r- `) [ - #include <asm/io.h>" z* N' P. a# x+ ]3 _) \4 F4 V: d
- #include <linux/moduleparam.h>9 q* A& R& F* R3 u, i9 s
- #include <linux/sysctl.h>
+ D' q& ~5 q: v- A- y - #include <linux/mm.h>
/ h* L! ^$ t, [: O2 C0 Y9 T3 O - #include <linux/dma-mapping.h>
; Q3 k( g* U( W O6 g3 u - ( t! c# u! ] ?, C' t2 N
- #include <mach/memory.h>6 o5 F) @3 o' M, u+ I
- #include <mach/hardware.h>, U+ ~; Q# ?' [" B+ p0 J6 y; E% {5 j2 V
- #include <mach/irqs.h>
+ J6 c( X' |( s& x& l% W* l - #include <asm/hardware/edma.h> C4 U3 D4 G7 d: }* v6 V
0 b1 E7 U0 a6 V; G/ I- #undef EDMA3_DEBUG% i" g' U& E: W* b7 ?6 m
- /*#define EDMA3_DEBUG*/5 U I' V3 A. I6 v
, G7 r. C; G4 K( d. q" v# k& I. c- #ifdef EDMA3_DEBUG/ w" {- c- j6 j: b/ W* P$ T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) w+ V% d7 t9 n4 {& B$ U) r1 g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 z$ i. Y# C, l2 m+ L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 t5 @% j) D( T9 D+ x3 |6 s* e
- #else
1 }: V/ Y9 j9 C0 h! z5 M - #define DMA_PRINTK( x... )
8 ^1 s5 H' _/ i7 R7 p- R+ g2 g - #define DMA_FN_IN
9 C9 m# u4 J( ?8 ? g* F - #define DMA_FN_OUT8 E i' o" c: X
- #endif
0 k" d [- A: ^, j5 h3 B: M; Q
/ ]: I! t! E( ^8 f" \' ^. \# m- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ D- h+ \* L: B - #define STATIC_SHIFT 3
8 U' o2 Z4 K N( D - #define TCINTEN_SHIFT 20
H7 D& B5 |) V+ S7 e! T8 e - #define ITCINTEN_SHIFT 21% a5 \" N q# ~% I" {# j
- #define TCCHEN_SHIFT 22
: z1 i/ q) i/ N6 `, ^2 Q - #define ITCCHEN_SHIFT 238 {7 x% R8 l% K. b+ r
1 y3 t/ v3 E! N! u% O- static volatile int irqraised1 = 0;! g! G! F+ r0 B
- static volatile int irqraised2 = 0;) C/ _6 j/ n6 n# j
3 F* T3 \5 v# i0 `/ a& ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& l: D2 p+ G/ y2 \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* R' Q' Q( [3 t - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, H$ {# R6 C: A$ k x; V
, M$ _& N6 ^9 I9 b* S+ k. y! l& P, S, c- dma_addr_t dmaphyssrc1 = 0;
3 w4 w+ a9 y6 g3 k4 v. K - dma_addr_t dmaphyssrc2 = 0;, T3 h* u( I+ X) T5 f5 O. k! T: v
- dma_addr_t dmaphysdest1 = 0;& r, E8 U- [* l O; c0 c6 u0 T
- dma_addr_t dmaphysdest2 = 0;
* D! D/ p( W. O
! t- {/ M' r/ J ?$ m+ j- char *dmabufsrc1 = NULL;7 |7 u: J: U# U: d6 p
- char *dmabufsrc2 = NULL;
M+ x9 U( ?% [ - char *dmabufdest1 = NULL;
: f" Z- ~6 d* X& x - char *dmabufdest2 = NULL;* ^; f$ G6 q0 p: F* g
- 3 ~* [% ~+ f2 T, D; b
- static int acnt = 512;
# X% V2 u, F u6 n - static int bcnt = 8;
( @ U U( |1 x6 X$ K+ z% r( Q - static int ccnt = 8;
! y2 h8 Y. e8 z( p4 b+ N
# l* D3 c# T/ t/ o6 Q$ \4 g: N- module_param(acnt, int, S_IRUGO);+ ^+ s. A7 s8 [7 M& c" `
- module_param(bcnt, int, S_IRUGO);
' O4 H* h. t- W% F% ` - module_param(ccnt, int, S_IRUGO);
复制代码 , i: Z0 p8 L, Z6 B
# I H$ K( x- o% J: m+ D* A' t, m 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ R6 z( Q( b1 I0 A5 {8 F- q. }) i! Warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 ^7 ~ K8 c: S; t8 o/ C% }" y' E% x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。) ^, ]7 i3 Q7 I" Z
. o* O8 P/ s& U9 R7 {! x6 d
+ y" ?: f4 y. I0 t
|
|