|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( }- t& ^: p7 d l( C
- [code]EDMA sample test application
. N8 \- S: F2 p3 h - /*- [% P4 V7 X6 |2 l5 i) J
- * edma_test.c
, e$ _0 R, a4 R: G* N, p) z - *7 J7 |9 L0 W+ _/ C: ?
- * brief EDMA3 Test Application
! B* I3 m' H7 F5 V; F, X - *( z' G2 t1 F: S2 I: n1 J
- * This file contains EDMA3 Test code.
0 I3 Z' [1 Y) b5 J, D - *! m, i$ T: t6 ^ U% x$ ~4 N- J
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: Z: I& _9 |/ Z3 D- S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* _" u+ {5 t5 ^% F) a+ f - * TO CHANGE.
* J* k5 O" A. I% O* S q - *$ w% g* z# d. Y( i2 e/ B8 S1 H* Y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 s+ k6 w) k# _5 P4 ^, P3 { - *$ J0 j: n" ]$ n! |9 H* y# T
- * This program is free software; you can redistribute it and/or, F, s( H2 o0 ?0 X4 O( s
- * modify it under the terms of the GNU General Public License as! L1 u# A" G3 s) |3 f$ O& }9 b
- * published by the Free Software Foundation version 2.
1 h' q) w2 i* x' W; k - *
) _# G8 u3 { D* k1 O* I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 k( K" p% Z# g# j2 A9 Z( T3 j9 ^ - * kind, whether express or implied; without even the implied warranty5 c# [( d" F4 R; N" }9 H6 z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 O' [: t0 [+ J7 r: a7 T
- * GNU General Public License for more details.# I8 t8 c% a; t4 y2 h
- */$ X! l- |) s" O3 } z4 z
! d+ x. _- v7 A5 S- #include <linux/module.h>+ [. L7 q9 T% p; s6 @( M
- #include <linux/init.h>
6 n$ }% M8 R2 S w9 x/ y+ ] - #include <linux/errno.h>5 L# Z! `3 L3 L( u# u) Q
- #include <linux/types.h>! C$ b( v/ m8 B6 {! l
- #include <linux/interrupt.h> q6 |2 Q6 _3 |$ q* B- O
- #include <asm/io.h>
+ w. g- Q) L& V1 y5 k - #include <linux/moduleparam.h>+ m, G/ ~ C6 j D" B
- #include <linux/sysctl.h>
Z" o3 s1 ]/ F( s5 c8 _* Z - #include <linux/mm.h>
. B; {# @ m8 c3 k2 T - #include <linux/dma-mapping.h>2 }) Q: Q5 e. l o# L, \* C
1 B3 N- d5 \9 f- #include <mach/memory.h>$ N. f- W% i& \4 ?. W7 e* i5 R
- #include <mach/hardware.h>2 E& ]8 H1 M5 F: y; z, ^% [
- #include <mach/irqs.h>
0 ~6 t6 a( ^, m7 D1 P1 H( C - #include <asm/hardware/edma.h>3 T* E$ S1 |( `8 s$ N% e/ K
- 7 o o* F. z3 `5 q( g- F
- #undef EDMA3_DEBUG
7 k* g; m- A0 J8 } - /*#define EDMA3_DEBUG*/
$ H4 `6 }4 G& H# d+ ~9 G - / y* G! r3 y- v8 w, L/ R+ o
- #ifdef EDMA3_DEBUG6 q4 _: \# L& [7 [# v2 o: t% b
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' y/ T# K' K! W) L
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- d4 m% Q% r O, k/ T2 {" M* s
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 n6 M9 i7 k* A; _ - #else7 `, X9 k9 b* _0 e0 \8 P P
- #define DMA_PRINTK( x... )
9 V I7 Q/ ~. L8 I1 Y$ T - #define DMA_FN_IN
4 H& \* {3 R+ J3 |; Q% |2 ^ - #define DMA_FN_OUT
. D- _; @* P+ k5 M4 x; Y - #endif1 \- f( n( d+ v# L
- 1 A/ S5 N2 S* r, L. N
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% g! I/ c& l! d7 i
- #define STATIC_SHIFT 3
# t0 L7 \: |7 |* y+ a1 \ - #define TCINTEN_SHIFT 20! C/ F+ J$ w1 B
- #define ITCINTEN_SHIFT 21# d3 N# j9 L1 z% g" | n
- #define TCCHEN_SHIFT 22
( R- {& E i$ m' O4 q - #define ITCCHEN_SHIFT 230 _& E8 h* f. C6 _( o9 ^/ r
- 5 Q$ w7 ^; m6 W$ z+ u3 H
- static volatile int irqraised1 = 0;
. l: t' J0 ^9 C5 P. B - static volatile int irqraised2 = 0;
8 z3 y& }9 f" q$ C+ j
5 t8 U I6 M/ p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ g) S; R, `' E. X# e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% _: Z) [( |6 {. k) {0 T3 b4 n7 X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& K$ o" z' n- j" F
! _$ B' n. d3 L- dma_addr_t dmaphyssrc1 = 0;9 m% H/ [7 u' d6 G. V" s# ?* s8 s0 l/ s
- dma_addr_t dmaphyssrc2 = 0;! U& d# J0 ]# \! }
- dma_addr_t dmaphysdest1 = 0;8 R+ w6 z3 m/ }/ g5 U! T2 D/ [) {/ l
- dma_addr_t dmaphysdest2 = 0;
( b6 R$ J( _, m; ?# w4 Q5 f# p - 4 K9 E8 h6 x$ ~) ]3 x" y
- char *dmabufsrc1 = NULL;
& F* i [5 ]; r6 x - char *dmabufsrc2 = NULL;" f6 L, u$ h2 ^+ T P1 x
- char *dmabufdest1 = NULL;( f0 |: B% E$ c$ `
- char *dmabufdest2 = NULL;
( I% ~3 W8 V$ X4 W9 W0 i4 c
6 P: @+ R& ?0 J4 l# \& a, x- static int acnt = 512;. i' q. w8 ?8 u
- static int bcnt = 8; T) V; w7 |9 z+ x
- static int ccnt = 8;% `- V# v( Y; Y9 ?) I. J
. @& o+ `3 {! T- module_param(acnt, int, S_IRUGO);
& ]; m9 H" Y/ @4 G5 V/ [ - module_param(bcnt, int, S_IRUGO);" ?# V6 E0 W" w2 g' j( @9 o h
- module_param(ccnt, int, S_IRUGO);
复制代码 : t4 c0 D! C: _6 o; z) p
& p; n6 d- M W6 R" P 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 x- p0 v* I' n% [# g5 iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* i; ^% @# T1 o( B3 ?* @
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 g+ X- s' C( B# ^0 Y: ^ x& k0 `7 C/ R" w5 C
+ [2 s1 N! Y0 t' `# F" A# Z |
|