|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( L' r, r, A- Z% l* s. t% O
- [code]EDMA sample test application
3 ~ b* ]4 p6 D& }6 p - /*# Q4 Q0 \/ T- f2 c/ X
- * edma_test.c( I2 E/ j' ]3 D
- *+ c9 {. |7 V5 V/ z5 n: ~+ v
- * brief EDMA3 Test Application
) k; D! B1 Z N2 P. M7 I7 c7 K - *
' k* q& z; z' S* U& S- ^- b - * This file contains EDMA3 Test code.
2 Y6 z' {: ]% n0 E2 J% \ - *& Q" p) a4 f# Q: G' f, P: E# }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- V2 m( }3 `2 E. q/ r# X" y2 } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 F; F' a* c9 ], ^+ f% t
- * TO CHANGE.
0 j# T) f, s, \ - *- z( h9 J _1 X, N+ [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 q6 k& k# G8 o* H# {/ r - *% \( ~: s* X* q7 Z5 Q$ [( h2 b
- * This program is free software; you can redistribute it and/or
& _# M4 E. M6 S - * modify it under the terms of the GNU General Public License as
# y$ ^6 S1 b) v, `- b( W - * published by the Free Software Foundation version 2.# }) o9 Z- _& @. ]+ Q
- *
7 P, {- v$ f% |* K" Z3 J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, Q$ Y$ O/ `, F: o9 L8 l - * kind, whether express or implied; without even the implied warranty
- J/ ^ J- [1 g9 m6 J - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 d u$ c8 M0 {# Y4 `& g1 P8 T
- * GNU General Public License for more details.
Y/ z' q3 J9 n; @ - */, m& C6 T6 y B" O" T
# ~+ C e( g7 W2 ^& ^- #include <linux/module.h>: j+ R' k# a( Q( L7 T
- #include <linux/init.h>
: {$ f4 u# M; {) f - #include <linux/errno.h>) w6 [$ W3 l5 G4 I# t! F+ B
- #include <linux/types.h>
0 O1 q% I; ^ Z: d# P9 b, ^' p - #include <linux/interrupt.h>) x8 T4 o' N) g" `. n. @
- #include <asm/io.h>
0 u3 V5 F5 J h! F. j1 \ - #include <linux/moduleparam.h>
' u8 R! g: J! E# |( h - #include <linux/sysctl.h>
* q) L+ D; k4 Q/ c - #include <linux/mm.h>
- ?8 E6 z2 H) H! Z+ K# d - #include <linux/dma-mapping.h>) o; l& e# _& D3 _* w
- & J# U) b. `, N* }& d
- #include <mach/memory.h>
& v. L2 r9 C" w$ N - #include <mach/hardware.h>9 @" U, h- w- Y! ~. l7 u7 n
- #include <mach/irqs.h>
: _7 K' c( R3 S, k - #include <asm/hardware/edma.h>! x. ]' o7 Y* \% t$ Z9 f) b
1 y# E: S. R# V3 h0 f$ ?; [- #undef EDMA3_DEBUG
( p) }/ M: ]3 X - /*#define EDMA3_DEBUG*/
' H2 Y. y; K6 E7 D' L6 t5 y! ^ - 9 a: G& J/ {4 ?) k/ u0 |- B
- #ifdef EDMA3_DEBUG
+ o8 `" w( `3 ^5 Q+ d# A$ g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! ]! A* Z r, ?! j# W6 i: i - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# f9 N7 f# N( ?! G' V/ T$ m
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 t! ?5 P- i* Y* m( R3 C1 u- c2 t6 r
- #else
' Y$ o: t+ M# r7 H3 S+ w; ] - #define DMA_PRINTK( x... )$ x5 l: \& z$ q* \; r- P: V( c e, Y
- #define DMA_FN_IN2 n+ P; `8 q9 [& ]/ a3 f6 b7 x0 _
- #define DMA_FN_OUT
# C4 w- n4 _: Z/ s - #endif# @7 s3 b- C w6 F4 W
5 V* r' i4 x' x: p9 B' q- Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768), V0 h) ?: r& U/ f i& w! u
- #define STATIC_SHIFT 3
. H% O. P: t( a U& k6 X+ M% F - #define TCINTEN_SHIFT 201 a; I" J& S7 \9 k
- #define ITCINTEN_SHIFT 21& D, s1 ?8 k( L2 j n
- #define TCCHEN_SHIFT 22
' {, z( ?6 g" k, ]" E. H8 K" Z - #define ITCCHEN_SHIFT 23
3 U% n6 h& Q8 _% t0 o/ J
+ j4 M# p' I) S4 ^ h5 k- static volatile int irqraised1 = 0;" X6 o8 ]8 d+ S
- static volatile int irqraised2 = 0;, x1 g8 l+ t# J/ D* e. g- s% D8 ~
- 0 ]: `3 S$ x3 x$ m: W. p7 R. d
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 I6 o3 `! v9 E - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 B, C8 t, O' Z% p/ J5 Q# h
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& N, B7 W7 F5 e. `# ^
: Q/ r! }" O [+ ^+ n- dma_addr_t dmaphyssrc1 = 0;6 F& V1 d: W1 _5 G* L
- dma_addr_t dmaphyssrc2 = 0;
- h3 u* C% c I - dma_addr_t dmaphysdest1 = 0;
7 I, F% u6 ?- R - dma_addr_t dmaphysdest2 = 0;
* E1 g l1 i6 O" s- i/ n2 R4 Z$ {9 L - 1 E) E1 C% ~4 |
- char *dmabufsrc1 = NULL;4 q, ~3 s: r# u& a& h' o2 b
- char *dmabufsrc2 = NULL;
7 G, H9 l9 `( [' }5 g$ _& H - char *dmabufdest1 = NULL;
' L0 d# |1 p- X, [ - char *dmabufdest2 = NULL;+ @& k+ J0 {+ b8 C" x5 U
- 5 {" |, s( j, B
- static int acnt = 512;- {# J( M4 }0 A0 v
- static int bcnt = 8;
' O; b' N. x0 }* R - static int ccnt = 8;
! L0 _9 V3 o6 w& M2 H5 z" t% e - 0 g! N2 l; H6 X, ?4 Q
- module_param(acnt, int, S_IRUGO);3 _/ v# A& Y' j( z( x& \
- module_param(bcnt, int, S_IRUGO);
# y% N" }5 C2 h" ^) W - module_param(ccnt, int, S_IRUGO);
复制代码
' Z2 ]8 X& v+ b6 I) M# J9 C/ g( M7 F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) D, }) w! D8 c. }* {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 }' g: h2 s) O) {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 D5 O0 C# ]! F) V0 n/ i) \/ ?. s
6 Z5 W# }$ w6 x) i. P/ s0 f/ f W
|
|