|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 p6 B) j; v; `- B+ i0 T* L- [code]EDMA sample test application8 s3 o6 o9 }) F" ]* Y- c1 t
- /*3 @! S7 s# y' i6 s8 h
- * edma_test.c
* I# S; u9 c6 A `# \ - *
3 A7 H4 w, A. y9 v - * brief EDMA3 Test Application
: G/ |5 c$ t% v% p# ~+ \ - *
d; {% B8 c- Z I1 U8 e) Q2 w0 a - * This file contains EDMA3 Test code.
8 R1 }* _/ }9 v% O - *
6 F) J( Q8 b0 E# E. w/ k! n/ r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; |1 ?# i) I; x& n) V
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! f6 h! o- ^0 w8 f o: C
- * TO CHANGE.
: d; i6 x; X& \$ w; [( @) N1 u: [ - ** J, t! p9 d. H% W
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( u& R# ]* ?+ `- P- ^% w; ^ - *+ Y" W7 d% K* H8 Z( r: g/ e* j* ~
- * This program is free software; you can redistribute it and/or
5 |# Y( M# |& ?9 p* Y0 I% I - * modify it under the terms of the GNU General Public License as
7 W9 U/ d* M F& w/ E Z - * published by the Free Software Foundation version 2.
" Z6 J# t) [0 b2 x5 {6 L0 B - *! k% o8 e d$ q' s' e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 h( z! M) V2 N0 L, z - * kind, whether express or implied; without even the implied warranty* m% c$ T! w- d8 B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 k' M- _% R( j4 y, W: K
- * GNU General Public License for more details.
( |* i! @1 X9 R1 C# B8 @ - */
* B) S z T8 {, P2 n7 }
1 d! n1 ~# ~ d, P! d- #include <linux/module.h>1 c; ^9 \2 K+ k+ t
- #include <linux/init.h>5 F# }0 A$ w) z" A/ b
- #include <linux/errno.h>0 \" v6 o1 \3 d+ I& a2 ~! n
- #include <linux/types.h>, m2 ^8 A j! m4 W+ o2 X8 u, z
- #include <linux/interrupt.h>
# l* r0 U, T: h0 T" Z) c1 J! w - #include <asm/io.h>% f9 q+ O" r8 _; I( x# |
- #include <linux/moduleparam.h>1 ^) x+ G1 G) [
- #include <linux/sysctl.h>% j- `/ W; ?# P; |. O& V0 Y
- #include <linux/mm.h>
! t6 x1 o7 z8 X% j0 E3 Q - #include <linux/dma-mapping.h>
) V/ e A# n4 m* H* |5 e T/ w
! A8 o/ u7 E/ p4 x- #include <mach/memory.h>
}' W, @/ y% H( O+ @$ X - #include <mach/hardware.h>1 K8 c/ j$ o O
- #include <mach/irqs.h>0 S6 ~' g o1 j4 `$ u/ Y
- #include <asm/hardware/edma.h>- N' B5 ?, K7 W; T- x7 \$ M
- 2 L+ d! V2 ^0 O8 O* K$ ^& [, p
- #undef EDMA3_DEBUG* B+ X+ X2 t! y0 u) G
- /*#define EDMA3_DEBUG*/
* U6 M/ y3 V: d, f! o - 9 A3 B' a! h5 _
- #ifdef EDMA3_DEBUG8 q# H2 }0 @! I& N! h, q
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ b# S% @- `/ M D0 i) c - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 ^, s# q/ E# v/ O' B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ Z$ V+ Q& ^1 N- h" c6 y9 [ E0 L - #else* I2 }- Y, L ~/ G3 L% w$ F+ l
- #define DMA_PRINTK( x... )8 A! e, U8 _' K- [; m& o; K
- #define DMA_FN_IN; j$ ` X( m! c3 t$ s* J8 L
- #define DMA_FN_OUT
9 J. o3 ^8 [6 _; o8 w+ ]2 ]9 _" w - #endif
: G0 c4 v1 B1 W2 D) ^8 t6 D5 e8 _8 F- p$ |. E
' q; \( ]/ f- a3 w- X' ^5 S U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" E5 s! K* M. z. }4 S) b& e
- #define STATIC_SHIFT 3
: B' ?* W( P! Y0 n - #define TCINTEN_SHIFT 20% @6 ^; |9 B( k7 h. p+ D
- #define ITCINTEN_SHIFT 21
1 M h7 e2 C% { - #define TCCHEN_SHIFT 22
' p$ e& p) ?7 {$ R9 R4 X; C# j - #define ITCCHEN_SHIFT 23
) r+ K9 l3 R6 G7 k7 m- h5 ?, Q - T8 E6 f! t" Q/ n9 q+ |
- static volatile int irqraised1 = 0;
: Y z2 X, I/ R - static volatile int irqraised2 = 0;
- c) v/ n$ i9 U2 }3 h7 ? {% F( { - , U$ p9 F8 B- f2 p$ N$ I
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( z3 @; i1 Q. @( `' b
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. R$ f% d* b; s2 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 N4 A3 C- P2 O" f
6 Q2 A6 F. L: k k R- dma_addr_t dmaphyssrc1 = 0;
- ]7 L' _/ m7 Z9 `% [: p - dma_addr_t dmaphyssrc2 = 0;6 {) m* \% o$ o1 P5 c
- dma_addr_t dmaphysdest1 = 0;
. s, D* p6 d+ B: ?2 P - dma_addr_t dmaphysdest2 = 0;
/ P1 @1 Z3 C' m, j5 m( ?* N
% k; C$ o# J, D6 z, M- char *dmabufsrc1 = NULL;
) M0 O0 ^% R3 S0 J( f - char *dmabufsrc2 = NULL;
; M9 ~1 T* k$ \: M1 g - char *dmabufdest1 = NULL;# l. a! l5 e, M. H
- char *dmabufdest2 = NULL;3 U: C* r3 ^8 x# G4 K. C7 y: a
- , I& F& h, v; J j# ]' v5 }
- static int acnt = 512;
- Z7 G' `3 R4 P" ?5 | - static int bcnt = 8;) [; x8 r. D2 w' j. Q/ b1 E4 _9 t' J
- static int ccnt = 8;$ d+ l3 R% `! Q9 ^) t I
0 O6 R8 V) M& T$ @1 ]1 H- module_param(acnt, int, S_IRUGO);0 W! F' H- H+ U$ d l
- module_param(bcnt, int, S_IRUGO);/ R9 J9 ^ ?+ ^# ^* C
- module_param(ccnt, int, S_IRUGO);
复制代码 / F$ m' x% n" J( ?- S8 l
, T- g% ~; G/ m
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 E3 w* P' R9 B& f! U% J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- D q' d8 q! h9 d. g5 o" r1 P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 m2 g$ Z2 ?; x- f
g; X0 c5 l! \3 D
" J6 T- a6 R' e7 n# J |
|