|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) \2 @6 e$ s( s* X, T- [code]EDMA sample test application
" c; w( e' k5 g4 v3 b2 p$ U/ D - /*- a9 [* I7 l0 s3 G; E
- * edma_test.c
, I V; h5 X; m: a - *
7 d0 M" o8 v1 M8 Z ` - * brief EDMA3 Test Application
1 H/ T* U, }; M2 c& a" \6 ~ - *
5 U; ?- X2 ~3 m8 d T) \ - * This file contains EDMA3 Test code. a9 k/ g2 G; t# m: ~# t
- *
' I" S' m. J# g9 ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE" F9 D0 _/ P* U3 m% q }
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) ^! B! P0 i! ?4 q: S' x9 B; N6 @ - * TO CHANGE.# d. X5 P1 z0 _* ]+ i; L
- *
: C; J9 s% T2 k0 x - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& |: b; k, ^* E0 a* Q
- *
5 c F b) G; S7 }# z" d4 f - * This program is free software; you can redistribute it and/or! m; s1 @0 X3 F3 u& ?
- * modify it under the terms of the GNU General Public License as9 u" i) ~# Q& a S1 _% f3 w
- * published by the Free Software Foundation version 2.8 O- z* t( G! e
- *3 P$ d" L* [9 Z, L* P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any' k, V) e5 {" C% x) g; f' r
- * kind, whether express or implied; without even the implied warranty
6 X& p9 [# n, h - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 w! h% k- f4 N - * GNU General Public License for more details.
0 U# }' i- ~. J; j5 A. M# M - */
% J/ F& O5 |9 [) b# h( U - * {# x# n9 h7 s, [
- #include <linux/module.h>" E" y, Q1 s) w
- #include <linux/init.h>
& s1 |) A! T. v+ d' ]4 ]; D. `% v" ` - #include <linux/errno.h>
4 I* b7 j; Q; n3 v4 G* w - #include <linux/types.h>, b1 i/ G& F7 O8 E; A/ w
- #include <linux/interrupt.h>- i) H7 l; k: p) w
- #include <asm/io.h>
6 K- h3 n* H' C9 w7 S# w' s - #include <linux/moduleparam.h>% x. W% c; J% D4 G: c: f
- #include <linux/sysctl.h>( o" Y; s. U' ^5 W* X$ i
- #include <linux/mm.h>
; Z! h' A# r6 f9 z - #include <linux/dma-mapping.h>
& Y5 R, c1 z8 _/ s$ ?" I - ) n+ n2 J5 F" b% u4 V2 R3 F
- #include <mach/memory.h>
- t# [3 O: X6 V% _1 @* B& { - #include <mach/hardware.h>
4 Z }5 Y6 y4 T3 i7 m$ x" O - #include <mach/irqs.h>) k3 v# {2 W- ?& G9 R# \
- #include <asm/hardware/edma.h>
* B) X+ C/ K8 W$ L' s# X
/ Q) e6 _& p" r! o5 G9 h- #undef EDMA3_DEBUG8 c7 ^3 j) s/ a' `$ Z5 c
- /*#define EDMA3_DEBUG*/# ?/ d2 z& p0 }
* a' u t/ D, U) F. }- #ifdef EDMA3_DEBUG6 k) o% \9 Z- N/ I) a8 y1 R
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ K/ e" T8 P% E' Y* i D - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), N `' n( d; E+ Y- v6 r/ O
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' c" A8 m6 I" q - #else# _1 o5 X2 x8 \/ I9 i. w
- #define DMA_PRINTK( x... )
1 B. O3 V) Q6 ~' h* e - #define DMA_FN_IN
) h( E' K b2 `1 k* @& _9 L - #define DMA_FN_OUT
- o$ l: ^% }7 f0 D2 u! I - #endif( o, E( O( r! M4 @
- + p3 j! k$ s% F# @
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 d2 ]" k% W E' x) j - #define STATIC_SHIFT 3* |" c, B# _* T1 i
- #define TCINTEN_SHIFT 204 @7 G; v6 a- W8 o4 Y: e$ s
- #define ITCINTEN_SHIFT 21; x2 ?- f( k* t( l$ ]8 _9 t
- #define TCCHEN_SHIFT 22
9 A8 e! f6 A* Z) M+ \ - #define ITCCHEN_SHIFT 23
% R" ]" b% S0 S; o1 }
6 t8 q2 ]1 a6 F2 }" l5 w- static volatile int irqraised1 = 0;
$ H8 W9 r" z& t7 t+ v - static volatile int irqraised2 = 0;
1 Z4 A9 i, E3 [& N, s, g# p5 J
; K P( O9 \9 D+ P" \1 o6 B1 z) M- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; ^! @9 _( {5 e' u8 k% x* T - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' M+ }) h# s M& I - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# F; d: l$ z1 @, C5 t
* h- P( h' A$ K/ a- dma_addr_t dmaphyssrc1 = 0;$ e! a& }- f/ \5 Z
- dma_addr_t dmaphyssrc2 = 0;
% t2 P- M! b. }8 o1 v3 g( ` - dma_addr_t dmaphysdest1 = 0;
- J/ P1 v( y. u8 p - dma_addr_t dmaphysdest2 = 0;' l5 B! q# O! B. x/ O' I+ F2 X
- 6 u" \8 Z U/ a* J! [6 k* C/ L
- char *dmabufsrc1 = NULL;; |% y4 t8 W; g6 N, D, A: u# W1 g
- char *dmabufsrc2 = NULL;( @+ h& h m4 N5 y2 J$ L
- char *dmabufdest1 = NULL;. m. Z; {5 I1 ^+ B7 M" }7 i
- char *dmabufdest2 = NULL;" ~ i. x* p- V5 D
- N, U9 {' @1 A) t4 K- static int acnt = 512;2 F! V7 M% O: I Z# s
- static int bcnt = 8;" x1 T/ C! {. D6 o1 T/ @$ s
- static int ccnt = 8;
$ u6 V7 ?* N% V9 l - % E6 S: N& ~- W9 J9 E: d7 c- {
- module_param(acnt, int, S_IRUGO);
, w: q+ g* d) m1 u - module_param(bcnt, int, S_IRUGO);( @2 c! F* |! H& Q5 b
- module_param(ccnt, int, S_IRUGO);
复制代码 . L( ?7 K9 s6 i- c
) b7 A+ o" C7 W. K" H9 i5 C 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" k# p* q) u2 J5 V3 A# Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* a7 U% R5 |# m, Y+ @% [7 ]
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 p" v% h, c* s/ v
" B6 p* z. K7 k" M0 k6 f" j; \0 }9 X" L% V8 b0 W
|
|