|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ Y) D; i) h4 [$ K. ~# J- [code]EDMA sample test application
# t2 d8 w) c3 }2 X- J0 ^" e2 X0 Y - /*
5 U! `) o2 G! T2 { - * edma_test.c E: \% ?+ m4 G3 C
- *3 O" h8 t, @% D; M. A
- * brief EDMA3 Test Application
1 j! t0 [& V2 |& A$ P8 h - *( n2 ?' q3 s: q( p ~+ u' C' d5 _
- * This file contains EDMA3 Test code.
! ]; G, K$ M- p- w( _6 ?( v - *
3 \1 v0 W7 g4 L: o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# ?6 F% d+ c* z+ h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& A2 M( h" W& T& n - * TO CHANGE.
. c. {) ]9 o/ s/ c - *6 _+ S) {, [7 T) T
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ F9 v( E! R0 ?& x# Q6 f M0 E) @ - *1 w9 [9 `$ l! [5 b2 G
- * This program is free software; you can redistribute it and/or
2 K5 r6 ?. A4 W+ G1 |6 e: a3 W - * modify it under the terms of the GNU General Public License as& }1 \) U9 N( |7 ]% z' U) y
- * published by the Free Software Foundation version 2.
% [% g) {+ U- J8 c# \ - *! @5 n% r: g& H5 ^9 Y+ v
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any, i# b e D5 r! z( r
- * kind, whether express or implied; without even the implied warranty4 G8 ?# y* O$ z. W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, B: w2 f8 s8 T: v
- * GNU General Public License for more details./ B6 P7 H! ~ w9 m& g/ h
- */8 ^- P; r2 @8 H/ h" P& N: O
3 }# W: k9 e7 G6 M7 z9 @' n, J3 `- #include <linux/module.h>
* x- p/ U( I4 L! x0 L - #include <linux/init.h> p* g# J! i* i% F
- #include <linux/errno.h>7 F6 B# i8 f" Q6 u
- #include <linux/types.h>9 E) q% g) I2 |
- #include <linux/interrupt.h>
: M! z% J* J0 K0 k( g9 c/ _ - #include <asm/io.h>
6 C: C7 q, \$ C8 `' |% `; J8 | - #include <linux/moduleparam.h>
! m7 Q+ D" g$ g9 m6 H2 d - #include <linux/sysctl.h> ]5 Y8 W4 F- ]' ~1 h9 Z" h% Y
- #include <linux/mm.h>; e0 ~; `9 x, w5 k
- #include <linux/dma-mapping.h>* n4 o' ]' { D& H" W* J) d) t
- * i2 x4 O, l: d$ S' O: ~! ]" ?
- #include <mach/memory.h>
# B! U0 t* q9 H7 r7 G8 u2 `9 p5 Y$ | - #include <mach/hardware.h>
4 J& ^% ?0 }, Z3 F0 q! z - #include <mach/irqs.h>9 j* J L- C5 @6 q! Q x! S3 e
- #include <asm/hardware/edma.h>
( k g2 g8 m* [/ @5 ` j5 } - + e# A8 C1 w8 S9 S2 i7 \ c
- #undef EDMA3_DEBUG
( b @% |. w5 g+ l - /*#define EDMA3_DEBUG*/
: Q1 f# j* L1 G- ^
( | m5 g; x* Y! D+ n2 \0 G- #ifdef EDMA3_DEBUG
0 B! ?# \. E5 s" s; y& c* M( V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
f1 K8 _- Q. Q7 G" R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ K: h+ q, |! w2 M
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' y0 F6 _, |4 |3 ^- ` - #else# e) }3 H9 A. A* H S: U
- #define DMA_PRINTK( x... ). n% o6 }* n! f6 Y ]! M7 y
- #define DMA_FN_IN
8 Y1 a s9 w( B( Y& h# d3 \7 T - #define DMA_FN_OUT
2 E$ p! p: Z7 U$ q - #endif3 l0 E! `7 T* Z9 Q2 L& d
/ }9 V" V& e" j, F+ E6 s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 z; L. T9 m5 N
- #define STATIC_SHIFT 3! B& ]; i) I u0 l
- #define TCINTEN_SHIFT 20
( ]. ^ Y$ ~" }9 ?. S' u/ h9 { G - #define ITCINTEN_SHIFT 21
( |% H9 g$ q) N. y: y - #define TCCHEN_SHIFT 22; K+ D0 ?8 r6 D. {
- #define ITCCHEN_SHIFT 23' y3 q/ Z9 A. R0 Y7 h4 A$ e
2 v3 H2 ]5 T$ I8 {- static volatile int irqraised1 = 0;# L3 R; e- T \7 w
- static volatile int irqraised2 = 0;
6 `, f- ? Z; K S+ N - ) z6 W% I% x* h7 U
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& |% V. c& h5 }/ t' k! G* v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
Z* h6 K+ E4 w3 Z' M M4 ]2 D+ m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 z! y/ r$ q6 b9 q5 D - . o$ @4 o: E b
- dma_addr_t dmaphyssrc1 = 0;7 U- c) z: m1 w3 T4 L+ t( n
- dma_addr_t dmaphyssrc2 = 0;& S1 _" h. a& o" N* |
- dma_addr_t dmaphysdest1 = 0;
1 K/ M! \ ?% d3 K% K - dma_addr_t dmaphysdest2 = 0;
2 G- e5 d o0 x2 Q% D# [ - * a( U: o( `. D O
- char *dmabufsrc1 = NULL;5 t/ V9 Q# o+ |) `6 ^) K
- char *dmabufsrc2 = NULL;& _+ l3 e3 R; C8 D, ~; g7 l
- char *dmabufdest1 = NULL;
1 l; E6 O& P, j% U N5 { - char *dmabufdest2 = NULL;
3 N% ^, M. y, {( Y! H
* @9 L+ z3 _4 x- static int acnt = 512;
& q: L) v1 R. M - static int bcnt = 8;
0 G. P& g& [2 ?8 {3 _8 X - static int ccnt = 8;6 n( P7 o( S4 @5 c7 h
- 3 ?7 o; W# C: ?% X
- module_param(acnt, int, S_IRUGO); I! |! i- a$ g% Y
- module_param(bcnt, int, S_IRUGO);' R/ E% {" Z/ @) A4 w
- module_param(ccnt, int, S_IRUGO);
复制代码
4 N8 L4 p7 \$ L) g
3 @4 i( c, Y( Y# Y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ D4 K$ O& E9 A( c- V; P. Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 {& d* n- @+ t' H8 {/ b" K/ Z# x3 g; Z" Z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# o( G0 G; U. K0 C& e* i; ~' A/ l* L) _) X
x, F/ U& P% t5 M- F |
|