|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 G0 U. O; }4 e- [code]EDMA sample test application
e; W a* E7 F1 o - /*6 q' I/ J& u5 X- p {
- * edma_test.c; `8 I$ `( |; z! i
- *
9 a: f; O, Q+ K# B- c - * brief EDMA3 Test Application
/ f5 K& R, `9 W* Y - ** ~# `2 S' x2 r$ j8 E
- * This file contains EDMA3 Test code.% Y6 q. \7 `6 ^8 F3 ?
- *
, r( g7 C; S* v2 S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 ?# _3 N, |! o$ `; H - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
/ e" z- [ ]6 W3 Q - * TO CHANGE.% s! c5 \" B3 ?: G
- *2 a2 G, N2 d$ ]4 V3 T% I3 h
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 j# @) @4 \. o: P8 A* p
- *
$ q( I# E$ [; M) `/ w ~* @2 E- I( [ - * This program is free software; you can redistribute it and/or! k0 l% i# F w* j; [, x
- * modify it under the terms of the GNU General Public License as. u/ d7 `% F4 D) A
- * published by the Free Software Foundation version 2.+ Z+ K; ?1 i$ P4 Z% n \& b
- *
2 p4 V* G+ {' I4 | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any* B# S E9 v5 Y* g* {
- * kind, whether express or implied; without even the implied warranty
8 B7 _9 F: H, R0 W4 Z3 T9 V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ i; I j" `9 r5 g/ I
- * GNU General Public License for more details.
8 L: v6 N( `" u" V - */
0 e' b6 C q# ? - 8 w+ `0 Q3 z7 J, t' B, S
- #include <linux/module.h>- e$ o2 |; }2 a5 a% V% q; l) i
- #include <linux/init.h>! B2 u X2 b4 W& r
- #include <linux/errno.h>3 p( f9 d+ R9 e# G
- #include <linux/types.h> v4 I' q/ o+ b) n4 y6 A
- #include <linux/interrupt.h>8 ?& k6 D% e3 t7 i- n6 @, u
- #include <asm/io.h>
$ ]! d9 ~# S- }8 N) Y7 } - #include <linux/moduleparam.h>$ e; |$ Y( ]4 }8 j" ?" E4 ]' F4 I
- #include <linux/sysctl.h>
4 |6 k/ c& P. } - #include <linux/mm.h>3 E9 V* Q" L- T) Z) m4 x5 Z! _" F
- #include <linux/dma-mapping.h>
, D* e$ ^ Y6 L, ?% f$ T - % ?6 Y' u7 b$ B6 Q9 H! r' a$ }. r2 J
- #include <mach/memory.h>- v9 Z; W1 q3 k- L- q2 r
- #include <mach/hardware.h>0 @" S8 [6 [4 C
- #include <mach/irqs.h>
0 b% I" _) M7 }5 O: G - #include <asm/hardware/edma.h>
0 u. d& ?4 a. h( L3 o - 1 s* P6 `4 |% [2 F% i
- #undef EDMA3_DEBUG
" C" p6 S) z# @# Y6 k - /*#define EDMA3_DEBUG*/
9 m" V. i! N+ D+ m4 a. O- E - / u1 {% T% B% |
- #ifdef EDMA3_DEBUG
& `2 }- R3 T6 h& R0 k& e - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
+ P: w, ?! b9 H, \2 z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 t9 V, U+ m8 V" G0 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 a& T5 w1 [, X- K: R; Z2 j - #else3 C; n) w. C4 ^, i3 Z9 [# m4 F/ Z
- #define DMA_PRINTK( x... )# z: _2 U, Y4 Y/ J/ L5 G# z: ~
- #define DMA_FN_IN6 Z6 H" y2 q& t1 n' S; z5 ?! \
- #define DMA_FN_OUT- J( H$ l1 D1 X4 j1 X
- #endif3 ?* _$ v6 Q/ b% d2 @
- 3 @* D& W. Z* L( S" L
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. ^% u& Y5 V0 R7 |5 f: { - #define STATIC_SHIFT 3, C7 S( _1 B8 `3 L# T
- #define TCINTEN_SHIFT 20+ u/ T! V. S1 }$ y* u1 Q
- #define ITCINTEN_SHIFT 21
. Z% b, Z8 j) C" c - #define TCCHEN_SHIFT 22, O& _2 J7 E- `. s
- #define ITCCHEN_SHIFT 23
6 G. ?! [+ W+ _) L9 y8 K
) K3 {3 r' k' J7 h% r- static volatile int irqraised1 = 0;% J b0 c; v6 K( A: D" k9 t
- static volatile int irqraised2 = 0;! | Q6 J4 l6 i3 n( A0 }
5 A- h) P. Q4 @. H8 F% M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 Q- q6 N2 ~# {# O8 L8 t - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 O/ ^2 t& p/ L/ Y( i
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 E. \7 U) _1 _! e) U2 @
+ h3 \" ]- _ Y8 d. N- dma_addr_t dmaphyssrc1 = 0;( p7 I( T7 p3 D0 Q9 J
- dma_addr_t dmaphyssrc2 = 0;
8 _7 R5 `; F, [& q% A# X5 @ - dma_addr_t dmaphysdest1 = 0;
9 X# E- z7 E9 ~# M/ E - dma_addr_t dmaphysdest2 = 0;8 k+ H6 T, o! e5 y
: V, ?$ S. N. `( U4 t1 k6 `- c1 b- char *dmabufsrc1 = NULL;8 B, \: l% t' o; K8 x# K
- char *dmabufsrc2 = NULL;8 U% p; L& ?" h, ]) P
- char *dmabufdest1 = NULL;
* R' V, X1 i% U- R: P% W - char *dmabufdest2 = NULL;5 K+ m1 B- _6 D# I8 s
- 1 x' j0 f: O! S% \" v+ y- y1 f
- static int acnt = 512;
- w6 m: [* u. H - static int bcnt = 8;1 [' a3 \ [. Y
- static int ccnt = 8;2 }% z6 s/ Q* R0 v6 _) Q
( L$ g6 h- O n! O0 P* ^- module_param(acnt, int, S_IRUGO);
) g, O' G: s* V5 g - module_param(bcnt, int, S_IRUGO);
7 }/ b) [2 D% v2 O8 Q# C6 ~! _ - module_param(ccnt, int, S_IRUGO);
复制代码
) k6 |' \- J9 T- A2 E0 S6 u7 W, W- H- k; m* A
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ T& m, @% N+ Z! [. Z' farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 v2 ?0 I/ k$ l& }7 Z& u, y) y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 E. d) l% k7 g4 G) ^- o7 `
! t' M6 \* U! T
2 M& a! x" k; e/ O& U" S" Y0 ^ |
|