|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 ?7 O" w7 k% w- i- k! B- [code]EDMA sample test application/ n; v/ x C% [
- /*
6 S; W5 }' a- t5 h - * edma_test.c
+ T0 j( t% y4 @# B - * t& M! @% q5 ?0 B* S* Q
- * brief EDMA3 Test Application
3 M/ f. d& }1 v l$ [& Q2 q - *
) q& x4 K; C$ i - * This file contains EDMA3 Test code.2 f8 z/ d! d7 f0 g) a. R- t" v
- *
# n p4 q- G @( M: [ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% ^% ^& {* }8 c- Z0 E/ x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 i% x/ ]+ L; m/ W! Z( [
- * TO CHANGE.3 J* S% h7 {( \; _, u
- *
/ T5 S8 W/ x- U/ T - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* D/ ]+ E/ Y/ I+ g g' {) G2 V$ O
- *
0 w' r: E2 y7 n. ~# Q - * This program is free software; you can redistribute it and/or1 ~. k. o, B* R- X) w
- * modify it under the terms of the GNU General Public License as
) t4 O, t" S3 s& i4 \ - * published by the Free Software Foundation version 2.! E, I! |! ?0 G D
- *: o, q. K% Z. `! |, V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 L V" P7 ^- F6 F3 p
- * kind, whether express or implied; without even the implied warranty, r- o4 K0 x2 E0 \! o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 I1 x6 b& ]4 h1 }2 z7 w+ y+ S - * GNU General Public License for more details.. C2 X! Y7 I, n& M: B
- */
$ m2 Z# M: h) G K5 ~, V - ; g- z* T* O2 ?+ _4 W
- #include <linux/module.h>
' h+ S- Q" q) z$ z g" r' e - #include <linux/init.h>' ?# E- `( U4 |* T ]8 {
- #include <linux/errno.h>
$ ?. F, n& ?9 m3 M3 S - #include <linux/types.h>5 ]: f7 @& L+ O K7 a. ~+ z
- #include <linux/interrupt.h>1 U1 K6 ]& X( @5 x& {& M5 p0 [
- #include <asm/io.h>
! x! ^9 U' {, P6 u - #include <linux/moduleparam.h>. G" \2 I, H" |. Q
- #include <linux/sysctl.h>: O8 b4 M& K- U; a
- #include <linux/mm.h>
" m9 K- _0 B) ?% f. C1 p - #include <linux/dma-mapping.h>0 W5 ^! f3 e0 O: s" ] i% b
- " G, q- Q5 B" u2 _$ a; ?
- #include <mach/memory.h> {: ]6 b' z1 W7 {! I7 a# y1 [# @
- #include <mach/hardware.h>; D. Z" P) _) _ W
- #include <mach/irqs.h>
& S3 Y. D/ P1 f/ J' F" i) v6 V - #include <asm/hardware/edma.h>1 m+ H: L& N4 `+ j8 T
; N7 [1 s3 X5 W! k( f& d0 o- #undef EDMA3_DEBUG1 H& L% V, G! C8 C( c3 q
- /*#define EDMA3_DEBUG*/5 [# g( w2 V$ g" b8 z3 l
- 6 e0 O/ U( C( Y% d. B1 m
- #ifdef EDMA3_DEBUG" q" U" t5 q8 p$ }4 z! L6 S) Y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
4 ~6 M$ c6 q: { W9 ?9 h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" y$ ~6 x- t: Z6 i- F
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 D9 n0 Y" ]* }& G+ z2 w. o& ~ - #else
! Y- c. r! _) l1 ^/ \ - #define DMA_PRINTK( x... )
# x* ?! e# r4 W" H3 o _+ v9 a! \ - #define DMA_FN_IN
$ ~) o% t4 x7 [; \8 y& X - #define DMA_FN_OUT. _7 I/ D2 W9 {2 r: E
- #endif
$ Y9 ]- E1 Z7 d/ Y& f8 T5 Z; K - 2 l+ @3 K# k. T4 E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" z& X; \% t. q+ f% s8 T
- #define STATIC_SHIFT 3
3 }1 ? j* Y& X6 V1 U2 E; ?% E- w$ J - #define TCINTEN_SHIFT 20& {; B# p1 z3 S" Y& P
- #define ITCINTEN_SHIFT 21
1 {' ]9 Q4 i" J" P* V; { - #define TCCHEN_SHIFT 228 b# c n. z3 V( V7 r
- #define ITCCHEN_SHIFT 23
2 U$ t& Q# T y1 X$ H
' R$ _+ g8 L3 J) A3 o. L( G- static volatile int irqraised1 = 0;+ n" G/ h0 J) T4 w& h! f
- static volatile int irqraised2 = 0;
7 |& K& D5 N2 R' s4 U! e6 [ m
- U( w' M# O. N, u- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% @; }) N" y, P5 K) t+ _ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& ], F$ H; x: c0 j, z' G2 Q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 U) Y" J' l5 p7 I2 i9 K% T
- 3 q' k9 \# X1 `& l5 M2 E
- dma_addr_t dmaphyssrc1 = 0;
5 m- H. d% f' V- P - dma_addr_t dmaphyssrc2 = 0;
* f. u/ K Z! f1 Q }/ B: F - dma_addr_t dmaphysdest1 = 0;# W; Q+ c* K9 N& L- I# c$ x. k
- dma_addr_t dmaphysdest2 = 0;
1 o) x: A" n' n4 R0 \' n: ?" w
* B6 U' s/ V& i& ~* i+ X- char *dmabufsrc1 = NULL;2 q4 _; G7 z, ~! K5 a; u0 ]
- char *dmabufsrc2 = NULL;' O: M u. }+ X
- char *dmabufdest1 = NULL;
/ ~5 ^5 Z# {. K g; ~ - char *dmabufdest2 = NULL;
" v( f( [( v, l W - / B, Q' ?" L M2 D
- static int acnt = 512;) y/ c( p0 T% E9 c2 q# {: i
- static int bcnt = 8;
& z c3 O; A( N0 b - static int ccnt = 8; x+ M' ^) l( N# p- E1 |
- / ?5 o$ d. d B: t3 J" E! h
- module_param(acnt, int, S_IRUGO);7 H' h# k7 S( B$ Q4 p( n! V4 M+ R
- module_param(bcnt, int, S_IRUGO);5 I3 K+ ?. V( @+ s+ k8 b! e
- module_param(ccnt, int, S_IRUGO);
复制代码 . D3 I) k5 V6 K2 ], K* B- A
1 T0 s. B U+ s; n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 C4 V/ p2 n2 @arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: t4 d# Y1 M$ o
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% _; a. Q3 T" N& v$ e- E3 y0 g0 `9 T; o5 Q
( \, Z6 R. k2 U: Y+ J& k7 s
|
|