|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
# F0 `% k3 d" O+ _0 R- [code]EDMA sample test application
. M$ u8 w9 W, e/ W0 M7 R! k - /*- ?; R" [% H+ ?$ P- l
- * edma_test.c
# O* r# _: X t% p - *$ E' H8 G1 F! T, a+ [! p. v
- * brief EDMA3 Test Application6 m* r2 n% c9 Q& z4 @: k2 e7 T
- *
* V6 h. {# c+ n0 T) |2 K$ z: T* h0 s - * This file contains EDMA3 Test code.* q* |: O# ?- u b
- *- w2 o, F: }- I& M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 V* b% c+ W' K8 C H' D X
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
A+ F5 \ h5 e$ ]9 e - * TO CHANGE.9 D% `! ]4 O( y( V) y! W+ K4 M; U
- *7 ?' |3 n, X5 G# O% O
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* X9 [2 p- [6 {( h2 [
- *! V* S4 Y0 v# V8 Z u% F
- * This program is free software; you can redistribute it and/or% t3 u' Y. N9 r* U1 R6 p, X# T
- * modify it under the terms of the GNU General Public License as0 u1 U: _7 Q) |
- * published by the Free Software Foundation version 2.6 E/ [9 K* X- h1 O$ v7 x* T5 X
- *( ]: o3 _2 w! \0 j
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" _0 D9 B# X2 i+ \) u4 r - * kind, whether express or implied; without even the implied warranty2 y# d" M% Y: T; a* u/ Q( K5 N
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( H% L' X: O% w; U7 x
- * GNU General Public License for more details.
1 g& Q( `/ }$ j1 j: {( a, z, y( ` - */
4 b2 ^. E7 [5 Z% P
% I+ i- a% ^8 z. r- #include <linux/module.h>0 ^% {! v* H1 P! |, q. q
- #include <linux/init.h>2 _' X+ x! s8 x% k w7 ]
- #include <linux/errno.h>: e5 V5 q" ]+ J1 P; |# Y
- #include <linux/types.h>
/ e3 @/ Y$ K b( }0 | - #include <linux/interrupt.h>9 I/ G/ N* t: u6 t6 m9 x$ o* y
- #include <asm/io.h>
; {0 D6 e. P& H( X% x) ?! w% D - #include <linux/moduleparam.h>+ u% j; t/ V2 }1 U& E
- #include <linux/sysctl.h>, X$ m2 m5 @' V
- #include <linux/mm.h>
5 a+ B. O) S' k - #include <linux/dma-mapping.h>
) t( Q* b% H9 d/ o" ]
, N. n( E7 Z" q& Z- K- #include <mach/memory.h>' p2 S" D. @/ Q7 p" v
- #include <mach/hardware.h>
' N9 O2 q, W/ q a* l. f - #include <mach/irqs.h>8 M/ Q) ] s; S; Y# P4 |
- #include <asm/hardware/edma.h>- G! F6 ^/ I- W* j! K* [8 x/ x- z
- ( @" T) v0 X7 g5 s" D+ C3 F/ W \! S* Q
- #undef EDMA3_DEBUG
5 z6 B% ?. E! S4 i5 S! C, g7 ? - /*#define EDMA3_DEBUG*// J& c3 y+ w) `: B4 M
, R: L& [. o: E O" Q; A3 X) p( U- #ifdef EDMA3_DEBUG
; O# S _5 S- t - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) A. |! x. E [; U) N* A( Y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; [0 |; e* }5 V; a7 |, N. W/ u - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! ?4 s0 f6 ]7 G; `+ ^: E
- #else
A( S; }* e/ K, K6 V- h0 s8 A - #define DMA_PRINTK( x... )0 Z6 I' a$ e- r! q1 E
- #define DMA_FN_IN
+ i% z1 A( R& `. r) [2 w' B - #define DMA_FN_OUT
# m3 H D- c+ U6 i/ l ]5 P - #endif& {! s6 j! v, Q j
- k8 J$ ]. j: X# y9 [( }7 x
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. G4 B8 G8 w9 h, b+ I6 { - #define STATIC_SHIFT 3; K( f% T& M! Q
- #define TCINTEN_SHIFT 20% ~# K$ i8 G9 [, e
- #define ITCINTEN_SHIFT 21
+ r5 L& f* \6 i$ a4 P2 P# q - #define TCCHEN_SHIFT 222 K j: L8 V8 N+ h: t& M
- #define ITCCHEN_SHIFT 23
& T' ]3 P9 L" H) S/ n
; A+ z% X" S, S+ X- static volatile int irqraised1 = 0;/ k8 k0 _+ Q: |
- static volatile int irqraised2 = 0;
) C+ f+ F2 d& D
% ]3 k i. E7 g7 L( ]0 r- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 G3 V' z0 p6 U" C' F3 s* E* _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' N. T! p! P3 c. u0 I! T4 [8 [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% z6 H, X+ [ c; x - % {: M+ g" t6 P o
- dma_addr_t dmaphyssrc1 = 0;2 X6 _( L; [$ a9 r, H" \
- dma_addr_t dmaphyssrc2 = 0;
8 k5 v& O' I2 y/ W9 q# o$ H - dma_addr_t dmaphysdest1 = 0;
% d) p$ T: ~2 Z1 n7 s# A4 ] - dma_addr_t dmaphysdest2 = 0;
* O0 L3 K2 {1 z) n; Y) X& l - 5 V9 N9 R! }0 _/ ?2 t1 M2 h
- char *dmabufsrc1 = NULL;
3 A. b; d& f4 Z! y$ b - char *dmabufsrc2 = NULL;
. M+ Z5 X+ `; L. ]( _( G - char *dmabufdest1 = NULL;
2 ?- W. d- V7 K7 G* W$ a9 n - char *dmabufdest2 = NULL;
/ K) G+ J) h; t9 t! B, d1 K# T - 5 e3 p8 E+ d- _4 P! z7 v9 |/ ~
- static int acnt = 512;
& }0 C* ^4 P6 E0 q* `, z+ S( m, [( `- \ - static int bcnt = 8;1 O; k7 f8 y+ R# l* G L5 d8 B5 B6 T9 c7 W
- static int ccnt = 8;
2 R- S0 P. m8 P. q! e+ |' g) F7 i - # s4 x/ ?9 M4 t; i l
- module_param(acnt, int, S_IRUGO);" H2 P# P3 c; L6 [+ h* Z0 @$ B- }
- module_param(bcnt, int, S_IRUGO);1 b e$ A! _1 \' z
- module_param(ccnt, int, S_IRUGO);
复制代码 ' I* E7 n! D9 o# z
6 m, @) n6 ^" U& r) e7 P4 i$ {# g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用# Y7 q. F( s) g
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# s2 j2 {$ d6 I2 y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 W* t9 l/ `/ H
% q* [4 N |5 U8 D+ V5 J/ \
4 H$ ` N0 ]. y |
|