|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. ` \# u* X; m; L9 k- [code]EDMA sample test application
9 {! P& Z7 w% P$ O* d - /*3 v7 i1 N o8 _$ H8 i: M- d
- * edma_test.c
* a( Z7 K( q" l; _% E4 ] - *
8 w, D9 B* y0 a4 N# n7 B1 t8 N - * brief EDMA3 Test Application
/ g3 k9 A: _/ u5 z - *9 h" r9 f! O) d/ l' B" t" F
- * This file contains EDMA3 Test code.
2 {& x$ U8 G% O - *
5 M( a+ |0 I5 w" S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
' e& b7 A, p) d4 y) w- K - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
E8 ?: n$ Z4 S( W3 N& P8 P6 t Y - * TO CHANGE.
: A( M6 E- ?+ E1 [; R$ a( @ - *
7 [. i% Q1 E2 P7 f$ K6 O. I# j1 r% Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! K$ @- ?/ G+ Y8 a" ~
- *8 T, [' n$ m2 D% f( B5 X
- * This program is free software; you can redistribute it and/or/ u0 l' s" G8 i( R
- * modify it under the terms of the GNU General Public License as
1 b3 W, @+ x8 e, k - * published by the Free Software Foundation version 2.$ Y0 J2 N" Z2 o/ y
- *
: O9 ^+ A6 t4 R( W$ j- {+ c0 Z/ s: n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 e% T- O. S9 P; Z
- * kind, whether express or implied; without even the implied warranty
0 L2 H2 f7 e- t! R5 ^4 O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 }, {+ }/ h2 K6 I0 o
- * GNU General Public License for more details.3 \" o6 ^; J" N7 S* Z# v7 S, C
- */
! u/ [4 j( p3 S( { - : v- J4 q5 ?; J: f V5 j$ Y
- #include <linux/module.h>4 ?% k0 k# I( A- N0 f% f% o' a5 D" }
- #include <linux/init.h>
$ ~! N/ T+ b4 U - #include <linux/errno.h>1 a0 ?) e3 F* E. o' V1 l4 b5 s
- #include <linux/types.h>
8 Q5 T- D( Q! \- J - #include <linux/interrupt.h>+ Q8 D) Z3 j- X1 R2 r3 A
- #include <asm/io.h>
& x9 P A; S1 x% v - #include <linux/moduleparam.h># H$ i) { U) d( U
- #include <linux/sysctl.h>1 R" v) V+ l7 U4 |
- #include <linux/mm.h>1 F7 }5 |# x6 T8 t( G6 N# f: I
- #include <linux/dma-mapping.h>3 F* G9 O6 Y" N$ b6 q! G9 x2 P
- % S+ I: d! G6 I7 b
- #include <mach/memory.h>6 s. H, t1 O7 V! N5 i2 ~ [" A; F' ^
- #include <mach/hardware.h>( k3 t9 Q4 s$ B, t. s% `; W3 N6 b
- #include <mach/irqs.h>% f9 n, k+ K5 V# a1 Y
- #include <asm/hardware/edma.h>
. y* e, M( s4 i( r& q4 S' j# b; a, \; \
$ A5 D0 A8 i5 c- #undef EDMA3_DEBUG
3 X( u1 J# O$ p) r& ^, K - /*#define EDMA3_DEBUG*/
* w/ T- w( }& F2 o1 \: Y- L - 3 D5 v6 m# k/ }6 H5 C
- #ifdef EDMA3_DEBUG
\2 D, P& x) n% A3 I D0 |2 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! y& F; b* H- U4 O/ w2 ~0 w+ g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 N5 ^$ R/ [4 B$ _
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( B- n& ~$ m# i5 w' L - #else
# f4 q5 r/ e5 H; q2 D9 v' c - #define DMA_PRINTK( x... )
l# ~- }7 J" Z; Z - #define DMA_FN_IN' [2 G8 ]1 q% q# g9 P! Z
- #define DMA_FN_OUT, r/ G6 E M/ S8 v0 A
- #endif d4 @% g- ?2 s; N& c
5 h" x! m% I) M- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 u. y! a, H( `4 {
- #define STATIC_SHIFT 3
6 j' G! I* Y" g, \; a$ z - #define TCINTEN_SHIFT 20
2 x( V6 T2 Z' I( E& F2 L - #define ITCINTEN_SHIFT 21
/ e' h- r5 v1 ?& j Q - #define TCCHEN_SHIFT 22
8 Q6 T$ D8 y+ ~1 w2 n - #define ITCCHEN_SHIFT 23
- V+ z# Q1 p' W) i
9 e) ?' k4 U% l( z3 m' i- static volatile int irqraised1 = 0;
! P5 Q: C1 T5 @! v* ] g. F - static volatile int irqraised2 = 0;8 Z) n5 }7 B H) a7 y
* R( M" |* D8 p N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# ~$ a! v1 R/ q$ D# l7 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# D5 z( Q' m$ M" ]8 l: r, { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 V$ Z$ N. q, e' Y6 e2 f4 _
/ C0 [. _+ L1 _! i5 ^0 B- dma_addr_t dmaphyssrc1 = 0;7 A3 y% T* q$ j
- dma_addr_t dmaphyssrc2 = 0;
2 z8 X7 Q& ?, E - dma_addr_t dmaphysdest1 = 0;% v( ^% |" z8 u* @) g+ t
- dma_addr_t dmaphysdest2 = 0;/ O& A- V" K0 X$ h
* _% ] c0 T2 V- char *dmabufsrc1 = NULL;) Q1 x5 x4 T- e
- char *dmabufsrc2 = NULL;
. U- m+ Q6 b X/ Q - char *dmabufdest1 = NULL;1 I* F8 M2 K6 _, I& I! ~; S M3 }
- char *dmabufdest2 = NULL;
; F5 ?7 X4 G( E e5 O; a - 0 t! ^( n+ I6 D" |6 g- S' t! H
- static int acnt = 512;$ h& p: N5 A$ Q! `
- static int bcnt = 8;
# | Z3 T; [ P; @# L - static int ccnt = 8;
7 q& K ?1 R# ?* l - 4 P4 H- x4 v$ C( S0 v
- module_param(acnt, int, S_IRUGO);
7 J- r7 f# V. Z' {3 [ - module_param(bcnt, int, S_IRUGO);
6 t$ {* s! G m+ ^! Q. t p5 ~9 r - module_param(ccnt, int, S_IRUGO);
复制代码 ( V# A. v0 m8 B* B. F3 s6 R8 O7 U1 n
, V& v5 c! [1 W! r# r( \
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ e, j6 k! ~& Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- _, y: Y. V" a* |/ ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: ?8 `" ?4 A2 M9 n1 M' {% A+ w+ _/ e! {$ s2 ^) q$ [
2 }- @+ L: n3 w
|
|