|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; M6 r" Z$ t2 }+ `, }" _- [code]EDMA sample test application+ D# b3 @/ K1 X7 a, ]1 R+ N- I
- /*9 ^8 T3 _, K# l2 H* U
- * edma_test.c
( H( I6 F9 q1 F! @* f, N - *# y) R7 [* |! a3 y6 J- F& m
- * brief EDMA3 Test Application; e- a8 k9 d6 B9 p* s! u: E% M
- *
& o: z! a# v' x9 h; F, ^8 I - * This file contains EDMA3 Test code.
2 s9 R |8 n# b$ Y! f - *
@, U* [0 Q- L/ w* H# u - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& b; v0 r( A9 Q( H+ |& ^2 Q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) y2 s7 r) @" z J2 ]( F0 I" W - * TO CHANGE.4 B" w- O+ h4 y
- *
* C6 j: K9 V( q% x5 h! H0 g - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 D: i1 a. c2 k$ S6 w - */ i; `* M0 [$ X2 I0 u6 [- e) C# |
- * This program is free software; you can redistribute it and/or
& e2 N, P" Q! A% H% d0 h. V8 t - * modify it under the terms of the GNU General Public License as! N$ Q/ n2 U% S5 M; F# L
- * published by the Free Software Foundation version 2. [ N* I3 D: ?) ^
- *
z$ c5 v) q3 ^, _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ M, P- X) B! G- C" o; H. K! @
- * kind, whether express or implied; without even the implied warranty0 J* v! a& W: M8 D& K
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 K; G) J3 b# c Z0 p9 U- U5 m
- * GNU General Public License for more details.# C2 o0 L" ~" P( r X! y1 D
- */( @5 k7 R% |% [' m
- 5 u+ ?& N: l2 g% a
- #include <linux/module.h>8 r1 \! l X3 _0 j! z
- #include <linux/init.h>* h1 e( {/ [7 i: L- m9 _- z
- #include <linux/errno.h>
5 e: h+ Z* a8 Z) a& F. @: F" P - #include <linux/types.h>- W0 _" X- t6 ?! h; U+ P
- #include <linux/interrupt.h>
% R) L9 }0 Z+ O$ U+ y8 ~0 l( b) D3 ` - #include <asm/io.h>0 s0 n. ^2 ?" B1 G
- #include <linux/moduleparam.h>2 k& v$ [& T- A. @2 q3 c
- #include <linux/sysctl.h>
; m. T$ j/ p. m& i1 i6 a+ ` - #include <linux/mm.h>% ]; o9 ~2 z9 t8 `; U7 t
- #include <linux/dma-mapping.h>
/ f, B, [- C, l4 }+ p+ F
: `: e3 d9 Z& H0 T- #include <mach/memory.h>
; u' n" x, e, k/ V+ C3 B - #include <mach/hardware.h>9 E# w+ k) z% z- X
- #include <mach/irqs.h>. [" z9 N, N9 A
- #include <asm/hardware/edma.h>
3 X) C6 t5 }( q - + }3 L0 Y# m- M$ U
- #undef EDMA3_DEBUG- d& B0 S7 p- I/ R& a9 X
- /*#define EDMA3_DEBUG*/
" E. Z: b& P% [6 Z! h% y, H
/ q- ]6 k$ ^, g% `3 q' h' X- #ifdef EDMA3_DEBUG
$ m) o" D8 ?% _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& H# O" K7 v( @4 b$ e: @- ^$ r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 ]$ M% c) Y) j9 X5 k* C" S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( z/ Z O: t0 s" h) |8 u C* m
- #else& B& C% F$ |! s, C
- #define DMA_PRINTK( x... ): x& F% Z2 ^8 ^: n, q$ Y
- #define DMA_FN_IN
. D: {7 y* _4 x! G4 D" f - #define DMA_FN_OUT( z" y4 U B c" K( z0 K. m& n: `
- #endif9 ~7 n" [$ F7 u% |% z
, }" A# n0 I, t2 P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; b. ^& Y6 r+ e- ?) P; X, P$ K - #define STATIC_SHIFT 3
t, T$ U( s3 y2 V4 }& B: E8 e- L* P - #define TCINTEN_SHIFT 20
9 Z+ g4 [; f4 K7 v - #define ITCINTEN_SHIFT 216 ^3 M* j' A3 j
- #define TCCHEN_SHIFT 22) T7 C" Z3 }3 l5 {5 h# W% K
- #define ITCCHEN_SHIFT 23
) T/ G- R- R8 g1 a5 c4 R - ! ^7 O/ I% p8 H
- static volatile int irqraised1 = 0;
0 z' K& n B$ _ n" |) H - static volatile int irqraised2 = 0; k! y) N; Q6 x& e8 o
3 f3 L4 _& v+ _# I+ n; j- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& o" @, p; E7 u+ V
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ a9 ?& }! @# D# ]1 Q9 e4 ?" M6 n - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! b) x% ]1 e) N
, B% |& h7 c- x; v- d' R2 f: v* w- dma_addr_t dmaphyssrc1 = 0;
* R, X- j1 l# j; t - dma_addr_t dmaphyssrc2 = 0;7 X' x+ ?2 I, S+ f
- dma_addr_t dmaphysdest1 = 0;- @% o/ @2 S- S; D* l
- dma_addr_t dmaphysdest2 = 0;; B. X8 I1 r6 i7 X. q
- * s- E' f0 J. }6 O+ y" H6 D+ J
- char *dmabufsrc1 = NULL;
: ]* Q+ g" ]! Y, X6 A - char *dmabufsrc2 = NULL;/ I) g7 m9 |- f M7 T/ E# B
- char *dmabufdest1 = NULL;' H7 v" F3 Y8 r. L2 h# _
- char *dmabufdest2 = NULL;
7 i3 }8 S2 J# o. X- z N/ S3 U
8 d) R |1 y1 ~+ E3 K- static int acnt = 512;
9 W5 c o; p- w O - static int bcnt = 8;
0 B* I6 h, a0 U) l6 q9 c ~% z7 s& ~# z - static int ccnt = 8;
. m4 J9 `, D$ x - ) Y4 T2 x' G4 p
- module_param(acnt, int, S_IRUGO);$ v- d+ c! x3 f/ g" x n ~( h
- module_param(bcnt, int, S_IRUGO);& f2 \! N6 Z3 B' W0 T) Z
- module_param(ccnt, int, S_IRUGO);
复制代码
' D; W( j. f4 I7 s& M/ }$ J" m1 z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 s2 C3 \, z* n: j) s$ `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) Q+ @7 x3 y5 c% j' w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: u9 Z V# R8 ?& ], g/ d
) z! X0 y9 g' R* O% M
* N4 z7 \' N+ `& u& L ]1 e: @ |
|