|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 P) W1 e9 @6 `" p: e7 v- [code]EDMA sample test application
$ u: u' W2 p* G4 w) I" E9 a - /*7 G' G9 W$ _( v- m# J0 Z
- * edma_test.c
" B5 ~) Q# p, C; @ - *
6 x5 e4 p" {: o0 [! K4 ~ { - * brief EDMA3 Test Application. n' r' m% Q9 K' y" o
- *
7 [1 e# r$ L& Y5 @ - * This file contains EDMA3 Test code./ Z0 B% k6 n1 J' q! ]7 Z" T$ b
- *
! b3 d( n/ X- n# s3 Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE- v( |/ w) N4 v4 e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# r& l, ?" y$ B9 g% M& D" k - * TO CHANGE.' }$ U$ _: I$ z% ^, Z0 M
- *
6 f- `2 H8 `& j9 F! T% x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) [- i3 i ]% o9 ~
- *3 ]# z2 T+ i3 S
- * This program is free software; you can redistribute it and/or& X9 f( C# _" z" r4 m
- * modify it under the terms of the GNU General Public License as
4 l" i3 X& a4 \2 P8 A1 C& ] - * published by the Free Software Foundation version 2.
- l) Y, C9 m/ _) v5 E - *' {. p- \5 J- S0 l$ s; n) A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- d* S& Z3 x! c4 e; x - * kind, whether express or implied; without even the implied warranty: S- f M+ R3 e% Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' |7 k8 R& w. W - * GNU General Public License for more details.
# r/ ^8 A! F# } Y - */
9 Z+ m$ W1 I0 f! e+ o
1 j2 ^* q3 N% I' @- #include <linux/module.h>
' M! I, g$ T! Y - #include <linux/init.h>. a6 X6 c* }7 I- n& R
- #include <linux/errno.h>
! `2 e8 G5 j$ N# X - #include <linux/types.h>2 k' u6 Q q6 U/ U. }( [: c
- #include <linux/interrupt.h>& G# F2 S6 ^) D+ S) L$ [
- #include <asm/io.h>& y5 Q% A4 d [. n
- #include <linux/moduleparam.h>
- Z4 ~0 f: E* X7 F/ n6 ^ - #include <linux/sysctl.h>9 Y' E) t2 y+ K( X' D2 H& l
- #include <linux/mm.h>
7 Z3 P% ~1 W' }4 ? - #include <linux/dma-mapping.h>
0 p9 V8 G8 S, P5 v O
3 Q- Q0 ^9 ~4 R3 K$ e- #include <mach/memory.h>
3 ]9 m7 q- f% a5 F - #include <mach/hardware.h>; z8 X! s/ B. |/ }( g6 H% H, i
- #include <mach/irqs.h>
" x" l4 g8 i9 `5 [9 t8 O6 P - #include <asm/hardware/edma.h>, s+ W( m9 V0 b, |* s* i9 ?
- - _8 Z- X1 z5 ~
- #undef EDMA3_DEBUG
4 S! S' H! V, [/ j - /*#define EDMA3_DEBUG*/
}% R* s: D @' V$ m( ~ - % q# f* c9 w o: n. c
- #ifdef EDMA3_DEBUG
% t3 _% Z/ `$ G1 d - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' Z" E3 m5 ^# x, O0 Y9 ]' h$ z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; b, O4 [& p0 E9 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 C; U0 K, u5 S Q, ~$ s
- #else n$ ~1 R6 x5 S- h4 N$ G9 h+ t
- #define DMA_PRINTK( x... )
+ G5 h; a# Q0 u9 y# s1 C - #define DMA_FN_IN
* n: L9 I/ a" l4 J5 [ }. S - #define DMA_FN_OUT$ }6 e7 O% W+ b I) v
- #endif
+ Q6 N! T6 g9 c! s7 C - 0 P4 X7 z9 D2 N! C" A
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
/ @3 o8 e# m9 M; c* w2 J - #define STATIC_SHIFT 33 ~, C3 t& f- q" q
- #define TCINTEN_SHIFT 20" ^* v" N. b6 v! M/ \! G! d
- #define ITCINTEN_SHIFT 21
. X% A, {! p/ ?! S, `8 b - #define TCCHEN_SHIFT 22! p$ l" `* T! D* j; G
- #define ITCCHEN_SHIFT 23
: x# F/ E% U! c/ j5 U; B - / M% T* t" k$ G; h/ p3 l c
- static volatile int irqraised1 = 0;
6 R( b6 A4 m7 u% A; C - static volatile int irqraised2 = 0;
4 n, A8 n5 j8 o% Y
& X7 m: C: I$ ?- k0 ~7 L- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ J" H% m, V, C' h - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 A J9 K& L/ K' G( f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; p$ u& ^- ?" p8 L& l4 |
. U3 [' m: P7 t* E/ d- dma_addr_t dmaphyssrc1 = 0;5 t8 c+ e5 R, {# ?
- dma_addr_t dmaphyssrc2 = 0;' H/ j1 L( T5 Q! _, R& w* B& G
- dma_addr_t dmaphysdest1 = 0;
0 G5 r6 v& y% m" `" |1 }) k - dma_addr_t dmaphysdest2 = 0;
8 U( x$ [5 y/ P7 Y' w - & d( P" K* B: L2 T. n; c
- char *dmabufsrc1 = NULL;
Y' V" F- a( c# l* A, A6 W4 G - char *dmabufsrc2 = NULL;
; L/ g+ C6 R- x - char *dmabufdest1 = NULL;0 X. R$ y1 g X
- char *dmabufdest2 = NULL;9 @) Q6 |7 q& j- [! i; d. O1 c
3 I* m& a5 @0 V6 D% m' y- static int acnt = 512;
7 `; @: J0 R9 p# e/ y/ ^ - static int bcnt = 8;$ o1 H$ z! l$ T* ^+ w: H9 k) ^
- static int ccnt = 8;" X& `1 W. a# l0 q: W
- : b9 |3 l9 B& a9 N% R% s
- module_param(acnt, int, S_IRUGO);# j5 ~& J6 t& k8 I9 f+ {- l* p$ |. t
- module_param(bcnt, int, S_IRUGO);
8 |& m7 k; W& L - module_param(ccnt, int, S_IRUGO);
复制代码
8 q) ? c: G+ ?+ v4 F# @' y# x- D1 o1 m) ~1 h1 H
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 [! ?6 A2 l% A( n8 ~3 M8 rarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 u# N) Q; u1 g' Y$ I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ {' X( j# c& [, |" O1 k! b5 y1 n$ t7 {) C
4 I. ^" c5 ~/ q" O6 u7 f$ r" c- d
|
|