|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 $ ~& a) f, V( _/ N: M6 d% o1 A) H+ a
- [code]EDMA sample test application
# F/ {; f% L+ \# `% b9 Z - /*
$ f& y8 |" P) u. t- _0 o' | - * edma_test.c
7 A, ~" R5 i* w, N D2 r - *
6 o9 l( C/ w! X M G - * brief EDMA3 Test Application
* H& i8 `* p( \* Q; N - *
1 f" l: j6 M n% {2 C$ g2 L* ~ - * This file contains EDMA3 Test code.; U, ?. ?% e5 r3 z* c r& Y
- *5 T9 Z8 g- y/ n2 V
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" k6 X$ K& a. R5 A/ z+ c - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 U' h8 z7 q: i2 E1 D, X+ l+ i1 c4 d
- * TO CHANGE.
( `5 u$ e# c% a# S( F - *' Y5 O/ R+ L$ s- i$ M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 i. K; G& C, }0 c% D - *5 |. v, _# c3 E& H: `. X. A
- * This program is free software; you can redistribute it and/or
" ]" [9 W0 Z" b6 Q - * modify it under the terms of the GNU General Public License as
- Q. A$ e$ Z, T* B& e) o, j - * published by the Free Software Foundation version 2.. z' `% J/ L- w: o0 d9 v4 B
- *
+ |0 R( P+ m/ D* g: K+ i8 e# W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 K8 w; e' z: V. p% K" t - * kind, whether express or implied; without even the implied warranty
3 `8 S0 @+ i+ r5 N4 [% s" ^ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( _! i4 X. j' L: l5 ^2 O
- * GNU General Public License for more details.
( W4 d- h3 u3 p$ E. X# M' j - */" W3 Q3 W5 |6 C9 y/ r r) _, x
$ L* ^+ S- O/ y' i. ~: B& A- #include <linux/module.h>; J# \+ l; F/ ]& ]
- #include <linux/init.h>
) I5 R; Y' J, }" r" w - #include <linux/errno.h>
7 N3 P, U, \: c7 P/ ?: v( O - #include <linux/types.h>
. B+ k3 C2 \8 S+ R) ` - #include <linux/interrupt.h>
+ h* e+ V4 S& U' B" ] - #include <asm/io.h>' j6 e2 L- f: M% `/ ?% J" y
- #include <linux/moduleparam.h>6 ^# m% J, U# ~ s2 m
- #include <linux/sysctl.h>2 a) b `3 O* n7 b( w& }) J% x
- #include <linux/mm.h>
* \& B( ~ l) e* B - #include <linux/dma-mapping.h>& ~/ Q6 H7 Z* Y% }' |
( I9 F; O& Z( |6 _* n- #include <mach/memory.h>
$ T2 Y/ g8 C/ K D5 v - #include <mach/hardware.h>
! [% Z' `2 U" G1 Y! \8 x - #include <mach/irqs.h>
$ K- F6 q; G6 a8 a, a" Y - #include <asm/hardware/edma.h>7 F1 V' D- Q6 G- ]) M. o6 s
# P W8 l7 G3 ?- #undef EDMA3_DEBUG: s/ X& E& Y$ z9 a1 w
- /*#define EDMA3_DEBUG*/
" g1 o( i" I; u4 O
2 t" o: t# v2 Y% Z- z* y2 i9 h) Z5 v- #ifdef EDMA3_DEBUG6 p, \. }! ~+ M" C5 v5 K
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" {" S7 P5 [+ Z h* d
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ ]: @, u% B8 g$ Q7 M- u
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 S+ K0 p1 o" K2 } {
- #else
/ l* E" ^/ e: I - #define DMA_PRINTK( x... ): `8 W7 |3 a2 j6 J" p; ]
- #define DMA_FN_IN' t* k5 V3 i% A. o& Z, y, L. ]! q
- #define DMA_FN_OUT. e6 l! O4 }; r& J# A7 {7 n
- #endif
0 o( q# E; u2 C _. t5 J* r5 q
1 a( h& n. A. s- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ x2 M' U' k6 t5 |; J - #define STATIC_SHIFT 3& S) m, l: d. r1 D# m1 T: O; X3 ^9 d& a
- #define TCINTEN_SHIFT 20; C7 E- n$ C! n6 ^% Z
- #define ITCINTEN_SHIFT 210 c: }. Q# \5 W0 `, j6 K
- #define TCCHEN_SHIFT 22
% W# }* u% g4 |) k$ G4 h; i - #define ITCCHEN_SHIFT 232 a( v$ [, q2 B7 k- t- T
- % J6 m% v7 K D) v7 M [% S
- static volatile int irqraised1 = 0;
1 C4 k* `! Z! r2 U - static volatile int irqraised2 = 0;$ ]0 d3 q; z) Q3 M( ?
1 u! I* R: x4 g( k0 \- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( l2 b ` X+ R8 d/ g8 W8 r7 s# N - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ ?* \8 d5 k4 p" J5 L' T - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; N/ [1 k# e7 w! F+ _
8 L2 D% D/ a. M$ f& q- dma_addr_t dmaphyssrc1 = 0;
1 m) h5 x/ {' q- U - dma_addr_t dmaphyssrc2 = 0;
0 C. ^+ r& X) Y- s - dma_addr_t dmaphysdest1 = 0;* u6 Y0 |& D9 v
- dma_addr_t dmaphysdest2 = 0;) Y7 q5 q& S7 r/ q) U7 N
4 ?( r/ F; l4 C! m! h3 f% i- char *dmabufsrc1 = NULL;8 D4 q7 \0 U; E
- char *dmabufsrc2 = NULL;9 U' X6 k( s; K6 N
- char *dmabufdest1 = NULL;/ a D; l, e' N1 }2 [; c4 u. r
- char *dmabufdest2 = NULL;
- F( ^ {* T0 t" z# ]& Z
4 E4 H' H+ n4 m* H- ^3 T- A! a! @- static int acnt = 512;
% F- v- V7 o1 `) f6 X- r0 o6 }7 f - static int bcnt = 8;0 t4 R: i( ~* D: c* q5 U0 Y+ j+ D
- static int ccnt = 8;5 O8 X% \9 Y7 }9 P3 I! V+ Y" Y
- ) f& f' C2 t; P
- module_param(acnt, int, S_IRUGO);
2 Z! S* W9 h! F$ E1 S8 G - module_param(bcnt, int, S_IRUGO);
6 M3 D- e" ^- V7 o& N - module_param(ccnt, int, S_IRUGO);
复制代码 0 Z. @7 @: S' F
5 L" `' g; B8 J7 q1 M 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ ]7 X& W" ~& |" Sarm-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+ R3 x: O8 ~# B; |* J2 n; ?+ m0 ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。# P" O5 I- F# o5 c
8 i: N" _% I8 D O4 j' w
: p: |" t! D4 U |
|