|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 " Z/ }5 T. Z: e2 |( z, \0 T
- [code]EDMA sample test application
8 n- T+ ^0 V0 t( k+ c1 ~0 z# p - /*
" C8 u9 e9 l) @) e - * edma_test.c
6 G# t% a! Z& p& B8 H+ c - *# @% h2 O9 o6 [/ P7 U
- * brief EDMA3 Test Application
, l2 S O+ c; o, q | `% {& V4 j - *
' u; a# _3 C; Z9 {6 R$ x$ s: J - * This file contains EDMA3 Test code./ Q$ \9 f; u$ p/ x
- *
0 b% m* i& A- h, {4 {* n+ [/ B3 _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
) ]% \2 k7 M1 L3 n0 M6 M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 f0 i7 o5 ]- ?& s; P - * TO CHANGE.
2 f4 w8 u. o+ Z- T) P - *
: @ X& Y8 Z O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/, u6 a4 `, Z# c; L4 J7 f' H
- *
9 S1 C0 C5 _$ J# @- J5 c - * This program is free software; you can redistribute it and/or3 D6 I$ A0 U$ m; I
- * modify it under the terms of the GNU General Public License as
' ~3 y) D4 z c7 m1 m j3 r% a0 g - * published by the Free Software Foundation version 2.( z1 D) S" o9 _7 ?
- *
9 b& E! c& z& `; h8 u. k/ |) U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any* q& E9 [7 e( _; l @
- * kind, whether express or implied; without even the implied warranty; M; X p& S8 N' D% N# ^0 B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 @# D; g4 x; K: d! h% w
- * GNU General Public License for more details.
, M# k$ Z8 ?3 }4 C0 x# X- q - */, ~4 y1 C _& w! \- h0 G* L9 _
$ d, _" v" |: `- Q1 v- #include <linux/module.h>
3 f$ K- r+ {3 \, P7 I- u - #include <linux/init.h>4 h, H0 }2 |7 d
- #include <linux/errno.h>: b g4 x( z# q/ r
- #include <linux/types.h>
* a0 o! e" X( o) I* C - #include <linux/interrupt.h>
* z+ x7 k& g( T0 p" u% [. S - #include <asm/io.h>
1 }, T9 t. l5 h5 s" z! { - #include <linux/moduleparam.h>, Q& q0 Q" d5 R& C2 v; | c3 c
- #include <linux/sysctl.h>) E5 t$ O* A, f: V, U" x0 E# h
- #include <linux/mm.h>
; Y: q% X4 _: o - #include <linux/dma-mapping.h>3 ~4 x& D4 o7 d9 [8 _9 V
- 7 Z# p- a1 q8 Z0 h# n
- #include <mach/memory.h>8 w% Q+ O! m1 @, q2 Y
- #include <mach/hardware.h> ~' [ U2 b: L" C5 M
- #include <mach/irqs.h># |( s: h+ R# K3 p8 b6 Y" y# s( M
- #include <asm/hardware/edma.h>; [" F$ L8 R) @# ]: [
2 ]( H- Q! p/ k5 t$ U" i3 C- d- #undef EDMA3_DEBUG' e2 n- j5 T1 k4 T/ N
- /*#define EDMA3_DEBUG*/
' N7 z$ |% a9 j% S4 M% l - ( Y6 k6 _) K! v2 o/ m" z5 i- Y
- #ifdef EDMA3_DEBUG/ v8 l4 }( Z7 S6 {' i2 W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ U: t9 Z2 a( Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), U3 C+ X; l$ r3 g* G4 x& E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 L! v8 S8 t/ G) ]1 I; C
- #else& X! H2 U9 \ @( X' D1 c
- #define DMA_PRINTK( x... )
8 P+ k3 _, M8 @' k0 T - #define DMA_FN_IN
( W5 W5 ]" d7 p( K; }1 |2 s- m - #define DMA_FN_OUT8 [! x# _. [3 v1 d1 D
- #endif$ T4 p9 g) j' \9 Y/ I
- 9 |2 K) } V! m$ W, ]7 E3 M
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 ^+ I1 a2 `; Q0 M" x - #define STATIC_SHIFT 3
( e) O F3 y- u# l5 \ - #define TCINTEN_SHIFT 20/ x1 V* U; o& `/ l# [0 O( E* u! `
- #define ITCINTEN_SHIFT 21
, I. a$ F2 I4 E+ y6 j, {$ |' U - #define TCCHEN_SHIFT 22/ G0 J4 ?7 U1 @& v4 E# x, J0 S
- #define ITCCHEN_SHIFT 23
! `. v. U( T. p/ K) N2 B
e+ p: \ Z0 f+ c2 k7 ?1 |- static volatile int irqraised1 = 0;
! `$ G1 _1 L7 ` - static volatile int irqraised2 = 0;5 N, c, q) I" V( a% H
- 1 L0 Z0 t3 W1 u, v: ~. a
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 E* e+ B9 W/ J' T( N: S% O) O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! O6 {9 }0 s% d# K* A2 c P8 P8 m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 x3 v& J+ f! H6 f w - 6 a! j" l6 K* C$ B1 @# j
- dma_addr_t dmaphyssrc1 = 0;4 G% d/ M9 m( u! f/ l
- dma_addr_t dmaphyssrc2 = 0;
6 q6 C. H. F6 G - dma_addr_t dmaphysdest1 = 0;* s a1 u6 {6 r# D# y
- dma_addr_t dmaphysdest2 = 0;: j5 q3 H" n9 \. s* H: D
t" P/ q% k4 Z g- char *dmabufsrc1 = NULL;
. t1 [: y) P1 x - char *dmabufsrc2 = NULL;4 v' a V/ U& H5 B
- char *dmabufdest1 = NULL;& i* n; g2 E% L& n5 [4 r
- char *dmabufdest2 = NULL;) X" {. W5 l# V3 Z% f
% E5 j, J i; ~5 A5 E8 x/ G- static int acnt = 512;9 X* z; }8 x, E* Y. m2 K
- static int bcnt = 8;
+ f4 G, I( v$ J9 O6 n+ w - static int ccnt = 8;
1 S4 a% l; r. U
1 q! ~6 |+ B2 a7 O3 N- module_param(acnt, int, S_IRUGO);
5 }' s/ |! x; E - module_param(bcnt, int, S_IRUGO);+ u. m3 [+ w+ d/ ^8 A
- module_param(ccnt, int, S_IRUGO);
复制代码
& |! I4 {, F% o2 v$ l4 n+ x! \* A% x* D- l0 L% t. I
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 d3 p( `0 D& }2 ]0 \; Narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ R) y/ X! _/ a 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 h* N0 y+ @8 T W5 E: N
6 F0 v1 P& Z( @, _
& P$ O# G; N: K f, ?9 F |
|