|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 V8 v: T) Z+ y7 ^8 O- [code]EDMA sample test application7 g9 r1 w: T3 v6 G; R
- /*5 g5 y9 t+ T) m% t
- * edma_test.c
3 D9 d& Z W3 a* t" p! Z& U - *
: I- }( W! W" B9 I) J - * brief EDMA3 Test Application/ W" h! P# X! ]- O- \. A
- *
- i1 X8 f& w4 M* e; s" W6 Z' e - * This file contains EDMA3 Test code.* n$ F8 @' a3 V
- *
1 c, e5 Q) I/ J$ f) W s - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 E' e+ c2 j, @7 c. m3 W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) \; a& N) D+ R/ s* p* \+ O - * TO CHANGE.
6 Z/ ^+ Q% f! j# E: ], P - *
3 ]9 R+ p' Y" O7 H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; V8 g) M. W; t4 Y
- *
7 Y% b0 C) j6 z; G - * This program is free software; you can redistribute it and/or
* W1 F8 {7 O; u) _% C6 b - * modify it under the terms of the GNU General Public License as
7 Q$ z9 \' r% `) a$ u4 a2 \8 M: t - * published by the Free Software Foundation version 2.8 m; N8 u' j" R9 z
- *+ m1 J% \0 m- H D6 g6 z$ g0 _& P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* O/ Q; N9 s; r6 s$ k6 C - * kind, whether express or implied; without even the implied warranty
( Z( h3 I6 {( T* Q2 E& z! {0 d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# A* N4 | J5 J
- * GNU General Public License for more details.& U4 n. j* `) ~
- */
L+ e" ^7 A0 J" F
1 ?( \4 Y; R$ h8 |0 \- #include <linux/module.h>( \: N+ M3 a/ j4 S8 t) N
- #include <linux/init.h>5 Y- A! n& f: b7 A
- #include <linux/errno.h>: C( B0 c- S! O
- #include <linux/types.h>
! U; P; J) b5 d/ @: y% y/ s - #include <linux/interrupt.h>$ d3 M9 N( F. J% v4 M
- #include <asm/io.h>/ p! W: j) `" Q( e3 b. B, {
- #include <linux/moduleparam.h>3 L ^6 m7 Z$ Y# J& S
- #include <linux/sysctl.h>
, M9 ]) H2 U# C; l$ Q$ ^ - #include <linux/mm.h>
. W: T/ L9 S9 F7 }$ G( r5 f) v - #include <linux/dma-mapping.h>
0 U1 V! x( P+ g8 @ - 4 ?) [8 G9 J: N4 P2 E
- #include <mach/memory.h>1 J4 j; ], [/ c' L# g, |' `
- #include <mach/hardware.h>
0 X6 V: U5 }$ h9 H( g- a - #include <mach/irqs.h>" r1 X {+ K+ m# E b
- #include <asm/hardware/edma.h>
( u) y6 d3 w6 b3 \- D0 k9 K5 V - ( Z: g9 ?/ {+ v" C
- #undef EDMA3_DEBUG- Q2 J( x) q4 }/ t- c9 {# n* F
- /*#define EDMA3_DEBUG*/
. X9 Y4 _# ]3 ~
7 \, c: ?2 H) A. c; q% Z# L& n( A- #ifdef EDMA3_DEBUG
7 L5 ^9 ~3 E4 i1 e6 o8 ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ v5 y1 ?2 G9 c3 P1 a6 M - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% ~, W) P( X/ V6 V1 f
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 k; ?5 W( ~5 s9 m3 P6 i
- #else
: n- C0 B3 D. X: v2 a1 G& ^' n - #define DMA_PRINTK( x... )
$ {6 Q& r2 k! g+ k - #define DMA_FN_IN
( z; F3 z* ]/ L+ p! ]2 W - #define DMA_FN_OUT! T% D" g8 q. K# { W
- #endif* F$ O7 H. S' P$ T8 p" J# X% s3 ]
- 1 B$ T% l7 ]" i+ U, }) w J$ x
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" H) J, q z8 y; s - #define STATIC_SHIFT 34 {8 \- ^' J8 J9 W% g @, f
- #define TCINTEN_SHIFT 203 { ]! N. m" C" m7 A' F# M
- #define ITCINTEN_SHIFT 21; I( L& D: Q! ~- P
- #define TCCHEN_SHIFT 22
" r2 W# Z6 {0 _" ]! q - #define ITCCHEN_SHIFT 23
6 R% `$ O+ [ v2 O- Z2 U/ g
1 r o. c4 B8 Z- static volatile int irqraised1 = 0;
8 w o- b, Y: C* F - static volatile int irqraised2 = 0;
% z0 U8 h# o, v, U c. `3 Q4 x
$ Z# D" e9 E u( r* o; x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 ~* f2 Q% M! A. a$ |2 [: P - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" m$ V- \& e* v5 H8 V1 h - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: z: E+ V8 F, [* P7 U
- & X/ t) _ n% q& p
- dma_addr_t dmaphyssrc1 = 0;! f; K& r9 |# F% ?6 u d3 ~! ]
- dma_addr_t dmaphyssrc2 = 0;
/ x: O2 R5 {. d - dma_addr_t dmaphysdest1 = 0;" ]/ d, F. ?& ~1 |- j( k
- dma_addr_t dmaphysdest2 = 0;
% V5 K, G# g; t% Q9 R) X* |
. m! C2 Y% g( T) L4 N- char *dmabufsrc1 = NULL;
7 Q- q( V; k$ n4 T. M - char *dmabufsrc2 = NULL;) @6 l3 ]' H# K$ G5 a, V: a
- char *dmabufdest1 = NULL;
M( g. A, ^8 V$ {1 ` |! k' g - char *dmabufdest2 = NULL;6 u. n D1 F; ^% F# m/ ~4 q' W0 X
r" p2 a+ v$ \4 \- static int acnt = 512;7 E2 E4 B3 r2 w3 k2 X0 n- ?( c! Y
- static int bcnt = 8;
5 {2 [1 c8 {+ w) w: I - static int ccnt = 8;. M7 |5 s# D0 I1 K" X
- 0 ?" h4 d0 ?' z# P
- module_param(acnt, int, S_IRUGO); m7 T% z: W+ I6 L5 X
- module_param(bcnt, int, S_IRUGO);
3 i. \# ]- c% c* k" i) L - module_param(ccnt, int, S_IRUGO);
复制代码
& h) j- }& d& G# e8 n& C; L
9 M W W& E# n2 S& K7 j* Z- }8 W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) r% o6 B- G, s, Z* S' U. Jarm-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 V2 y' A$ F" O! L- f/ g$ _8 q9 ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. |% k" z" j6 a- T: `3 r
G l& m9 n, g3 N
. A/ W+ U2 K3 g |
|