|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 E9 R8 G0 P0 r( k
- [code]EDMA sample test application
9 O# X, k. J5 a - /*6 x( c0 x0 A5 K, M
- * edma_test.c
u; _; t5 Y7 I, j - *, }! u# m6 Y6 }) Q
- * brief EDMA3 Test Application
3 A; U" Z6 N) S1 G2 K; x& I5 W - *
# I/ U; }. `2 \ F# E' e) f8 G% Y - * This file contains EDMA3 Test code.
% z/ s5 ^+ n, N: C+ ]& H - *9 v @3 n- l9 ]. u, x8 U+ Z: {% ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% c) i4 S, D) v: f# G! x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 _. |- c# H! E$ `4 W8 f( U - * TO CHANGE.
4 H M* ^- j% V* U ? - *
0 X2 Q( G) V- l! K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ M+ [# F K/ K
- *5 w9 o" \: g, V: |( b: r3 u
- * This program is free software; you can redistribute it and/or# v: M0 t ^ {1 L/ I# }. @2 j7 C
- * modify it under the terms of the GNU General Public License as0 L3 _" ^1 @5 X5 e6 d8 W* Y# K+ }
- * published by the Free Software Foundation version 2.
( z$ O/ \: S$ D- a2 d( q - *
8 J8 @7 A$ c" c# H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 z/ T/ x( @* b) r( F; D
- * kind, whether express or implied; without even the implied warranty
7 p3 `, [$ e# e7 N - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( Y; v& F9 L; Q( \$ A
- * GNU General Public License for more details., F0 `% \/ y4 u2 u8 l2 |
- */. b2 B& o6 K* R& B$ D F' T
- ' C/ n) c+ D- k' O
- #include <linux/module.h>
+ o+ q; |7 d9 I4 N/ I - #include <linux/init.h>$ T% T0 g$ d. G- D6 E& A
- #include <linux/errno.h>2 \4 a2 ^" G( v9 E# t# w: {! l0 e
- #include <linux/types.h>
. u& ~" P# l8 W7 ^/ k8 a" K - #include <linux/interrupt.h>
: A E" Z: M3 Q, s - #include <asm/io.h>
$ q# {- T; ^$ N, U7 a - #include <linux/moduleparam.h>
- X: n0 `9 }: l2 c' P. u3 S - #include <linux/sysctl.h>' J% g, p4 C( s& X' ]7 [# y
- #include <linux/mm.h>, d1 u) R: @! S' H/ C) r
- #include <linux/dma-mapping.h> o$ p7 a% c# d2 F/ ?
- 0 l$ E9 }5 b5 N) o. E# K; l o
- #include <mach/memory.h>! I, }8 A5 K7 V3 j4 F4 S+ i
- #include <mach/hardware.h>
3 b9 N4 d: I+ Y2 _. y4 e( ` _ - #include <mach/irqs.h>" T* E, O5 K8 L1 `/ j
- #include <asm/hardware/edma.h>' v4 a% M9 C$ Y2 A( {9 q/ E! ?
7 P* a) b+ Y. u% s- #undef EDMA3_DEBUG1 d/ d# u5 D& {* v! J) M0 n9 W
- /*#define EDMA3_DEBUG*/
9 u5 g- B5 h4 I4 H& S* ]' A% O - 1 H% K' E2 `* C5 r9 x, X" J
- #ifdef EDMA3_DEBUG8 w/ u6 j& i. }' b9 u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' i. h k9 k- u. Z6 _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 i$ M# p3 n/ H) m) Q
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! f8 [6 B) I( B+ Q1 R
- #else j4 y, r1 S3 ~
- #define DMA_PRINTK( x... )
) n/ T) G* d0 T3 j, j - #define DMA_FN_IN% s3 S: j& @" ^9 S2 f9 \
- #define DMA_FN_OUT
2 u6 C' A9 `/ \% E G - #endif
+ y3 O# U1 j7 X$ Z! H- Z
! d5 \2 i8 P1 ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ m/ Q8 u& P J. h. e* n6 C
- #define STATIC_SHIFT 3; o/ k' G2 }9 W9 B6 E; |
- #define TCINTEN_SHIFT 20
6 q; ]5 c2 U( l- X, M! B - #define ITCINTEN_SHIFT 217 E: J, t% @6 u( q4 G
- #define TCCHEN_SHIFT 228 [) {$ ], U; {3 O) T
- #define ITCCHEN_SHIFT 23: y& N7 P4 L% }6 A3 _& P7 _1 E f7 u
6 m9 c, h7 |. ^- static volatile int irqraised1 = 0;
( H" ~6 X2 W4 h7 ?1 a5 k+ n! s - static volatile int irqraised2 = 0;
. R+ o8 ~$ e+ C0 m$ |
2 E0 D' b! S3 ?1 r# ~# k) z H5 i [) p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) Z- y, t. e/ ]) @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ }1 Q( \( j$ [, J* ?$ E$ m ]/ [
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( t$ i, N* l& B8 H4 E( ?" Y
- 9 i) y: v4 c6 v" F6 T6 b- p# Z2 k, Q
- dma_addr_t dmaphyssrc1 = 0;' p P3 t% f& ~: ^/ G- ^4 h6 m
- dma_addr_t dmaphyssrc2 = 0;/ X( j' h6 P# P6 {! _6 e
- dma_addr_t dmaphysdest1 = 0;9 G- e" P3 b. v6 d3 a8 ~
- dma_addr_t dmaphysdest2 = 0;; W5 S2 k6 \$ k9 Y. {& V2 l
+ N4 Q a2 q) | W+ ~+ p- char *dmabufsrc1 = NULL;
: X3 _$ v, }+ p8 L( h L- u - char *dmabufsrc2 = NULL;7 U9 J* e2 A) L
- char *dmabufdest1 = NULL;
6 X6 o# o; p+ d y. s6 ?% F - char *dmabufdest2 = NULL;' {8 y5 q( j# E- i
+ K9 D) \8 F* U4 t3 r* }- static int acnt = 512;$ c5 G9 Y) H, n* M
- static int bcnt = 8;0 w8 U: Q2 @+ X/ W* S3 }
- static int ccnt = 8;
% I6 Y& O& B" H/ E8 y - " T! ~# i8 `* j7 L9 I# I
- module_param(acnt, int, S_IRUGO);
9 b2 k* U5 n* H X# e9 N - module_param(bcnt, int, S_IRUGO);% S3 j0 {, M8 J: k; W0 E! n
- module_param(ccnt, int, S_IRUGO);
复制代码
, D7 z8 D. l! b! J" N2 o
. N. J& S& H! F) m, C0 B# V' N! u 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 R; u; k9 F1 C; A8 r) Parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: K. Q/ ^; j# y9 i- J! g+ b+ v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& O0 ]/ I* k; y7 `# k
. d- S6 F9 Q+ j& X' o) ^% a: o
4 ]' P/ S, n! b; c! }8 |
|
|