|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; `* g& N7 E- C6 G2 H; H- [code]EDMA sample test application
! k* \4 u2 q X+ |# }0 J3 U+ o' P - /*0 H1 T% y8 f$ a8 |/ o
- * edma_test.c% |* F7 ]4 u9 V& q
- *
8 ]1 k6 m9 Z% J - * brief EDMA3 Test Application
: h3 t0 i; S/ h# C) l/ R) J* } - *2 G) m: n/ p+ g! i$ p9 y q
- * This file contains EDMA3 Test code., F5 l6 C" I0 w( J) d) i
- *0 L+ ~4 N: J' `, O( z4 t
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ J [* P, ^- d5 t$ u' r% s
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 k& Y1 K- M# `; C% j) T. ~$ s - * TO CHANGE.7 U: \ A+ G1 p$ s4 _" m- S
- *
, o, ^. X! U- w - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; s/ O+ k. r q. f - *6 J ]7 u; d- N% l; l3 f( E
- * This program is free software; you can redistribute it and/or
- W, `) u! l& {& F- ? ?5 D7 H5 q - * modify it under the terms of the GNU General Public License as E8 p5 c% m$ d* F+ I$ ?
- * published by the Free Software Foundation version 2.
T# T. f5 y+ v - *
9 f( B4 X- [1 z1 l: Y) h - * This program is distributed "as is" WITHOUT ANY WARRANTY of any# y( c W# ]& t+ P2 \
- * kind, whether express or implied; without even the implied warranty
- |5 i$ v4 V' B/ M# a - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% B; G, T& ~* i% Q; A7 Q& ~ - * GNU General Public License for more details.
. e/ k; u1 H4 B: L1 C - */( U$ z% q3 W+ H5 B9 Y9 m
# w5 g5 w+ g4 |4 P9 `! k: K5 m- #include <linux/module.h>
0 X$ x9 c1 k) D' F+ ]" P7 }& c% w - #include <linux/init.h>
+ w+ z8 `3 c( L$ P' D; b - #include <linux/errno.h>
4 Q1 p$ x5 K9 _ - #include <linux/types.h>8 ]7 V: q6 u% B
- #include <linux/interrupt.h>3 }" F8 f. C& a' m" R; q8 a) ]8 D
- #include <asm/io.h>
$ u% E* U; v* e9 g N2 Z - #include <linux/moduleparam.h>, |! Y4 s& p0 ]1 I) P" P' O4 _
- #include <linux/sysctl.h>
/ U/ }+ O4 ?6 E5 o- q# \( @+ _8 ^ - #include <linux/mm.h>8 E5 Z3 j8 R" ]4 P
- #include <linux/dma-mapping.h>
1 D! Z/ x l# G2 {2 C, q4 x' O0 Q
; k1 B4 V: G) n4 Y- #include <mach/memory.h>
: l; r @1 L* N - #include <mach/hardware.h>
" q" L9 N5 M8 v& N& N9 L - #include <mach/irqs.h>) O' r: d. B# P9 r- B
- #include <asm/hardware/edma.h>6 q0 I6 q0 Y6 ]* H( o
- ( o) b g! i; t! c: z4 V9 \
- #undef EDMA3_DEBUG! \/ t+ o; R% _7 u1 L* O3 [
- /*#define EDMA3_DEBUG*/
: ~% W% [. a+ [/ o1 X( C: K - $ j* Y1 \* J7 w' ]9 j; s+ p
- #ifdef EDMA3_DEBUG( W; `+ I5 r! Y% d& C, i) X8 a* m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
X5 z5 @% o" v) u0 u: h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 Q2 m# E5 l1 X4 f, d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# x; `, U1 G( p0 C- x
- #else
) e+ v7 v6 b3 ?3 I - #define DMA_PRINTK( x... )
% j$ U s) P$ e6 l. ~7 i" R6 F - #define DMA_FN_IN
" b M7 O7 Z% V. H. J# Y - #define DMA_FN_OUT9 h0 h# B6 r* o
- #endif
. M: G) p/ s2 i. {' f5 v
( {6 M2 e. O. f( j$ Y7 a# W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 Q8 }: v& F/ @ L4 u# E% Z9 f( \ - #define STATIC_SHIFT 33 v; }- l& H% I- g% {
- #define TCINTEN_SHIFT 20
, Y1 J2 l0 V3 \! i$ Y - #define ITCINTEN_SHIFT 21* x* r, a: E% Y7 f
- #define TCCHEN_SHIFT 22! k7 s8 j% q, S& P2 R: a& C2 y5 N
- #define ITCCHEN_SHIFT 23# f# q% }; X7 \; m% A
9 a e/ N5 K1 |3 Y1 U5 c+ {- static volatile int irqraised1 = 0;: n% l9 n: B4 ?: l
- static volatile int irqraised2 = 0;# ?- o- S. W; N: V/ l2 _) X
3 R( R9 r- Q' I8 V( b; ?: C* k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ d/ F5 {, p: \& M/ d5 a, Z: ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- I8 L9 {" R! V5 B& J) ` - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); o: A+ P; ?5 q' W
- / t. }8 \+ P/ _5 u* v+ k* v5 K/ G
- dma_addr_t dmaphyssrc1 = 0;
) y* D4 p' f6 U - dma_addr_t dmaphyssrc2 = 0;
$ _- v, W, D: H6 `* M3 d, t5 B - dma_addr_t dmaphysdest1 = 0;6 o. k# P; c5 O
- dma_addr_t dmaphysdest2 = 0;$ g( Z, i/ X. V5 l3 C3 s- E
9 W( j# }( W+ Q# v9 `. I) D5 r' I- char *dmabufsrc1 = NULL;
. d! w' ?% q0 j - char *dmabufsrc2 = NULL;
, ]) Q& `5 F! z$ q - char *dmabufdest1 = NULL;
M: o2 ^1 ^4 r+ a ]- a - char *dmabufdest2 = NULL;
+ `0 B+ ?$ r( l - 9 L: Y+ W, k# i
- static int acnt = 512;& [ a! E& o# Q, B% H7 t
- static int bcnt = 8;
8 e/ K* ~, R) r6 l. y - static int ccnt = 8;
9 y1 X- W E' ~- @ - 2 g, a# g: a; W* a1 y b4 ?% h
- module_param(acnt, int, S_IRUGO);
" L4 f9 X6 X. K+ d/ n" R - module_param(bcnt, int, S_IRUGO);
; r" ?6 @! ^3 c* G. u" U - module_param(ccnt, int, S_IRUGO);
复制代码 ( Q4 x, ]. M4 D' i
- ?$ x, n& p' u6 u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: S( V* K) M$ E% @0 C& ^' `! Y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' r. ^( {& J; t) U% ^7 P! G
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. ^. [8 v0 f" n% X8 N4 E2 `. e
: Z) Y* I/ H6 D+ m9 R
; K6 N. B7 F! N, y
|
|