|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" Q& r, }4 e* C& m E# f3 |9 v- [code]EDMA sample test application" Y2 I6 I: U/ f' q& u& I6 E
- /*
% a# c' W3 t l, u% w) K - * edma_test.c
2 ]/ ^" ~! z2 U* p: H8 d3 F - *; Z6 [9 ^' b* C) p. I3 q9 i/ ?
- * brief EDMA3 Test Application
* @# B' L2 u* d, k! ~ - *
( ]1 L9 ~# a, n8 @% A3 N0 r - * This file contains EDMA3 Test code.
W! ]" e5 I/ _. s: ~- j - *
9 `% @) B% n+ j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# n* R7 d# S) I* K9 D, q& b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: w' r$ q4 R, }% R1 Q - * TO CHANGE.
( Z. Z8 i3 W+ K5 |2 }; M - *
$ o7 |: e$ ^, }8 A6 a7 v - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 d% E% Q) P# z' n. I - *+ V& Z8 o a5 p. L" H! L* w; |, L
- * This program is free software; you can redistribute it and/or, @' l+ o+ ~$ e( K- t
- * modify it under the terms of the GNU General Public License as
# D! {* w6 L p4 n+ D1 l( X9 k! T - * published by the Free Software Foundation version 2.
8 y$ j) I: L W: Y$ |' \; z& l - *
2 C3 F% `- x2 _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! d1 z- t) ~$ x
- * kind, whether express or implied; without even the implied warranty' a9 A1 Y' K4 ]+ ^3 H/ h: w' B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 v U" h |% m - * GNU General Public License for more details.! `; n1 ?, J' D6 ]
- */' C0 {, S6 i7 O0 a% Y8 \, `6 ]/ x
# W9 c( ~# a/ C* F: X( r/ A- #include <linux/module.h>$ J# x% u: G; c7 `
- #include <linux/init.h>: ^1 Q8 v$ i$ j6 I5 d: h5 L
- #include <linux/errno.h>
+ {# a& ` w d( K- F0 T6 y* z - #include <linux/types.h>
# i/ E' y: r$ N8 F5 l - #include <linux/interrupt.h>1 S; H* s8 g( c) z
- #include <asm/io.h>
4 j$ d1 [& P, X/ G( j: o! v - #include <linux/moduleparam.h>3 ^ ]. b2 ^! k& _
- #include <linux/sysctl.h>% c6 S) N0 D) K0 i1 A {
- #include <linux/mm.h>
0 u0 d& {9 @" D! O9 P: J5 @( a - #include <linux/dma-mapping.h>
+ U# b5 y" }' m4 v! k7 `" P
3 @1 g# s3 Q3 \ e' F- #include <mach/memory.h>
! g; g2 k6 c: I. e8 g2 c) K - #include <mach/hardware.h>. l$ S* ~. ~; B6 c
- #include <mach/irqs.h>
5 @0 t- `. w1 A4 O+ j - #include <asm/hardware/edma.h>7 O1 W9 O* P; _, j; M
- 7 s/ C# Y9 f4 {2 P0 q/ d$ O
- #undef EDMA3_DEBUG- _) L9 U2 E4 J
- /*#define EDMA3_DEBUG*/
, \6 D# x0 H* ~( P
8 k3 h& A1 u( M2 D4 n2 o3 n# P. D- #ifdef EDMA3_DEBUG
! ~4 W" x; o/ O8 M& q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 _! T( B, k9 p+ n# `3 B0 K! X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); c% x' m. v* Y: Y5 @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 g% |1 m' @1 z) D' } - #else$ u0 _) F* J% E' i. W
- #define DMA_PRINTK( x... )
6 g, U8 Q& S9 E/ j( i - #define DMA_FN_IN# y, X: P' S& {3 e" f: V
- #define DMA_FN_OUT
$ c1 I2 s7 j: T4 [" p: f - #endif
) w( R, H( X' ^/ X0 N. C) X* ?( ~9 K
H* @/ R# b- l# A- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ p" |. d5 T1 `/ T
- #define STATIC_SHIFT 31 N7 T7 o2 l4 I. o) V( i) V
- #define TCINTEN_SHIFT 20
+ F, Z# D4 b/ b, i - #define ITCINTEN_SHIFT 21
3 O% [* Z0 B3 _- A - #define TCCHEN_SHIFT 22
$ S* q4 o6 D* d8 M8 D* j - #define ITCCHEN_SHIFT 23
3 a, }7 P) P! v9 E- M - % W9 S8 |" ~+ q- G* y
- static volatile int irqraised1 = 0;
6 e) b, z- a: D' v K+ c - static volatile int irqraised2 = 0;( p% R: z, {/ r; m/ b* V! x
( R: j7 b4 u, } t9 t4 C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) t6 I( x0 ^! g& u* M+ U+ a9 [ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* i0 F! B0 }, K2 X% _/ J1 |. v
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ A/ A3 t+ S: ?" Y% w- Z e) R
! ~/ ~9 u; Y2 I3 @( w% @# e; E- dma_addr_t dmaphyssrc1 = 0;
3 |0 V4 j. Z ?* U/ e8 ` - dma_addr_t dmaphyssrc2 = 0;, ?- C8 O/ c: \! D9 s) G
- dma_addr_t dmaphysdest1 = 0;
% W) z: _/ X: b - dma_addr_t dmaphysdest2 = 0;, [' N1 c% N* h9 ^5 C. {! K; z
# R/ k+ F$ X. o. |+ h; i* E- {- char *dmabufsrc1 = NULL;
0 Q, } ~7 H5 {6 p( ]$ }7 o4 ` - char *dmabufsrc2 = NULL;- Z" E8 X @7 H1 k2 t6 Y
- char *dmabufdest1 = NULL;5 f# s0 _. a% O% ^+ c# o9 Z
- char *dmabufdest2 = NULL;3 z1 Z( Z, C8 j0 p
3 {% i# o! S$ `1 B% S- static int acnt = 512;
9 P- @( i- G+ f3 V8 I% A - static int bcnt = 8;. F% H( ]" I" L6 q3 k6 E. N
- static int ccnt = 8;
" h$ f/ U3 |) w& `6 L% u0 v4 ?9 Y
# G1 u* X J. x, }5 b) z: K0 J- module_param(acnt, int, S_IRUGO);6 ~% y% ~. s/ b0 o* Q& }
- module_param(bcnt, int, S_IRUGO);) d, r0 } L3 D8 D! ~$ e
- module_param(ccnt, int, S_IRUGO);
复制代码 ; Q+ p9 p1 u: d+ Q1 s
' Y# a; U2 A$ ~$ k* p4 c
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! Q3 p9 }7 J) Z5 @0 N: jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. x, O/ F& O# R \
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ v: q( s, H# J3 N( y* r
5 S, p7 q, F6 F! V0 q7 A' s6 Q
3 I" E, U$ D% V0 g, Z1 F$ { |
|