|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! Q% ~/ O% Y1 ~' Y a3 L$ n% `0 t- [code]EDMA sample test application
2 `( V$ o1 Y+ u p0 S: | - /*
$ S" d- n' V( z - * edma_test.c C# d9 c9 O7 f0 i+ a
- *
1 M# f. X' y, p7 Z( K) c0 _ - * brief EDMA3 Test Application
: N2 X1 Q+ }5 o - *
9 |- v; k- ^4 A( p' x& P. u - * This file contains EDMA3 Test code.. g# X" A/ T( u3 j" q- h! l7 K$ v
- *
" Z: \) Z) b7 b1 H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: |/ _: s* o& Y( `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" o, b$ Q& J s- v - * TO CHANGE.9 N8 g+ g2 p: ]. r. d) V2 K" j3 \
- *) x, {6 T8 t- l. Z; E
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% t1 _. E0 g* L/ U - *
j) s* A$ s: f! M5 n - * This program is free software; you can redistribute it and/or
8 s1 a5 v6 C/ N* {2 p1 g - * modify it under the terms of the GNU General Public License as
( u& ~8 ^* \1 ?5 f. ^! D( G - * published by the Free Software Foundation version 2.& G+ ^" e. G; H! N
- */ i' d' V: ^/ i" A. t6 [
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any% Z' Z3 U$ z" U+ v; Q
- * kind, whether express or implied; without even the implied warranty8 y, l# t6 k% r l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ S' O+ G: M8 K3 |
- * GNU General Public License for more details.( w$ G: ?3 U6 ^5 K, `$ A
- */
% d ^" I( r2 @9 p- T7 z% S - 7 m- E- m1 g5 ~; ?& ^: m9 B
- #include <linux/module.h>
1 \4 J0 M: z2 _# | - #include <linux/init.h>0 n( ^ g+ B& s& H# ~: H \
- #include <linux/errno.h>: L0 j& L& Y/ |' q9 {
- #include <linux/types.h>
! B# e# Y6 Q( v. x; H8 a9 A - #include <linux/interrupt.h>
7 M, N7 q: N& F& t1 [2 Y - #include <asm/io.h>( z* U9 A6 v7 y+ v% Q; k) P- M
- #include <linux/moduleparam.h>
9 N9 |8 k7 x. z! C, E* o( L - #include <linux/sysctl.h>
5 D% z+ P T- |3 e; |4 r7 a. X) z1 t - #include <linux/mm.h>3 @( i5 U2 F2 U* Q; `! D( [
- #include <linux/dma-mapping.h>" S$ m& t9 g. K1 e5 m6 O) e% T
- # c" s+ `' S9 |3 _& n! ~! I
- #include <mach/memory.h>/ k A6 f1 }" `+ h, B, C- G8 s
- #include <mach/hardware.h>
4 ^, |/ m. I" O1 C$ }3 P6 x - #include <mach/irqs.h>- c' h' V# }& t
- #include <asm/hardware/edma.h>
/ c u2 {/ ^- i# @* X9 q% [
6 @- J5 n1 e/ |. `5 C- #undef EDMA3_DEBUG
( p" ^) S- x6 B* S( G" a - /*#define EDMA3_DEBUG*/6 a8 K* J. l4 h7 V- v5 y
- $ O2 M- b: w' w3 }
- #ifdef EDMA3_DEBUG, @5 X& t' r& j+ m* C& V
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): ~. P3 ?2 G: p. I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 j" v- H6 s4 k9 M
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 v2 E$ q# J/ t5 k - #else
4 V) m$ u$ n& B - #define DMA_PRINTK( x... ), z! B/ Y6 h5 g8 N
- #define DMA_FN_IN
! i' y( y' b0 X2 a+ N2 q0 R+ v, H - #define DMA_FN_OUT/ Y! {- x* T8 T% }5 u7 ~
- #endif
1 R: b0 Q5 A% \
! r# ?3 [5 [% V' u7 v* v) { i- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 ?/ q; r1 P5 |& @% M6 e) }/ D - #define STATIC_SHIFT 3* w7 O/ _, P6 j: k$ y8 r9 }
- #define TCINTEN_SHIFT 20
; T5 m% n) M9 R/ z9 ~3 T/ `: Z - #define ITCINTEN_SHIFT 21
6 D0 W+ n8 B, n$ r% T8 @$ \$ B - #define TCCHEN_SHIFT 222 u6 A# t/ q* L/ s
- #define ITCCHEN_SHIFT 23
' f' e% I9 u3 `6 ~: ^$ O* | I - . o( D, ]. z2 F: L
- static volatile int irqraised1 = 0;
: p9 j( K8 b2 \" O" k7 L: i - static volatile int irqraised2 = 0;
) {- Z8 W$ X) k6 @$ N - 1 o/ I4 t9 X; Z/ _5 _8 S/ T. p
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% O3 x( {+ }- `8 c; I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ P- A+ G+ I9 A9 n& k6 T1 |
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# B% V9 S" y5 Y$ h0 D1 l( C
- . l3 A, R6 t f
- dma_addr_t dmaphyssrc1 = 0;- d/ l4 B3 b1 q j0 B: i
- dma_addr_t dmaphyssrc2 = 0;' l' }$ q& Z/ j
- dma_addr_t dmaphysdest1 = 0;
4 u* d+ m' C, b6 b7 X5 I% k2 x$ G4 ~) [ - dma_addr_t dmaphysdest2 = 0;
, I- ]$ o/ ^, `+ k/ D7 k
* L+ K& J1 T+ Y1 F' E$ G" a0 c' j/ q4 _- char *dmabufsrc1 = NULL;' o' \2 q) D# N0 _
- char *dmabufsrc2 = NULL;3 x5 ]. b* Q" Y X( f, o
- char *dmabufdest1 = NULL;# c5 b7 r% r: n2 [0 V. T+ ?
- char *dmabufdest2 = NULL;5 B4 e% v0 P& s+ t, Z9 Z
+ Z+ H |0 a# i$ Q2 `6 N/ ?- static int acnt = 512;. h$ q1 r6 {, l
- static int bcnt = 8;0 a, _: ?* D3 b; e; v& c
- static int ccnt = 8;
1 N# o. k" m& v# f9 }( ]6 D - 1 s* J" S% r/ x! B% Q
- module_param(acnt, int, S_IRUGO);
0 l: d3 h1 L9 x0 J& }; E: Q - module_param(bcnt, int, S_IRUGO);" K& f. x0 U1 Y) V1 H
- module_param(ccnt, int, S_IRUGO);
复制代码 1 g5 P. T1 z7 N! H$ L1 ~
: K5 Z) B( ?; z9 O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
& F! |8 j$ u V8 u. Oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! h& ~: p; @$ W 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
+ m* m5 Y2 g% [: \ S8 Y4 e7 P4 k; Y4 M2 i" j, ~ Z2 [
9 A; a/ _% C+ p4 W
|
|