|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : t$ U1 P$ C( Y$ U6 A
- [code]EDMA sample test application
0 q+ [8 V& I" Z; i - /*/ K9 B3 d- r: r1 ?
- * edma_test.c
4 p \: I8 a/ D% b' L& F. i - *
3 s% q, B9 w" m% v. c - * brief EDMA3 Test Application
3 u" `! s, g9 ?. i. K; r( }6 ` - *6 Z/ _3 A( i8 f7 Q; f
- * This file contains EDMA3 Test code.' @4 i% `' O% I, Y$ y
- *( k) [8 [, D, }% ^* R
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- ^( R4 z$ X! Q" |% k - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, N t& T1 s8 z& d3 F
- * TO CHANGE.0 V2 N! F3 O- x6 {! R% ~2 B
- *
7 d+ V1 D, M- N' g2 N7 Z% L7 ? - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" V3 b' e: h+ I5 [( m1 c - *3 u# n- N8 ~7 {/ m! X6 t
- * This program is free software; you can redistribute it and/or$ p% B* Q6 r: F7 z$ Z
- * modify it under the terms of the GNU General Public License as* s c6 K( F1 {
- * published by the Free Software Foundation version 2.; g1 l8 @( p% j$ f* J
- *; s# K& H' l# E7 b( o
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 \- h# Z; g; C5 I, |
- * kind, whether express or implied; without even the implied warranty
' S: s1 \1 N' A) h1 h- b" G) g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, c6 |& H' J1 T5 n1 b+ q) x% h& l - * GNU General Public License for more details.
; G% y: y, T# d( F, W, Y - */
" u3 m0 q/ g5 L! ]; G. i* [8 |
! i) d5 Z$ F5 z9 J2 F1 D: C9 g- #include <linux/module.h>, y6 ?4 W* O7 d6 R9 n
- #include <linux/init.h>
9 U- _* o4 I; |" P0 U. H - #include <linux/errno.h>) K; H4 n" w6 c2 C8 r2 s/ f
- #include <linux/types.h>
0 ]5 e L, g# z7 \( V% j. w; D - #include <linux/interrupt.h>- X. V2 y1 K. O" X4 [! V+ K( z
- #include <asm/io.h>; q' [" w Q: r8 d) t3 ~/ ^
- #include <linux/moduleparam.h>. i1 a$ O+ N7 o7 |: O$ w
- #include <linux/sysctl.h>
" L% ~0 E" H4 j4 H! Z0 b - #include <linux/mm.h>
+ H( C) Y( F8 ` j O' V8 _ - #include <linux/dma-mapping.h>
8 X4 r4 d7 L5 A, P - - e1 W/ e; s2 m& z W
- #include <mach/memory.h>8 W) @/ _+ O" C
- #include <mach/hardware.h>
0 W+ L, v$ @+ P- e9 D - #include <mach/irqs.h>7 V; \; X8 e* z2 q
- #include <asm/hardware/edma.h>9 b8 q" Z+ w0 W8 B) c6 c
- ! F- H3 t4 N+ h( Z
- #undef EDMA3_DEBUG/ G- B. c' Y) p3 b! X p; C
- /*#define EDMA3_DEBUG*/
W4 c( }4 y: f- J' t6 T
' C2 ?- r: r" ^! J- #ifdef EDMA3_DEBUG
' t+ h: o9 U. F/ w: j$ f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# s4 V' b% y0 }2 y7 u0 |$ f - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 _1 c _3 G2 P6 T
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) J( @# k3 |$ m# u* V
- #else
$ E! x8 ~% O8 | F. X( c1 s1 T - #define DMA_PRINTK( x... )6 c/ b, S0 L3 b0 F" O
- #define DMA_FN_IN0 j7 H( K% [# R. j. @
- #define DMA_FN_OUT
* a; J, K3 z& ]' I* } - #endif9 d7 B- @3 T2 q8 \
- 0 v+ k) y7 c, c y1 j( E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768); I; |# ^( ?* t- }& H
- #define STATIC_SHIFT 39 W' u3 v4 L# |+ }" {* g
- #define TCINTEN_SHIFT 20
1 d' a/ A' e' \1 i' E! c; p! y - #define ITCINTEN_SHIFT 21
) o/ x4 e9 G! S4 ] \4 | - #define TCCHEN_SHIFT 22
; f( z" R( [) j. J - #define ITCCHEN_SHIFT 23
s m* p, E0 q, u2 N. m* X6 k+ ~6 Q2 H
1 {/ A" F% _, E7 i2 P: m- r- W- static volatile int irqraised1 = 0;) @( O* m$ A0 _' i& a+ }
- static volatile int irqraised2 = 0;
7 z6 \9 j! \$ x - $ _4 B5 @, n- h. D4 h! n8 @9 H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 R) A4 k* X3 \% j, H: m
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) e' k. \4 K3 P) V
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 s' v/ f% V. k; M* v - 2 ?3 L# e; O. t/ U
- dma_addr_t dmaphyssrc1 = 0;( y" p6 h' B+ O, {; Q& g
- dma_addr_t dmaphyssrc2 = 0;1 U& {$ v* X% G2 A
- dma_addr_t dmaphysdest1 = 0;& X3 N7 A/ P; ^0 Q, w- Z% ~
- dma_addr_t dmaphysdest2 = 0;
+ U* J6 [6 l8 Y$ ]! o5 p$ @
' A; w4 M8 L" o( t- `% H- char *dmabufsrc1 = NULL;
! x' o6 r( W S' @3 @ - char *dmabufsrc2 = NULL;2 }+ _$ F6 ?0 b$ p* I5 p' U& h5 \# [
- char *dmabufdest1 = NULL;6 e0 X: T" b6 D% M3 x7 ?; f* S% I
- char *dmabufdest2 = NULL;! w6 O6 t" ^2 o
- ' \% a- p$ e9 f T9 B z
- static int acnt = 512;/ I. c/ w% F8 D7 K- u# J( U
- static int bcnt = 8;* m8 z+ M6 i8 Q- j
- static int ccnt = 8;
7 B" t/ {+ E1 i3 m
- c8 w, f8 w; F3 _- module_param(acnt, int, S_IRUGO);
7 I0 `$ P M# v3 R. p" A6 U - module_param(bcnt, int, S_IRUGO);
, U* d0 `3 N7 B/ c - module_param(ccnt, int, S_IRUGO);
复制代码
1 a$ |% X& s4 K; g+ k' ]# l: U3 R9 f9 w+ g/ n* M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( h7 _: t8 a1 ~ Z- f. G$ A5 }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 n+ ]! W3 s# D
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 ?) d4 G5 W& [5 o
" p! W2 f& G% J; ]; `+ a$ x* `! q8 i' k7 N7 z
|
|