|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 Z d. s. n( [- [code]EDMA sample test application
1 D# g. L$ u* F/ T+ v - /*
5 x$ j% H2 }8 t5 g - * edma_test.c D5 r9 X1 d9 h2 G( y4 |
- *5 D& p; J* G" F6 s# `
- * brief EDMA3 Test Application
$ x6 q/ A% `, h6 Z- R0 D: r, @5 N - *4 R4 I8 d6 G* d$ p4 ], j7 B
- * This file contains EDMA3 Test code.
- D- L' Y c! M& B- u6 J - *
1 F, z$ {& t) w: Z. h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# q' {: n4 j8 v1 P% O - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) ]* P* w3 T: g: v - * TO CHANGE.
% f# i+ `: o4 f) c& A! U - *$ s- [$ f2 P" i9 ?/ I/ A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 ^! r" T9 q4 B& z" y - *
2 _% ]9 i7 a& b) U' ? - * This program is free software; you can redistribute it and/or q4 W6 D) b i( v* F
- * modify it under the terms of the GNU General Public License as
6 |% [1 H, c* j/ r2 s - * published by the Free Software Foundation version 2.2 H" D8 k H+ {/ u
- *$ m: X* `' d6 o, y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 R$ e% P2 o% Y" F# C" O* H - * kind, whether express or implied; without even the implied warranty
) c% F& t* W6 i - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) y& `* G: u1 N/ C# `3 B7 b/ C U
- * GNU General Public License for more details.% t3 _$ Y1 ?1 f+ _2 j- w% ]- U
- */
. o5 N) g) r% a3 k7 K
- P6 T) ] x6 ~+ a9 H4 L- #include <linux/module.h>
9 U( v; k( k: D5 j# Q, f U) E0 j+ c - #include <linux/init.h>
* R1 r7 n7 C9 h- f$ t1 _ - #include <linux/errno.h>
+ o. S) O% w1 Z3 b, _" f1 \8 q - #include <linux/types.h>
# m5 r7 ?, F0 R0 Y3 [ - #include <linux/interrupt.h>
* E. z5 H) K, ?' R7 @: Z - #include <asm/io.h>- l" }- Y! d! Z
- #include <linux/moduleparam.h>
3 Z! I+ q* [2 L; ~" F, H4 ` - #include <linux/sysctl.h>9 b V$ @" P, f: {
- #include <linux/mm.h>
* D1 ~5 r7 p5 G/ w% [5 ]" D - #include <linux/dma-mapping.h>% M) g; X7 d# m+ X% c3 R+ m i
- 6 a; u# f- q- G* X e. X
- #include <mach/memory.h>. J' t, Q& w6 z5 h- ?
- #include <mach/hardware.h>
. [9 h* M& h7 h( i6 x+ s+ i- z! z5 } - #include <mach/irqs.h>7 d6 F( i" p$ `$ O4 ?
- #include <asm/hardware/edma.h>' o. t* l9 F; f, p) D3 o' A
- 6 r! B% h# M& \) o: v
- #undef EDMA3_DEBUG
5 p$ h6 O( p) J - /*#define EDMA3_DEBUG*/4 W9 z% B2 a9 _3 N
- + J) Z6 _7 C7 ~9 S& `& C: v/ R8 Q$ d
- #ifdef EDMA3_DEBUG, v1 \- b4 F) S3 e& R# @ Y$ }' l
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 D! Q8 u. ^/ G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! Z0 R, C `3 Q& I/ e) o* L
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 @) C. a; J/ d' Q; j1 ^( R# B - #else" i' K6 {! i/ E: |+ u8 A b
- #define DMA_PRINTK( x... )
$ N7 L2 I7 c5 p( y) \ - #define DMA_FN_IN
' | b& t3 G# C: s' y! e - #define DMA_FN_OUT1 f" F& D( e1 o6 p5 c/ d# I: Q" j4 _
- #endif
! W' @4 Y# |, o9 P
( y2 c/ l e: T. b, c' S6 C- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ i/ }; D9 U" m7 L
- #define STATIC_SHIFT 3
5 U- J$ j# a/ R5 d& F* s4 E3 H+ \ - #define TCINTEN_SHIFT 20
. M$ C V d% V2 j! X% M$ D3 L- R5 I8 X - #define ITCINTEN_SHIFT 216 p8 \$ Y8 V; q' l8 E
- #define TCCHEN_SHIFT 22
8 D |9 |5 K2 [( q& O - #define ITCCHEN_SHIFT 23/ ~! K g$ L8 v
- : s# k& n% t2 s% e* F
- static volatile int irqraised1 = 0;
; D+ ^! } q5 h; m8 Z5 j" O8 d - static volatile int irqraised2 = 0;# z8 J6 s8 p1 o9 Z7 p% }; t
+ z' \# k S5 \% {. d& H! i- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 S$ Z+ S2 b: `* z& C, M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# B/ I- `2 Y: y' R - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# t- m! w( Z, X( Z' E- \
- 5 u: W, c; O2 G$ V* X
- dma_addr_t dmaphyssrc1 = 0;
3 A) I% P. `6 k1 G# x - dma_addr_t dmaphyssrc2 = 0;- N/ q0 m# g! O6 b7 M' W: L
- dma_addr_t dmaphysdest1 = 0;
' z7 Y! r- T7 ` - dma_addr_t dmaphysdest2 = 0;. ?! b" F9 s5 P. h7 G
4 K- u' L: D; X" I1 _' v- char *dmabufsrc1 = NULL;
* O* _9 n% {+ [3 i/ p - char *dmabufsrc2 = NULL;4 i/ S. F( m$ i9 F' p9 F6 H4 J
- char *dmabufdest1 = NULL;
4 s( C4 `2 }: L4 ] - char *dmabufdest2 = NULL;
# B6 }* r5 g8 G: ^. [8 ^+ ~& a - 1 p, `1 \$ p& M' n( M) c
- static int acnt = 512;% g$ n" ?, u6 ~
- static int bcnt = 8;
. r8 ?/ u% _# B; |3 t: ^ - static int ccnt = 8;" z; M% r$ ?1 h5 \) g
1 M) D" T( [3 r5 \. A- module_param(acnt, int, S_IRUGO); g( b0 T$ r, p% ?2 t
- module_param(bcnt, int, S_IRUGO);/ ]; u9 {& V2 R- X3 ~) ~# T6 H+ M
- module_param(ccnt, int, S_IRUGO);
复制代码 3 ~. u+ l' H Q/ V
' \9 s" E8 b% M' ^2 C1 B8 H, n; }3 R8 r
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 ]8 d' N8 \/ x- B+ B! E/ A
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
* n- V7 z2 k; t8 N6 B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* p5 ?9 |8 d6 f, i
5 Z+ A# |& X; H H# E
& p; B6 A6 w2 Q; ?$ j |
|