|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 H/ Y& g2 e/ r# ?% G; U/ Y- [code]EDMA sample test application
1 `" E# w& n2 o# _( n" y7 S - /*
, a! i R* r W1 A* g - * edma_test.c' ]& E, A5 `+ W7 _
- *) S! V; F' z( s7 [8 E1 L; G; ]
- * brief EDMA3 Test Application
5 X6 a2 d! i9 Q/ H/ o8 ?) }& Q - *0 i5 m$ ^4 ^% S. f7 t' Z
- * This file contains EDMA3 Test code.# ?5 ]' u2 ~% M' A# `" P
- *
# y* `4 Y' A( \4 X! {5 ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ ]' _/ O4 _8 T
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 S" n8 }; Q( k% v1 b v - * TO CHANGE.. q6 p+ o, D# _ K$ q2 _% ^& t5 N
- *
) A6 T/ p& L2 }% s6 C2 y# ` - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ c7 o2 b+ ~! v' D6 Z- g - *
3 z. K- R0 Z! I/ J - * This program is free software; you can redistribute it and/or
8 F! M' R) R y1 N g" u - * modify it under the terms of the GNU General Public License as" @- Q3 i( U# c' h9 c9 N. z
- * published by the Free Software Foundation version 2.
2 k, k$ H7 v3 g# v- z6 G' I/ l - *8 W+ P( M; `0 x
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ i& P$ |+ k3 d- X! z. ^% s6 i" L$ e: J - * kind, whether express or implied; without even the implied warranty/ Z9 ^4 z! W, f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ q E* T( y# \$ p2 J2 M( z - * GNU General Public License for more details." w" ]- ^ v4 z% E6 N
- */
9 W! X4 B6 ?4 [% Z8 z0 J3 }+ G
5 E* t5 b7 b3 V: e9 B# G- #include <linux/module.h>
* V8 M R$ V- j+ q' d2 K3 L6 t - #include <linux/init.h>5 @7 ~/ I6 L$ ]& x, _* } [! k" I
- #include <linux/errno.h>7 q/ ~5 n" B8 t* Q! o! T. @8 R+ P
- #include <linux/types.h>5 g) i5 X7 W. K! N8 ?
- #include <linux/interrupt.h>
) B9 @# Z& z' j. V - #include <asm/io.h>. e3 B. m% g" ~) D; r% e
- #include <linux/moduleparam.h>
4 H1 X: k" D$ ?. Z) S7 J7 o3 q9 o- | - #include <linux/sysctl.h>
2 G7 k) k* ?& C& l% \1 P - #include <linux/mm.h>
" p- f; u/ z; g5 S- t3 K3 Z - #include <linux/dma-mapping.h>
6 M" m" P5 F {+ k- [# S+ N; m2 c# v
7 o6 J( ~* y7 A) G% e4 Z' X1 C- #include <mach/memory.h>
$ G3 K! @ D! e5 }$ |# e - #include <mach/hardware.h>
5 w$ {' s9 {) u - #include <mach/irqs.h>
; b! V% U3 U8 A8 |* ?; m - #include <asm/hardware/edma.h>. t& Y( C3 A5 g& D
* c9 A0 r, n4 J9 p' C2 ^+ b) e5 L- #undef EDMA3_DEBUG
4 _* p% l' X6 \- |7 F: k - /*#define EDMA3_DEBUG*/
2 E& x$ d4 s3 E, E- o8 \6 {
3 s8 v4 A6 x" ?0 `- #ifdef EDMA3_DEBUG
; l- T- v) [5 G0 N6 x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: e2 \4 H2 e; Q$ F& m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 r1 c/ y s# J4 N
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 [1 Q( A' h0 m% r - #else% @( n" J/ Z! S1 z) y5 x8 u6 a) ~
- #define DMA_PRINTK( x... )& o h6 S0 }' J
- #define DMA_FN_IN
3 W& c" X4 h5 |% k G; Z - #define DMA_FN_OUT
3 K5 O; n( \) n3 V% t5 T9 B7 W" k* l - #endif6 [) a$ Q' Z, u+ |# L
+ g9 k2 Q, p; n- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ N( k A* d# @$ m - #define STATIC_SHIFT 32 n: f0 u( H1 B% R3 M
- #define TCINTEN_SHIFT 20
6 g- R- {% Y3 t - #define ITCINTEN_SHIFT 21
7 q. J. I6 p3 B) n - #define TCCHEN_SHIFT 22
5 }, B; l. {% }& @- T+ O* J+ b8 U - #define ITCCHEN_SHIFT 23" O: ]5 G; v3 V" q
9 V3 V5 @- D8 B- static volatile int irqraised1 = 0;% R: I: {* D; x7 O) a+ J8 v, Q
- static volatile int irqraised2 = 0;8 H! k2 Y* D3 @# J$ D. E" X
2 G* f; }" n& n0 ?- Z7 E+ G8 Z$ z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 `5 G/ K6 |) Q2 r. Z E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' C5 \/ h* L' a4 j! u1 b! i5 x0 G
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 ?+ C5 S+ F k* ?/ {- r8 i
- 2 J% k6 ` w9 ^" O
- dma_addr_t dmaphyssrc1 = 0;' t" P6 t4 w6 t: m$ M- T) @
- dma_addr_t dmaphyssrc2 = 0;* \0 @. M- B) y, Q
- dma_addr_t dmaphysdest1 = 0;
5 F1 N% V4 c6 D# H) N7 o+ N/ x - dma_addr_t dmaphysdest2 = 0;
- B1 b8 w7 d$ \' ~ - 7 O: x& v& _4 m7 F* t7 a3 ^
- char *dmabufsrc1 = NULL;5 `; d z* _" q6 Y+ Y
- char *dmabufsrc2 = NULL;7 ~& a% `- s5 f `& Y: |
- char *dmabufdest1 = NULL;( r3 g* [' W6 V# q
- char *dmabufdest2 = NULL;4 a6 n# Q! T) j/ T
; d0 g" ?; C; ~: a% t- static int acnt = 512;
( v6 k( c( t$ |6 m3 p% J5 ~: N - static int bcnt = 8;( Z A0 [- q2 r" B3 |$ O
- static int ccnt = 8;
0 r2 L% g* r7 G; _ ~# S- Z - + y- M) _% b$ O* w
- module_param(acnt, int, S_IRUGO);* u& [- t3 W& B x8 W
- module_param(bcnt, int, S_IRUGO);
: l' _4 }$ W; u3 P - module_param(ccnt, int, S_IRUGO);
复制代码
6 m3 A! Z& ]6 Z: d# r2 @% x% Y8 H: H9 P! p. ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 j, I" @' L, p Q! earm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 t- Y$ {" q; ~% ?! `/ U6 ?2 x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
1 b0 @- x5 o- m8 \- O2 c |: N1 X5 Q8 `
& s. T# k6 d6 j5 `2 u
|
|