|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 + N' T5 t1 i/ r
- [code]EDMA sample test application
( ^5 _+ T+ S! |& t3 p - /*
' ` B: ~. y4 O' I/ \ - * edma_test.c* X, c' _/ n2 I% O" l. }" }7 p1 Z
- *" y. A, O- O Z
- * brief EDMA3 Test Application
( @4 @3 w/ F7 m! R7 f+ V& F9 O- N' Q - *6 j) [4 g) z$ {+ \2 {4 v ^" K6 B
- * This file contains EDMA3 Test code.
4 Y! B, ?4 k3 j! ^% K6 u( P9 A% j - *9 q7 |1 i# Q0 e6 E' }. }( ?
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 W6 \$ x0 N& J% ^( [; S - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 k9 `9 i9 b! A9 R2 q5 V - * TO CHANGE.0 `4 m+ ]5 z" \ R4 {, p
- *9 q+ u9 a% V7 A( A3 Q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 W o* v7 j3 b$ W5 J4 h9 w
- *
0 l2 b& C( e4 b& w" d5 {* e - * This program is free software; you can redistribute it and/or/ s; R/ b1 g0 O% x' @2 }+ n
- * modify it under the terms of the GNU General Public License as
6 w+ W; H8 x; J+ q7 p! _ - * published by the Free Software Foundation version 2.
% Y6 L# t$ W0 T# A - *
! ^7 G+ e% c* D7 ~ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 h3 t/ d" q& ~6 n - * kind, whether express or implied; without even the implied warranty) L5 K( m/ H9 \3 S- `2 j' P
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" h5 M+ i }! Q# \9 w2 F( p# _3 b - * GNU General Public License for more details.
) g' U# \0 {: J - */# e- @+ w8 q' T2 G
# }8 p4 c5 e( R" ~$ o+ n- #include <linux/module.h>% ]: o/ Y0 p( @
- #include <linux/init.h>
' J& e$ e7 S* p& U9 D - #include <linux/errno.h>/ \) J6 l; b+ f+ W
- #include <linux/types.h>
- |" P& l% h+ z0 O* u# a$ \5 y - #include <linux/interrupt.h>2 r* I( u8 e$ d2 H* i
- #include <asm/io.h>3 n) F& N9 a+ J* b2 p% `. \2 S: X2 ?
- #include <linux/moduleparam.h>
0 w& M8 e+ n) l# j# e8 Z - #include <linux/sysctl.h>5 q. {! @9 Z3 ]4 J7 M& |
- #include <linux/mm.h>
# ?% \ H7 t0 _7 z) ?6 G - #include <linux/dma-mapping.h>) T( X# o( A' m- n; m, L
; y2 f5 X+ o' _% a- #include <mach/memory.h>
1 v9 z+ K1 S7 `% L1 t# i3 _5 r$ F - #include <mach/hardware.h>
% g5 r% C* Y0 m0 v9 g" O# { u* G$ n - #include <mach/irqs.h>) Y( }- X, u4 S2 u9 c' M" C9 _
- #include <asm/hardware/edma.h>' w+ O0 e$ B$ Z4 S# j3 Z
( c/ w* M; N7 l1 H- #undef EDMA3_DEBUG7 r4 q9 R3 W7 L; P$ m! d
- /*#define EDMA3_DEBUG*/6 H; X# f1 v( j, _
- " X" m0 j" j" M( F2 a0 A0 u
- #ifdef EDMA3_DEBUG
: B1 _- T0 W) P - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. }) R8 j& A! }1 d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 B+ H/ ?8 e& A d+ O7 d
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- i4 o& x* J8 t! }- P8 ~; g' p
- #else
- b3 C8 G! p! w9 E - #define DMA_PRINTK( x... )
. b& d7 I1 x7 t - #define DMA_FN_IN( x9 O. Q! h4 c9 L
- #define DMA_FN_OUT
, t1 g/ f$ z+ X; ]% I S - #endif* m m! Y- q$ C+ a
. f5 U2 h$ C0 f# s# Y- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ x- n5 q$ K& @9 a4 C' A$ S - #define STATIC_SHIFT 3& ?5 ?2 S$ A3 r" L* M& A, T" E* C
- #define TCINTEN_SHIFT 20! e2 f- g7 ^& I) k2 d
- #define ITCINTEN_SHIFT 21# Z+ E) ~( k! c1 r4 i8 }; N
- #define TCCHEN_SHIFT 22
8 z# D1 N% z3 V# b0 Z! b - #define ITCCHEN_SHIFT 23
/ o$ S& t+ s$ p - ( ]! p' x4 ~4 q( T
- static volatile int irqraised1 = 0;
& H5 F! p6 p" g% J0 \ v/ y - static volatile int irqraised2 = 0;
* c, E7 B D% c - - ]; S* l; | y9 \) W
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( B/ k/ _, g, U; ?9 K
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 u- _3 v1 C2 S& m. D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 y( Z; ]/ [% _) D) x: [0 J
- " F& I4 Y! c! Z
- dma_addr_t dmaphyssrc1 = 0;/ z8 k) E# T$ \; K `# y
- dma_addr_t dmaphyssrc2 = 0;* b) |0 w" b0 z- d# L- Y
- dma_addr_t dmaphysdest1 = 0;
' l+ n A, _4 D3 T - dma_addr_t dmaphysdest2 = 0;
& Z5 V' q; w$ a; O- {$ Y
$ _$ J0 V* D0 d2 n) f t- char *dmabufsrc1 = NULL;% T- k5 y- q4 H- P$ Y
- char *dmabufsrc2 = NULL;
4 N9 k4 j" ~& U, Y - char *dmabufdest1 = NULL;
2 E5 ?" l9 m% i2 t5 f - char *dmabufdest2 = NULL;
* i2 F4 M! A& w$ w* q
8 f: W7 S, y; }- static int acnt = 512;- [" [& j/ b4 \3 @& ?. e: b
- static int bcnt = 8;
- b, Y' }8 Q% W, w! [0 g - static int ccnt = 8;/ A! |/ J- Z7 J# S( i [2 t( r7 _
- 0 S, B# l1 Q8 w J* f+ t1 }
- module_param(acnt, int, S_IRUGO);5 f$ ?0 S& U2 C) r# ^! g
- module_param(bcnt, int, S_IRUGO);
1 l7 m& \/ ]% C, B! M3 M8 j - module_param(ccnt, int, S_IRUGO);
复制代码
8 u! \- K) e# S: U" ~6 |
4 C% w9 Q/ c7 i 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- A7 _: W; \1 V4 t; uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% j6 F, W, \3 j# [, Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& E! L' Q* ?0 C
: W$ G' b9 w) R, l e
& e4 C6 c. g$ \- M$ N |
|