|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 U6 @$ Z1 a( U, q; j/ z! t- [code]EDMA sample test application
* u- V3 S6 y) }/ p! a4 t0 o - /*, a/ P9 B6 r8 @) u5 U( ~
- * edma_test.c
7 O! w0 {" u5 h& F! F/ w - *7 r/ Y O' E( ?/ y9 {6 H
- * brief EDMA3 Test Application9 y/ H l' ]4 y" k7 q( v
- * R; S% ?9 L. x3 e. ?
- * This file contains EDMA3 Test code.7 J, O5 q7 D' m& C
- *6 E I/ q0 N# q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
9 K% L% D) w' q/ w - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ T9 m% @' E( n" t - * TO CHANGE.4 @ Q, s5 f3 k# |3 D
- *
) ?- V: W. P9 e' c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' [3 S1 [) ^0 y+ b. ~4 y - *! b3 G' c! D4 _& Y9 l
- * This program is free software; you can redistribute it and/or
$ v" |- @5 P5 T3 O. m0 V( B0 z4 O: W - * modify it under the terms of the GNU General Public License as6 }- m- \8 f! ]9 S G: E9 S7 \3 H
- * published by the Free Software Foundation version 2.
' g' h# q; q) S" P" ]5 h) f: } - * ? [0 M* H5 G& h5 P; \0 n; i7 p
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any. `9 \5 ~: I6 \- l6 d @. V3 v; L! B
- * kind, whether express or implied; without even the implied warranty. X( \$ Z, U# y( e# X/ U; n7 D
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 ~# n6 b! B+ ?3 m0 r" ? - * GNU General Public License for more details.
, C" G( i9 j/ w. P9 y0 f. g$ R - */
9 R- v6 ^5 c" y# k1 }+ J - # _- g3 W* i: {" E
- #include <linux/module.h>* v0 `. ]9 g4 o5 X
- #include <linux/init.h>
- n4 K9 z0 E& ^" a5 n' T - #include <linux/errno.h>
& P% B6 W' h( E# o Z - #include <linux/types.h>- s: x( ]( t- v# H
- #include <linux/interrupt.h>! l% Q4 ~9 r* A& H- ^& C
- #include <asm/io.h>% V3 n9 E! ]3 V |
- #include <linux/moduleparam.h>
4 {( f3 W- P) E5 Q - #include <linux/sysctl.h>
/ p; ~. A6 j9 N! M - #include <linux/mm.h>
% j9 s4 b. j* o - #include <linux/dma-mapping.h>
1 g' A; }1 L+ a1 r& h9 x! j! t - % X3 G, Q# D$ V& R' F
- #include <mach/memory.h>" ~+ e1 o; v- x* O9 C6 m
- #include <mach/hardware.h>
0 k; a8 K) @( G' I - #include <mach/irqs.h>
8 F: Y6 `2 T5 O3 g6 _* F- I/ ] - #include <asm/hardware/edma.h>
* i' ?8 a% ]+ k P! s. x
3 n$ }/ U% A+ Y+ C) v- B. n- #undef EDMA3_DEBUG
# o$ A1 z+ Z2 l3 [4 \: R - /*#define EDMA3_DEBUG*/% d5 Y* a0 f4 z4 i# G! B; G. P5 e
- : p9 m* a/ D$ l! o
- #ifdef EDMA3_DEBUG
8 s9 P2 ^9 ]# B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" [ x; i5 y( J! D; Z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): x* c, F0 b: R
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 g( P( y. E: u0 {: @/ M% \ - #else
/ k* r' N# I: Z - #define DMA_PRINTK( x... )
! d/ E0 w1 X0 t4 ]5 j7 c - #define DMA_FN_IN
+ V/ S9 v* D) b - #define DMA_FN_OUT
" D( w. Q g8 R/ P: R - #endif
! V9 d& D3 D' ~- j$ ^0 v; O" u M9 q% z - 2 ]1 R) U% [, j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 z" V8 q9 |# {& N# w - #define STATIC_SHIFT 3
0 e3 }' v9 v" y8 a - #define TCINTEN_SHIFT 20
5 H4 a6 k/ \ \6 `/ g) B- j+ r - #define ITCINTEN_SHIFT 21
4 d" m. N/ @% |/ p0 I( l - #define TCCHEN_SHIFT 22, B8 v+ @6 U. x( }; s1 I
- #define ITCCHEN_SHIFT 23: U0 B( \. e, r* a* P* @7 j! I) h( f5 m
+ r6 ~/ H7 `6 f7 j( V( o- static volatile int irqraised1 = 0;+ w1 r8 N7 s. e4 x
- static volatile int irqraised2 = 0;
1 V K9 q. m3 k7 Z3 C
1 c5 V% ~) `/ W2 Q$ a' a- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! c8 d1 F) Z z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 H3 r8 v+ c9 ^; C3 H7 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" H6 W" M! s' E, z5 ~
. L u3 s5 p+ _' j- ~% Q. F- dma_addr_t dmaphyssrc1 = 0;$ {% z- n: G$ H0 K( i1 A, U" W
- dma_addr_t dmaphyssrc2 = 0;
7 O) E! A/ j2 }+ V - dma_addr_t dmaphysdest1 = 0;
4 h- y/ e2 N6 n8 d& ]8 P2 t - dma_addr_t dmaphysdest2 = 0;
" }/ E, I& \# G& a# a3 l - ( L# w7 L9 B0 V
- char *dmabufsrc1 = NULL;0 `7 k( z! {; I& x0 v
- char *dmabufsrc2 = NULL;- C5 `; q4 W3 }2 ^( u0 j
- char *dmabufdest1 = NULL;5 U+ u$ k2 V. o% L' B1 P$ P. `- ^
- char *dmabufdest2 = NULL;
5 e' m/ }+ Z( ?/ c1 S' G9 K
2 Z- E$ u I o5 O/ R" i- g- static int acnt = 512;
6 v! B4 A6 J& _ - static int bcnt = 8;
% ]9 j( c$ |" a5 E$ { - static int ccnt = 8;
! P2 v/ z7 }: J }3 V! d& W N
5 B& p9 | f! Y' D- module_param(acnt, int, S_IRUGO);' ^8 m2 `$ J( u, f
- module_param(bcnt, int, S_IRUGO);8 B! \: U; U' {( Y
- module_param(ccnt, int, S_IRUGO);
复制代码
& [9 B! U' b& O1 H( v" V
/ h0 i9 u# Y6 t1 z! j 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ x9 ?* c+ O; r9 W' L; o# |4 V
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。9 v0 }7 S) t% C6 F1 U& ~- e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 e/ L5 F! T, g' e7 M
+ X x- J9 X6 `7 Y8 [: C$ S8 Y. e% T! q/ Z. ]; g
|
|