|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 f+ @7 V. |' M* L- [code]EDMA sample test application* u5 a8 F9 H3 }4 u- l
- /*
% ~: v/ y$ z6 H' G; | - * edma_test.c8 j" d4 n; K/ O9 I+ l
- *$ J- a4 ?* ?7 s8 V, I6 a
- * brief EDMA3 Test Application( c) g. f4 L$ p8 s/ O3 F
- *) |5 R4 `1 @# A2 s
- * This file contains EDMA3 Test code.
3 @ X ?) o. q - *
! q- u) Q' q) X( `8 B& T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: Q5 |* r9 l% L0 Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% [* O" h6 c. ~9 j4 d
- * TO CHANGE.
# H! i' N8 A) z0 [3 m$ N) X - *
* N' E9 }5 r1 U6 B - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, A. v3 m* e8 o( {4 y/ z - *. M* R! E0 s- B. S
- * This program is free software; you can redistribute it and/or4 a, w5 A$ `3 J1 Z
- * modify it under the terms of the GNU General Public License as
# w( m4 }9 `( X9 l4 K - * published by the Free Software Foundation version 2.4 G9 Q# v: o* j. S6 O( Z
- *, X$ b# K; l V# n6 p$ u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ V& X+ o$ G* N. J/ Q: e. D0 n+ K, u8 z
- * kind, whether express or implied; without even the implied warranty
% g! l2 W$ S* s/ s D - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ p6 J" L; N9 j1 a; Z2 z( x - * GNU General Public License for more details.+ H( w* f) |2 n! t7 N- V
- */; ~9 \0 w9 a+ _- h
- ' e4 M- K$ Z e% p! ]. b
- #include <linux/module.h>( n' z6 v m& K2 `) A Q
- #include <linux/init.h>; M* ^0 E/ c/ Q# H
- #include <linux/errno.h>( h [7 E$ f; ~; B7 @% ]) T
- #include <linux/types.h>
# E& }9 D5 p$ a0 w( Q9 z: } - #include <linux/interrupt.h>, A+ s( z, F8 E- U
- #include <asm/io.h>
4 R7 `( R l; n4 T6 N' k" b7 r - #include <linux/moduleparam.h>
1 L* q i$ c1 a - #include <linux/sysctl.h>( ]+ l! k I! i1 k& L: R8 M2 T
- #include <linux/mm.h>
% J+ y' Z7 A* B8 m - #include <linux/dma-mapping.h>$ K' b g/ V9 F! g3 K& r$ [7 e
6 x9 Y+ s; t) l' _( `4 V- #include <mach/memory.h>
& T% A5 }& J) J# X P - #include <mach/hardware.h>+ W/ A/ f" q6 f( E
- #include <mach/irqs.h>7 G4 |) }' x. {$ b+ z4 ~2 v
- #include <asm/hardware/edma.h>
g" @8 d* @+ ~
5 D( ?$ A, a/ g& N- #undef EDMA3_DEBUG# F; |! t2 Q& G0 i {
- /*#define EDMA3_DEBUG*/4 O& |4 D& [5 t
- 0 v& J0 u; Q" s4 s# T% M7 ], u
- #ifdef EDMA3_DEBUG) g5 U2 E8 q4 V$ B$ w, j2 S1 _
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& J0 x6 T# a9 n; S/ d
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ A. ~' G% g+ z6 X) g! n- p
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
4 U# z) x% ]1 `' s9 F# h- f& z A - #else" y3 C$ R& o8 V' Q1 t+ P
- #define DMA_PRINTK( x... )0 m; I. i. [( F4 [$ S
- #define DMA_FN_IN
$ H& D1 E* _1 _* Q+ I+ c- M0 Y - #define DMA_FN_OUT
! T z8 S1 e2 _8 O) o0 V3 f/ \ - #endif6 d5 t2 w4 j+ q3 x
- % F2 t7 R- v/ C9 _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 ?- {" t# g6 z, J& }0 G C4 T! Z - #define STATIC_SHIFT 3! u% U z# m& P _
- #define TCINTEN_SHIFT 20! O4 F* o( y' B9 J% }9 U$ L/ U8 t
- #define ITCINTEN_SHIFT 21: c% d- ~0 j( q- ^. E
- #define TCCHEN_SHIFT 22
7 L3 Z3 c0 A w8 N - #define ITCCHEN_SHIFT 23
9 V, o2 D. o$ G - ( y" U% U9 Q6 [* i$ w
- static volatile int irqraised1 = 0;
; g6 U }+ l. f8 n' H1 e - static volatile int irqraised2 = 0;( f, o5 I6 ^7 T9 o/ \, s9 P$ v. i, W L
- 4 d, u% @+ T8 j9 ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' M& d/ j6 z* b+ S" U; q T4 ? - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* D- r# b; _1 E! o/ Y) R - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. s" w. k$ p @8 @; w - 5 t, n; ]6 R+ S9 D" m
- dma_addr_t dmaphyssrc1 = 0;
# F$ d6 W; k9 }" T" Q - dma_addr_t dmaphyssrc2 = 0; I, S( ^1 m# k
- dma_addr_t dmaphysdest1 = 0;- ?8 l9 w q0 A# d$ \8 P6 g
- dma_addr_t dmaphysdest2 = 0;9 A4 ^' G: b$ I6 Z' }
- 5 N7 K: s. q2 K$ r; y* y- j/ A
- char *dmabufsrc1 = NULL;, X) R- T' ?4 W( ?3 E% T# P
- char *dmabufsrc2 = NULL;5 A T% N% b" h+ V$ J2 M
- char *dmabufdest1 = NULL;6 I) R& d9 H+ P7 {
- char *dmabufdest2 = NULL;& a/ m) a4 S5 K$ m- M
& h6 i! G5 o8 k6 e7 D- static int acnt = 512;
7 g t& p; C8 ` - static int bcnt = 8;& B& {: x1 T$ f- c" m5 k
- static int ccnt = 8;
; f$ T/ q4 e3 x4 m' A9 y3 }1 v2 B
0 m X* d+ W8 ]" E: B- module_param(acnt, int, S_IRUGO);
. |0 Q7 g" E( I$ Q8 x. G& N0 @- V$ {0 X - module_param(bcnt, int, S_IRUGO);
2 }3 V- t" K" L2 S1 ]6 J - module_param(ccnt, int, S_IRUGO);
复制代码
* Y; R2 K0 R( i. W' O+ v5 A$ `
l: Y+ s5 W0 T+ m o( F 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 v1 |/ @+ V( \& } X% i, d6 e( \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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 y5 [# k: ]0 x, D 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 L0 b3 e$ Z% u9 g( P/ Z% E0 Z% A# g' W2 ?/ w6 v
9 E; A4 T$ s6 {
|
|