|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , j$ Y" |, w# R$ i5 _' g& X6 F
- [code]EDMA sample test application
' n$ h6 p) b0 w+ f( r' u - /*& m) I! R1 e; n1 l. \+ `; u; f
- * edma_test.c
- o# X5 [+ B( ^* ^. w' h - *; r6 W4 h4 Z* K
- * brief EDMA3 Test Application
3 ?* \/ Q6 P0 \5 m \ U% ]2 e+ @ - *
' x& y" ^5 Y1 `7 H+ ?5 M( L3 ^6 U - * This file contains EDMA3 Test code.
% e6 I4 ]4 @& ]; t4 r6 f - * y: d# W( _9 H
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE c& p4 r8 _0 K" O2 F1 H: Q% K( N* o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# R. r- q, s) W - * TO CHANGE.% ~ Y6 @+ u0 O- Z2 N
- *
* S0 l* z) K3 [. e - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 j% S* _$ U7 c, r
- *
) O; _+ w! Z# F8 j7 b - * This program is free software; you can redistribute it and/or
7 V9 |/ ]3 U0 H! H - * modify it under the terms of the GNU General Public License as( k1 y; m* g% `* N' z% n; @/ O
- * published by the Free Software Foundation version 2.& w/ Z- |& [2 J1 K1 Z9 ]6 H
- *
2 E9 j& X) ?9 j( B6 ]5 S- j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, w+ Q% W' w7 k1 B4 R - * kind, whether express or implied; without even the implied warranty" X) _4 |$ R( M2 i4 x0 o) c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 F7 I* m, q8 e. u; b4 ?1 E
- * GNU General Public License for more details.
; A) t$ G6 z/ j6 m/ Y7 v& V - */
z {# k$ f0 g& q8 G - ! H% i& j& t0 [% O
- #include <linux/module.h>* G1 K+ d) R1 S/ U7 _( u9 S
- #include <linux/init.h>
& B+ W: `1 R1 B4 ^1 C; L - #include <linux/errno.h>9 E( S& o1 @: L0 P# H- K
- #include <linux/types.h>/ Z& p% H) X- M5 ]9 S
- #include <linux/interrupt.h># @, s$ i; K1 O8 w
- #include <asm/io.h>
4 A; a/ u! O7 `6 R: e) U4 W - #include <linux/moduleparam.h>( ]; b! K' @1 a
- #include <linux/sysctl.h>
; b- p% `( l( p2 A4 e3 v& j - #include <linux/mm.h>9 ?( E8 m( K; ?. j
- #include <linux/dma-mapping.h>6 E x. n* j3 |+ ?. r1 o
9 K3 t8 a- y4 e5 c8 t' O$ \- #include <mach/memory.h>; Y: F, c/ h H) M: C
- #include <mach/hardware.h>, v; b0 s$ `' u! P& H
- #include <mach/irqs.h>
3 @, c3 P9 S& I* b - #include <asm/hardware/edma.h>
, H: L2 D0 e2 r. R - 9 I( z3 k o; W8 H8 H. D8 A: p
- #undef EDMA3_DEBUG% c: T+ v6 u* F: g$ w& o7 V
- /*#define EDMA3_DEBUG*/
! L/ w5 b$ ?# l# Y# n
; W( Y' z% I+ m% }' C; n- #ifdef EDMA3_DEBUG1 b$ ^+ ^( l9 f, ?0 Y' [+ k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 y: h9 q) x( W$ g8 m& H3 N - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 e* N$ L/ ?- [7 k, D
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 O& g. k1 e' X/ ?" ?( Z - #else
) @+ ?1 F& M: [0 z - #define DMA_PRINTK( x... )
4 c1 {& y" C. Z4 e4 y; H- y; \7 {' i0 h3 q - #define DMA_FN_IN
0 a1 e2 [- J5 p - #define DMA_FN_OUT: {, T- ]+ ?& H9 y* H5 n: ~1 f
- #endif
* [# ~+ E+ O! L8 A - 8 o, X- |: `" _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! n) |4 Q, y! J; z* f9 ~ - #define STATIC_SHIFT 3
$ _; l3 g! W; R( L5 F - #define TCINTEN_SHIFT 20
$ r' G% r9 v* z- Y' W4 q- Z+ F; _ - #define ITCINTEN_SHIFT 21+ w% L8 L/ X$ C3 `1 ?
- #define TCCHEN_SHIFT 22
* v8 d6 B. u2 q" X& J1 }% C4 p - #define ITCCHEN_SHIFT 232 r$ T3 K: @) Z; o; U9 y9 j
- 5 u) {' k: m( {
- static volatile int irqraised1 = 0;
) R0 ~9 V* l, ]8 W: P9 k - static volatile int irqraised2 = 0;) f4 G2 P6 }# F8 b' c/ Y% _9 M+ O5 T
- , ^. x! x- L5 ^ r+ i% \
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; Q( ~- K; s) g4 T1 S
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( x1 l; d7 L3 V
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 J/ K/ x f( e5 M - ; J% s, E1 J3 S6 `# l
- dma_addr_t dmaphyssrc1 = 0;
0 U8 @* R9 I- p* F$ I; d/ d* J7 } - dma_addr_t dmaphyssrc2 = 0;/ R! h. T, q3 x5 _3 ~
- dma_addr_t dmaphysdest1 = 0;
! F" Y, {0 }8 l# K# f5 d7 a/ Z - dma_addr_t dmaphysdest2 = 0;& Q2 r5 ^* j h. K* g" i8 @; @
- + U+ _2 e: m( w- q$ x% F! i
- char *dmabufsrc1 = NULL;
- T, G5 Q. L4 m- Q' s; a - char *dmabufsrc2 = NULL;. o8 Y. F. K7 l) {+ K
- char *dmabufdest1 = NULL;7 r' G3 v1 G. a5 Y* ?1 W! G
- char *dmabufdest2 = NULL;* y" ]5 Q+ M# _8 V( j
- p+ V* q. ]2 }: i1 W! P/ [7 W- static int acnt = 512;- U9 W- U- A/ O9 t' R( F6 ?
- static int bcnt = 8;
' S! c" e2 l) `! p9 F - static int ccnt = 8;" B |$ I: d/ p: }% g* b5 p
/ C6 B3 L+ o" k! o# c/ j- module_param(acnt, int, S_IRUGO);6 s3 l2 J0 p, g# U
- module_param(bcnt, int, S_IRUGO);1 q0 F3 q; ] H( h" _# Q
- module_param(ccnt, int, S_IRUGO);
复制代码 6 B( z+ L [6 I3 I7 C7 i2 h' s, J
8 }8 Z3 g a3 {0 Z [) }$ U7 E 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 K' ]! k% c# ~6 y; m0 ?
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 R8 h& b/ F9 n7 U9 |& ~* I" p$ Z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# N h8 Q7 X1 @ [7 T' p% i
6 U' j( w0 u( @" i7 L
6 {4 H5 H P6 F4 b" ?4 z |
|